Skip to content

fix(authoring): protect Windows skill initialization from reader races - #1127

Merged
777genius merged 1 commit into
mainfrom
fix/e2e-windows-skill-concurrency-20261127
Nov 27, 2026
Merged

777genius merged 1 commit into
mainfrom
fix/e2e-windows-skill-concurrency-20261127

Conversation

@777genius

@777genius 777genius commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Problem

The continuing #1087 qualification exposed a real Windows AMD64 Authoring failure on #1125: job 140220504679 reported expected one commit, got 0 in TestInitCollisionCancelAndConcurrent/concurrent-absent. Two initializations of the same Skill must produce exactly one publication while preserving existing data.

The original test discarded both errors. Its artifact proves the failure, but cannot identify which syscall failed. Source review found two concrete Windows sharing conflicts consistent with it:

  1. A losing full source read can begin before the winner acquires its reservation, then descend into the winner's new private stage. Its directory pin denies DELETE sharing and can prevent opening the payload for exclusive publication.
  2. A reader holding only the destination parent can delay the final rename syscall.

The failed workflow's existing checked-package-publication controls all passed, including the parent-reader cases. This change reuses that established mechanism for Skills and adds a control for the earlier payload-open conflict.

Changes

  • Acquire DELETE access atomically with exclusive creation of the private Skills stage. Retain the guard through owned-stage removal so a competing source walk cannot descend into the payload.
  • Preserve the existing protected current-user DACL. Generic staging keeps its current behavior, and POSIX continues to use the existing private mkdir.
  • Use the existing bounded checked no-replace publication for Skills. Every eligible commit attempt rechecks source/core CAS, package and parent identities, complete generated bytes, reservation/stage/payload identities, destination absence and cancellation. The same anchored source handle is retained. Initial source-open failures are outside the retry policy.
  • Keep the strict exactly one commit assertion and retain both attempts' reports and errors in failure diagnostics.
  • Add the ordinary-versus-guarded stage control, five portable publication controls, and 14 real Windows reader-process cases across absent and existing Skills directories. They cover release, collision, cancellation, persistent sharing, generated bytes, core changes, reservation replacement or specifically validated kernel protection, and complete owned cleanup.

The publication checks move to a cohesive helper so the legacy Skill-plan file shrinks. No lint exemptions or source-reader sharing rules change.

Source and review

Base is merged #1126: f60cbdf812b63fa4647728666c547947ec5f1147. This PR changes exactly ten Authoring code/test files and preserves the Firebase custody correction.

Local commits 9c248a5215b2b3d3edeb3d68a148700e69689e27 and b09ba3276efe3803e5bf93b305ab5b0945f1a0bf produce tree 5c84c8e54871ac41736ef2b4a55d8614817a98f3. Published head e4847a00434e4fa3d9555e75024bb8c571fc32ba has that exact GitHub-verified tree. Independent review of the stage primitive, publication path and complete diff found no blocking issue.

Validation completed

  • Full Linux Scaffold and Skills packages passed; final concurrent-init regression passed.
  • Five portable publication controls fail against the original integration and pass with this change.
  • Windows AMD64 scaffold test compilation passed with the new controls. Compilation is not native Windows execution.
  • Formatting, whitespace, focused Linux and Windows size/architecture checks passed. The legacy code-line ratchet passed with all 137 exclusions unchanged.
  • The broader local Authoring attempt completed nine packages; its native lifecycle test failed while linking the real CLI because the host killed the linker. The full-module linter and narrowed changed-line linter were also killed. Those attempts are not reported as successful full gates. Complete lint and native execution remain hosted requirements.

Merge and continuing qualification

Ordinary squash merge completed at 00:47:02 UTC as 472d0b157f21b1b5c2a5b716ccc8f49577e7262f, with parent f60cbdf812b63fa4647728666c547947ec5f1147. GitHub Git Data confirms that the actual merge and PR synthetic commit 63ae91124bffb5fb054201ff8a3a9427ec9b2270 have the same complete reviewed tree 5c84c8e54871ac41736ef2b4a55d8614817a98f3 as the local and published heads.

Automatic PR Authoring, PR Required, and post-merge Required are queued/running and are not yet passes.

Hosted qualification required

Native Windows execution of the combined correction, the original concurrency test, platform Authoring qualification, Required lint and Core remain required. They run through the normal automatic PR/push workflows. Existing #1087/#1119/#1125/#1126 checks continue, including the full Firebase data-tree custody case through Remaining/Windsurf.

No CI cancellation, rerun, protection bypass or release publication is part of this change.

Summary by CodeRabbit

  • Bug Fixes
    • Skill creation now revalidates staged content and destination ownership before retrying publication. This helps prevent publishing after relevant files or reservations have changed and preserves conflicting files.
    • On Windows, skill publication can retry when a temporary file-sharing conflict clears, while still respecting cancellation and retry limits.

Preserved profile identity follow-up — 27 November 2026

#1128 addresses the additional deterministic Required failure at authoring-native-qualification.test.js:1152 (job). #1121 had appended informational status to the fully byte-hashed profile README, changing its public digest despite unchanged published 1.0 rules.

The correction restores the exact 9,012-byte captured profile (sha256:2bffd36f3e4ef0bdc1b25c3153b847542011a01af2f0b35ec31f2bc747952789) and preserves every accepted upstream fact in the existing clarification notes. Production pins, independent assertions, schemas, profile revision and Go hash semantics are unchanged. The existing regression reproduces the mismatch before correction and passes afterward (1/1, no skips); two independent reviews found no issue.

