Skip to content

test: drop route copies of the script ancestry matrix - #4671

Merged
thymikee merged 10 commits into
mainfrom
test/trim-script-route-ancestry
Nov 18, 2026
Merged

thymikee merged 10 commits into
mainfrom
test/trim-script-route-ancestry

Conversation

@thymikee

@thymikee thymikee commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Removes route-level copies of the path-shape matrix that #4584 added. host-kit's destination rule owns those shapes. Touches 5 files.

  • Daemon writer suite: 20 cases down to 9, parameterized over force and exposure.
  • Remote suite: 15 cases down to 13, parameterized over force, version and how the parent changes.
  • Each kept route case catches a change that only the route can make: canonicalizing or folding the caller's spelling, creating directories early or after approval, staging, committing or confirming on any publish branch, or disclosing the failure.
  • Adds two host-kit tests: creating a missing level under a sticky directory, and under umask 0200.
  • Adds two refusal cases outside the ancestry suites: an active session save-script, and a completed repair, each to a shared directory.

Validation

Mutations ran on this patch in a disposable checkout on macOS, Vitest unit-core. The route, handler and repair cases skip on win32. In host-kit, the 15 decision cases and the parent suite's relative-path case also run on Windows. No CI lane runs Windows.

Planted regression Retained detector
host-kit rule: modes, owners, hint, links, .., umask 002, sticky creation, confirm, staging, file mode host-kit ancestry/parent/decisions
host-kit: no chmod after mkdir parent umask 0200 (EACCES)
writer: realpath (always or forced); forced writes through the generic publisher daemon shared-link refusal (force ×2)
writer: approve, then stage through the generic publisher (always or forced) daemon link-.. (force ×2, staged)
writer: folded-parent mkdir after approval daemon link-.. (home/y stays absent)
writer: early or normalized mkdir, fold, bypass, rewrapped error daemon backtrack, missing-parent, link-..
writer: hint stripped missing-parent (×2, chmod g-w <dir>)
writer: active save through the generic publisher handler active-save refusal
writer: completed repair through the generic publisher writer complete-repair refusal
remote: realpath at record creation private link, foreign hop, replacement
remote: early, normalized or folded-parent mkdir, before or after approval; fetch first backtrack, missing-parent (fetches), sticky folded-parent
remote: preflight judges the nearest existing directory sticky folded-parent (success expected)
remote: spelled staging or commit on any branch (first, forced, replacement); link becomes rename staging race (force ×2, swaps, staged, bytes)
remote: confirmation skipped on any branch download race (first, forced, replacement; earlier bytes survive)
remote: confirmation skipped when the spelled parent matches the prepared directory download race (parent recreated at the same path, parent made group-writable)
remote: reason changed, cause, warning or replaced hint dropped every refusal, via readScriptDeliveryFailure

pnpm typecheck, pnpm lint, pnpm check:production-exports and pnpm check:fallow pass. pnpm exec vitest run --project unit-core over the two route suites, the handler suite, the writer suite, the three host-kit suites, and the hostile-daemon and download suites gives 187 passed. CI validates the pushed head.

🤖 Generated with Claude Code

thymikee and others added 2 commits November 18, 2026 10:48
…t paths

The writer ancestry suite repeated the path shapes that host-kit's
destination rule already pins. Keep three cases that host-kit cannot
see: a private acceptance, a missing-parent refusal that proves the
writer creates nothing first and returns the typed refusal, and a
link-plus-`..` save that proves the writer passes the caller's spelling
through without folding it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The remote ancestry suite repeated host-kit's path-shape matrix. Keep
a missing-parent refusal that also proves no version is fetched and the
warning is disclosed, one success that pins both physical staging and
the physical commit, and the replacement-during-download refusal.

host-kit had no positive for creating a missing level under a sticky
directory this user owns, so pin it there. The test-kit ownership
fixture has no remaining consumers, so remove it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.40 MB 6.40 MB -21 B
Package (unpacked) 6.40 MB 6.40 MB -21 B
Package (download) 1.94 MB 1.94 MB -9 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 42.1 ms 45.0 ms +3.0 ms
CLI --help 70.9 ms 94.5 ms +23.6 ms

@thymikee

Copy link
Copy Markdown
Member Author

The PR is ready at 9e0afa6: dropping the route copies of the script ancestry matrix looks right, since the host-kit tests still cover the walk and the retained route tests still reach the same route functions. Not blocking: the retained route tests (for example daemon-artifacts-script-ancestry.test.ts), the daemon file and the new host-kit sticky test carry long comments about the link/.. fixture layout, and trimming each to the one-line invariant it pins is optional. CI is still running (Smoke Tests, Coverage) and nothing has failed. There are no conflicts.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@apex-sentinel-staging

This comment has been minimized.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@thymikee

Copy link
Copy Markdown
Member Author

I'm withdrawing the earlier ready verdict at 9e0afa6 and removing the ready-for-human label. A mutation cross-check of this head found two regressions that the retained tests no longer catch:

  • A route that resolves the parent with realpath before passing it to host-kit would hide an unsafe link. All 203 retained tests still pass under that mutation, and only the deleted route cases catch it (5 daemon, 6 remote).
  • An early recursive mkdir on a path with .. leaves directories behind after the refusal. Only the deleted backtracking cases catch it.

Please keep one case per route for each of these, so the matrix lives in host-kit and each route still proves it hands host-kit the spelled path unchanged. I'll review again at the new head.

thymikee and others added 2 commits November 18, 2026 11:03
Canonicalizing the parent or creating directories before the rule
answers are writer-side changes that host-kit cannot see. Restore a
private link standing on shared ground, the missing-directory
backtrack, and the unsafe `..` destination, each asserting that the
refusal leaves no directory behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore the missing-directory backtrack, the unsafe `..` destination,
a private link on shared ground, and a foreign-owned hop. Read every
refusal through readScriptDeliveryFailure with its publication ID. The
success case now asserts that the swap ran, and the replacement case
retargets an alias so a skipped confirmation would publish. Keep the
test-kit ownership fixture, which the foreign hop uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

thymikee and others added 2 commits November 18, 2026 11:21
Restore the staging-location assertion in the link-plus-`..` success,
which catches a writer that judges the destination but stages beside
the caller's spelling. Run the shared-link refusal with and without
force, since a forced write takes its own publish branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extend the staging race to a revision-2 replacement, which is
published by rename rather than link. Add a success case whose folded
parent is absent and must stay absent. Assert the replacement
refusal's warning. Pin, in host-kit, the missing-parent creation under
umask 0200, which needs the post-mkdir chmod.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

thymikee and others added 4 commits November 18, 2026 11:44
Run the link-plus-`..` success with and without force, with the folded
directory absent, so forced writes that stage beside the spelling and a
stray `mkdir` of the folded parent are both caught. Assert the recovery
hint on the missing-parent refusal for world- and group-writable
ground. Add one active `session save-script` case that expects the
typed refusal for a shared directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the staging race with and without force, and the retarget during
download on the first, forced first, and replacement versions, so each
publish branch must stage, commit and confirm in the judged directory.
Assert a non-empty hint on the replacement refusal. The folded-parent
case now creates its level under a sticky directory, which restores
the sticky-parent coverage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A completed replay repair publishes to an explicit caller output, so
it goes through the same destination rule. Add one refusal case next
to the commit-when-complete test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add two rows to the download race: the parent directory removed and
recreated at the same path, and the parent made group-writable. A
route that skips confirmation when the spelled parent matches the
prepared directory now fails both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

I reviewed 27e2b49 and found no problems in the code. The earlier findings from 9e0afa6 (#4671 (comment)) are now fixed, and nothing remains open from them. 16 of 17 checks pass and the last one is still queued. The diff touches only test files, so no failing job covers a production route. There are no conflicts. The assertions match session-script-writer.ts and host-kit atomic-file.ts, and the mutation results come from the PR body. The Windows paths are skipped by skipIf, and no CI lane runs Windows, as the PR body says. Nothing else needs to change before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 27e2b49

Since the review of afa3f8f: 1 new · 0 still open · 0 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/daemon/src/core/__tests__/session-script-writer-ancestry.test.ts:42 🆕 Daemon ancestry test matches host-kit's hint prose verbatim, incl. a phrase with no path

Reviewed with this repository's own Sentinel configuration (684c59480774).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 27e2b49. The verdict and the full list are in the summary comment.

Comment on lines +42 to +44
test.skipIf(process.platform === 'win32')(
'a recording saves a private script under a chain only this user can write',
() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆕 🟡 Minor · Daemon ancestry test matches host-kit's hint prose verbatim, incl. a phrase with no path

hint: (_dir: string) => 'only you can write' asserts the refusal's hint contains that literal phrase, so any rewording in host-kit's hint prose fails this daemon route suite even though nothing the writer does changed. AGENTS.md says "Do not match error text."

⚠️ Check this patch before you commit it: the review doubted it would be right as written.

Suggested change
test.skipIf(process.platform === 'win32')(
'a recording saves a private script under a chain only this user can write',
() => {
test.skipIf(process.platform === 'win32').each([
{ mode: 0o777, exposure: 'world_writable', hint: undefined as string | undefined },
{ mode: 0o775, exposure: 'shared_group_writable', hint: (dir: string) => `chmod g-w ${dir}` },
])(
Details

persona: maintainability

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

@thymikee
thymikee merged commit 1c6e81c into main Nov 18, 2026
17 checks passed
@thymikee
thymikee deleted the test/trim-script-route-ancestry branch November 18, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant