Skip to content

Workers accept glob write scopes without allowing workspace escapes - #2399

Merged
santoshkumarradha merged 6 commits into
app/v3from
c27/glob-write-scopes
Nov 5, 2026
Merged

santoshkumarradha merged 6 commits into
app/v3from
c27/glob-write-scopes

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

What changes

Crew planners write glob write scopes such as crew-0-*.md, but the write guard matched only an exact path or a directory prefix. Every write under a glob scope was refused, and the worker ended "INCOMPLETE: nothing was written". The bug was found in a live four-crew run.

Exact and prefix matching came in with 461fcd9. dedbfef normalized scope spellings but never read glob syntax.

Now:

  • A scope is a workspace-relative file, directory or glob. *, ? and [...] match within one path segment, never across /. A matched directory covers its subtree, and exact and prefix scopes behave as before.
  • As in the shell, a wildcard never matches a segment starting with . unless the pattern segment starts with . too. So * never covers .git, .env or .codeaf, and .env* covers .env.local. Git hooks run code, so a scope that looks narrow must not reach them.
  • ** is not supported, and neither planner prompt promised it.
  • A plan whose scope has .., an absolute path, ** or a malformed pattern is refused when it is made. The planner gets a reason it can fix.
  • A path reached through a symlink that leaves the workspace stays refused, including a dangling link.
  • All scope checks share one matcher:
    • the worker write guard;
    • amendment collision checks and the repeat check;
    • quick-task claims;
    • the harness-design rig.
  • Two glob scopes that might overlap are run one after the other, to be safe.

The planner prompt and the crew prompt each gain one line saying what is allowed. Other text was trimmed to match, so both chat prefixes shrink by 10 bytes.

Tests

  • TestWorkerWriteScopeAcceptsSegmentGlobs is red on base: crew-0-a.md was refused under crew-0-*.md. It is green after.
  • crew-1-a.md and ../x stay refused.
  • * refuses .git/hooks/x and .env, ?env and [.]env refuse .env, and .env* allows .env.local.
  • Other new tests cover .., absolute and malformed patterns, a glob reaching a symlinked directory that points outside the workspace, and a glob matching a directory name.
  • The target tests pass 5 times, along with 34 named session neighbours, the amendment tests, and the source and packed manual checks.

🤖 Generated with Claude Code

santoshkumarradha and others added 3 commits November 5, 2026 06:48
The base worker regression refused crew-0-a.md under crew-0-*.md. Commit
461fcd9 introduced exact/prefix matching and accepted unvalidated scopes;
dedbfef normalized scope spellings without interpreting glob syntax.

Share segment matching and scope validation across worker guards, scheduler
collisions, retry detection, quick-task admission and the harness rig. Reject
unsafe plans with repairable reasons and refuse symlink escapes, including
dangling links. Keep exact absolute quick-task scope normalization compatible.
Potential pattern intersections serialize conservatively. No recursive **.

The worker regression was red before implementation. Target tests pass five
times; all named tests in the affected session files and amendment file pass.
Source and packed manual checks pass. Fixed and lean prefix totals each fall
10 bytes; their existing budget failures remain. Changelog check rejects the
required pr: 0 placeholder as expected. No budgets or tests were weakened.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
As in the shell, a wildcard or class never matches a segment that starts
with a dot unless the pattern segment starts with one too, so * never
reaches .git, .env or .codeaf. Git hooks run code, and a scope that reads
as narrow must not reach them. .env* still names .env.local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 5, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 5, 2026
santoshkumarradha and others added 3 commits November 5, 2026 07:56
The glob scope check pushed newQuickSpec to 18 decisions against a
ceiling of 15. The check is now its own function, refuseUnsafeScopes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@santoshkumarradha
santoshkumarradha merged commit 964090f into app/v3 Nov 5, 2026
@santoshkumarradha
santoshkumarradha deleted the c27/glob-write-scopes branch November 5, 2026 15:10
santoshkumarradha added a commit that referenced this pull request Nov 5, 2026
* Accept segment globs in worker write scopes

The base worker regression refused crew-0-a.md under crew-0-*.md. Commit
461fcd9 introduced exact/prefix matching and accepted unvalidated scopes;
dedbfef normalized scope spellings without interpreting glob syntax.

Share segment matching and scope validation across worker guards, scheduler
collisions, retry detection, quick-task admission and the harness rig. Reject
unsafe plans with repairable reasons and refuse symlink escapes, including
dangling links. Keep exact absolute quick-task scope normalization compatible.
Potential pattern intersections serialize conservatively. No recursive **.

The worker regression was red before implementation. Target tests pass five
times; all named tests in the affected session files and amendment file pass.
Source and packed manual checks pass. Fixed and lean prefix totals each fall
10 bytes; their existing budget failures remain. Changelog check rejects the
required pr: 0 placeholder as expected. No budgets or tests were weakened.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2399

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep scope wildcards off dot-named files and folders

As in the shell, a wildcard or class never matches a segment that starts
with a dot unless the pattern segment starts with one too, so * never
reaches .git, .env or .codeaf. Git hooks run code, and a scope that reads
as narrow must not reach them. .env* still names .env.local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fix empty crew plan endings and admit fresh retries

An empty opening fell through synthesis with no results, marked the root done, and announced an unsaved stop. End it through the existing failed-with-detail path and save one assistant notice. Admit retries only for live families that created no workers, through normal budget checks, with a new run and no carried output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2403

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move the write-scope check out of newQuickSpec

The glob scope check pushed newQuickSpec to 18 decisions against a
ceiling of 15. The check is now its own function, refuseUnsafeScopes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Word the empty-plan ending without "stopped"

With the Library re-land also in the manual, the word pulled "what happens
if it will not stop" away from the keys page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 5, 2026
…plan (#2404)

* Accept segment globs in worker write scopes

The base worker regression refused crew-0-a.md under crew-0-*.md. Commit
461fcd9 introduced exact/prefix matching and accepted unvalidated scopes;
dedbfef normalized scope spellings without interpreting glob syntax.

Share segment matching and scope validation across worker guards, scheduler
collisions, retry detection, quick-task admission and the harness rig. Reject
unsafe plans with repairable reasons and refuse symlink escapes, including
dangling links. Keep exact absolute quick-task scope normalization compatible.
Potential pattern intersections serialize conservatively. No recursive **.

The worker regression was red before implementation. Target tests pass five
times; all named tests in the affected session files and amendment file pass.
Source and packed manual checks pass. Fixed and lean prefix totals each fall
10 bytes; their existing budget failures remain. Changelog check rejects the
required pr: 0 placeholder as expected. No budgets or tests were weakened.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2399

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep scope wildcards off dot-named files and folders

As in the shell, a wildcard or class never matches a segment that starts
with a dot unless the pattern segment starts with one too, so * never
reaches .git, .env or .codeaf. Git hooks run code, and a scope that reads
as narrow must not reach them. .env* still names .env.local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fix empty crew plan endings and admit fresh retries

An empty opening fell through synthesis with no results, marked the root done, and announced an unsaved stop. End it through the existing failed-with-detail path and save one assistant notice. Admit retries only for live families that created no workers, through normal budget checks, with a new run and no carried output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2403

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fix truncated opening planner replies settling as empty plans

The planner introduced in 461fcd9 discarded finish reasons and accepted empty syntax repairs. Retain response metadata, retry a lost opening once with more output room, and preserve the cut-off detail through the empty-crew notice and fresh-run recovery path from #2403. Complete explicit empty plans and later planner calls keep their existing behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2404

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move the write-scope check out of newQuickSpec

The glob scope check pushed newQuickSpec to 18 decisions against a
ceiling of 15. The check is now its own function, refuseUnsafeScopes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Word the empty-plan ending without "stopped"

With the Library re-land also in the manual, the word pulled "what happens
if it will not stop" away from the keys page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 5, 2026
…ply (#2407)

* Accept segment globs in worker write scopes

The base worker regression refused crew-0-a.md under crew-0-*.md. Commit
461fcd9 introduced exact/prefix matching and accepted unvalidated scopes;
dedbfef normalized scope spellings without interpreting glob syntax.

Share segment matching and scope validation across worker guards, scheduler
collisions, retry detection, quick-task admission and the harness rig. Reject
unsafe plans with repairable reasons and refuse symlink escapes, including
dangling links. Keep exact absolute quick-task scope normalization compatible.
Potential pattern intersections serialize conservatively. No recursive **.

The worker regression was red before implementation. Target tests pass five
times; all named tests in the affected session files and amendment file pass.
Source and packed manual checks pass. Fixed and lean prefix totals each fall
10 bytes; their existing budget failures remain. Changelog check rejects the
required pr: 0 placeholder as expected. No budgets or tests were weakened.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2399

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Keep scope wildcards off dot-named files and folders

As in the shell, a wildcard or class never matches a segment that starts
with a dot unless the pattern segment starts with one too, so * never
reaches .git, .env or .codeaf. Git hooks run code, and a scope that reads
as narrow must not reach them. .env* still names .env.local.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fix empty crew plan endings and admit fresh retries

An empty opening fell through synthesis with no results, marked the root done, and announced an unsaved stop. End it through the existing failed-with-detail path and save one assistant notice. Admit retries only for live families that created no workers, through normal budget checks, with a new run and no carried output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2403

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fix truncated opening planner replies settling as empty plans

The planner introduced in 461fcd9 discarded finish reasons and accepted empty syntax repairs. Retain response metadata, retry a lost opening once with more output room, and preserve the cut-off detail through the empty-crew notice and fresh-run recovery path from #2403. Complete explicit empty plans and later planner calls keep their existing behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Number the change entry for #2404

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Refuse lost later planner amendments and size syntax repairs

Later planner calls bypassed the opening-only lost-reply guards, allowing cut-off replies and empty syntax repairs to settle as no change. Reuse the existing failure detection so the run notes the refusal, keeps its plan, and continues. Give syntax repair max(8192, twice reported completion tokens), preserving a larger requested recovery cap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Move the write-scope check out of newQuickSpec

The glob scope check pushed newQuickSpec to 18 decisions against a
ceiling of 15. The check is now its own function, refuseUnsafeScopes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name #2407 in its changelog entry

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Name the #2407 changelog file for its pull request

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Word the empty-plan ending without "stopped"

With the Library re-land also in the manual, the word pulled "what happens
if it will not stop" away from the keys page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Take the gated copy of the union merged docs

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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