Published head 4e2acd9344fdacf2215ddece1ed956db36245ee1, local reviewed commit c6f903a73324e40e74e0d99e8e824952789edb85, and PR synthetic commit 6510a11c2d5621771dad9152ba20e450f120eb68 share exact tree eaf1aa1ffd491a4d92abdc852201f9ed0c283834. The broader local npm attempt was terminated by SIGKILL, so it is not full-suite proof. Final source-bound Required/npm and native E2E outcomes remain pending; historical failures and artifacts keep their original source identities.

Windows snapshot observer follow-up — 2026-11-27

PR #1131 was merged normally at 04:27:27 UTC. Its test-only correction addresses the three replacement-test failures in Windows Authoring job 140287944492: ordinary snapshot opens conflicted with the correctly retained private-stage DELETE guard before the rename attack ran. That job passed both concurrent creation cases and all 14 reader-process publication controls, but remains a failed run overall.

The observer now reads through existing rooted APIs, retaining all paths, modes, bytes and literal link targets. A new Windows regression verifies complete guarded-stage and parent snapshots while ordinary/source-reader opens remain refused. Production guards, lifetime, publication, cleanup, attacks and accepted rename errors are unchanged. Local Scaffold/Skills validation passed 172 tests with zero skips; Windows AMD64 test cross-compilation passed, without claiming native execution. Two independent reviews found no issue.

Head cb03f9c856806039424618fcef4d31de736357bb, synthetic PR commit b9993e7df9d3e5d1c1504f89d8515da19e2f89d5, and main merge f75a1b9ee3d1518c519f74d0f8b9c562c3af3503 share the reviewed tree 9b364c850b8f985a96bcb1ded33e2451b55de31a. Fresh Required, Authoring and Native Client Runtime checks are pending. Existing installation/Marketing component reports retain their original source identities. No CI rerun, cancellation, dispatch, runner change or protection override was used.

Hold DELETE access from private Skills stage creation through owned cleanup so competing source readers cannot pin the payload. Reuse the existing bounded checked no-replace publication, revalidating source/core, identities, generated bytes, reservation, destination absence and context on every eligible commit attempt.

Preserve the strict one-commit concurrency assertion and retain both actual errors. Add deterministic Windows reader controls and portable refusal regressions. Native Windows execution and complete hosted gates remain required.
@strix-security

Copy link
Copy Markdown

Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here.

So far, Strix has reviewed 392 pull requests, surfaced 113 security issues (1 critical/high) and blocked 3 risky merges across this workspace.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Skill publication now uses a guarded private stage and checked publication that revalidates transaction state before commit attempts. A concurrent initialization test also reports the results and errors from each attempt when the commit count is unexpected.

Changes: Skill Publication

Layer / File(s) Summary
Guarded skill staging
cli/internal/authoring/scaffold/stage_posix.go, cli/internal/authoring/scaffold/stage_windows.go, cli/internal/authoring/scaffold/skill_plan.go, cli/internal/authoring/scaffold/stage_skill_windows_test.go
Skill staging now returns a guard. On Windows, the guard retains a directory handle with DELETE access. ApplySkill closes the guard after staging. Windows tests exercise guarded staging and reader-blocked publication.
Checked publication and revalidation
cli/internal/authoring/scaffold/apply.go, cli/internal/authoring/scaffold/rename_windows.go, cli/internal/authoring/scaffold/skill_plan.go, cli/internal/authoring/scaffold/skill_publication.go, cli/internal/authoring/scaffold/skill_publication_test.go, cli/internal/authoring/scaffold/skill_publication_windows_test.go
ApplySkill configures checked publication. Checks validate the payload tree, precondition, recorded file identities, payload type, and context. Tests cover retry, cancellation, collisions, changed state, and cleanup.

Initialization Test Diagnostics

Layer / File(s) Summary
Capture concurrent initialization attempts
cli/internal/authoring/skills/skills_test.go
The concurrent initialization test records each Init result and error and includes the attempts in its failure message when the committed-attempt count is not one.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ApplySkill
  participant renamePackage
  participant skillPublication
  ApplySkill->>renamePackage: Start checked publication
  renamePackage->>skillPublication: Validate transaction state before an attempt
  skillPublication-->>renamePackage: Return validation result
  renamePackage->>renamePackage: Retry eligible failed commit against the held source
Loading
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@777genius
777genius merged commit 472d0b1 into main Nov 27, 2026
49 of 53 checks passed
@777genius
777genius deleted the fix/e2e-windows-skill-concurrency-20261127 branch November 27, 2026 00:47
777genius added a commit that referenced this pull request Nov 27, 2026
Use compatible rooted reads for complete test snapshots while retaining the production Windows stage DELETE guard and all existing replacement attacks. Add native guarded-stage and portable root-leaf regressions.

Follow-up for #1087 and #1127. Local Scaffold/Skills tests: 172 passes, zero skips; Windows AMD64 test binary compiles. Native E2E qualification continues on the selected PR checks.
@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.38%. Comparing base (f60cbdf) to head (e4847a0).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
cli/internal/authoring/scaffold/skill_plan.go 75.00% 1 Missing and 2 partials ⚠️
...i/internal/authoring/scaffold/skill_publication.go 86.66% 1 Missing and 1 partial ⚠️
cli/internal/authoring/scaffold/stage_posix.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1127   +/-   ##
=======================================
  Coverage   64.37%   64.38%           
=======================================
  Files        2352     2353    +1     
  Lines      143065   143080   +15     
=======================================
+ Hits        92104    92118   +14     
+ Misses      37898    37896    -2     
- Partials    13063    13066    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant