Skip to content

Guard artifact project identities against case-colliding paths - #3223

Closed
Kkkkkuro wants to merge 4 commits into
garrytan:mainfrom
Kkkkkuro:codex/case-path-guard-v37
Closed

Kkkkkuro wants to merge 4 commits into
garrytan:mainfrom
Kkkkkuro:codex/case-path-guard-v37

Conversation

@Kkkkkuro

@Kkkkkuro Kkkkkuro commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Git can record two project directory spellings while a case-insensitive checkout materializes one directory. Exact spelling claims prevent new aliases, but a short claim that ends before a writer reads/appends is insufficient for historical migration.

This candidate keeps the existing identity guards and adds cooperative per-project writer lifetimes. Native shell/Bun entries retain admission across complete operations; libraries retain it across reads, writes, close and async settlement. Skill-start/end retain a workflow lease for direct agent report writes. Browser/design publishers and arbitrary destinations use the same path-aware admission; unresolved links and alternate project roots refuse. Received image bytes follow the existing recovery-copy path without another model call.

Compiled tools use helpers from their own installation layout, including the browser slug shell helper. This closes source-only deployment gaps; old daemons still need a controlled drain/restart. Direct render/PDF/snapshot APIs admit all destinations before business reads.

Metadata lives outside the moving bucket and folds NFC/case identity. A pending maintenance window denies new writers, waits for admitted writers, and becomes exclusive only after all leases end. Other projects continue. Unknown/dead ownership and expired windows never age-reclaim. An interrupted holder keeps its lease if its child is still alive; admitted native children obtain separate retained leases. This is cooperative admission, not process-tree containment or an OS security boundary. Legacy sessions, older daemons, root Git locking and the native GBrain owner/fence/CAS recovery still require operational qualification.

Validation:
-57 passed/0 failed: native admission and existing case-collision suites, including actual killed/interrupted owners, async children, nested claims while draining, persistent native skill leases, Unicode/case identity, dangling links and paid-image byte retention.
-37 passed/0 failed: complete skill-start/end suite, keeping its original5-second per-test limit. A prior combined123-test run had one intermittent held-sync attention failure (122 passed); that broader result is not certified.
-109 passed/0 failed: domain-skill storage/writes, gallery, image persistence, brain cache and headless artifact acknowledgement.
-39 passed/0 failed: full evidence wrapper suite. Duplicate slug resolution was removed to preserve the existing startup budget and command-result transparency.
-151 passed/0 failed: direct PDF/render/design/Autoplan writers, native compiled and Node-bundle helper resolution, multi-destination refusal, delayed nested rendering and installed-helper fixtures.
-20 passed/0 failed: native publisher drain checks and domain-skill storage; the admitted domain RMW retains its second identity check while draining.
-16 passed/0 failed: public PDF CLI exits and HTML/DOCX format gate.
-75 passed/0 failed: final case/identity/window/publisher/compiled regression, including consumed-source refusal and inherited identity liveness delegation.
-Product TypeScript check and diff checks passed. The test typecheck ratchet reports two existing diagnostic identities with checkout-path normalization differences; no baseline was widened.

Qualification limits: POSIX maintenance behavior only; Windows ordinary leases use SYNCHRONIZE-only process liveness rather than sending a signal, and Windows maintenance explicitly refuses pending qualification. Platform-scoped tests retain the unsupported-platform refusal contract. Native Windows CI is required. Local QA containment/timeout tests still expose EPERM when signalling child process groups (also reproduced on the pre-change baseline and an independent bounded probe); these failures are retained, not converted to success. No strict release/full free-suite/production exclusion claim. Installed copies, production services, schema, credentials, fees and live report data were not changed by this contribution.

Public scan: no HIGH findings; two exact nonsecret numeric matches were manually verified (the unchanged AWS IMDS comment and synthetic dead-owner PID). No private operation snapshots or conversations are included.

Refs #3220.

@trunk-io

trunk-io Bot commented Oct 16, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@Kkkkkuro
Kkkkkuro marked this pull request as ready for review October 16, 2026 20:15
@capy-ai

capy-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Triage (fix wave 5, GSTA-37): thanks for the careful work on #3220. It isn't in this wave: the PR changes 69 files (+3138/−1088), including 7 that open wave PRs are changing (gstack-evidence, gstack-gate-diff, gstack-gbrain-sync.ts, gstack-skill-end, gstack-timeline-log, browse meta-commands, headless-artifacts), and it adds a cooperative per-project writer-lease system across every artifact writer. That's a design decision for Garry, not a severity fix. A narrower first step (verify staged entries after git add and refuse new casefold collisions in brain-sync) would be easier to land on its own.

capy-ai Bot added a commit that referenced this pull request Oct 17, 2026
…ad of reporting ok (#3220) (#3254)

* fix(brain-sync): verify requested index entries after add

Refuse missing or unrelated staged paths and stale indexed content without consuming the queue or resetting the index.

* fix(brain-sync): refuse new casefold path collisions

Check component prefixes in requested/index and outgoing trees, including retained commits and fetch/merge retries. Preserve historical aliases, local commits, index, and queue on refusal.

* fix(brain-sync): hold case-colliding paths instead of halting the sync (#3220)

Builds on Kkkkkuro's staged-index and casefold checks (#3245, from #3223).
A queued path whose spelling differs only by letter case from another path
in the index or the batch is held before staging: it stays queued, every
other file keeps syncing, and the status is "collision" rather than "ok".
An established spelling keeps syncing; only the new alias waits.

Skill start prints one ARTIFACTS_SYNC attention line naming the colliding
names and the repair anchor (docs/troubleshooting.md#artifact-case-collision);
gstack-doctor warns the same way. The outgoing check is cached by HEAD so
the empty-queue drain at every skill boundary stays near main's cost.
gstack-slug and skill start's slug path are unchanged.

Co-authored-by: Kkkkkuro <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(brain-sync): close review gaps in the case-collision hold

- Windows: write the held-path list with LF and strip CR from helper output,
  so CRLF cannot let a held path through or blank case_names.
- --publish-removals runs the outgoing case check before it pushes.
- The cached outgoing verdict is keyed by every ref, not HEAD alone, so a
  moved remote baseline is re-checked.
- The repair snippet folds only JSONL logs and lists snapshots and other
  files for a manual decision.

Co-authored-by: Kkkkkuro <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(brain-sync): second review pass on the case-collision hold

- The repair loop also folds the dropped spelling's untracked (held) files
  and says to check for leftovers before removing the folder on Linux.
- The cached outgoing verdict also keys on HEAD's symbolic target.
- The outgoing check no longer needs a temp file, so a failed mktemp can
  no longer skip it.

Co-authored-by: Kkkkkuro <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test(brain-sync): give the retry-merge fixture a git identity

The retry merge commits with the ambient identity. CI and Ubicloud runners
have none under the test HOME, so the merge failed before the outgoing case
check ran and the drain reported push_failed instead of error.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs(changelog): unreleased entry for the #3220 case-collision hold

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* v1.91.126.0 stamp

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: KuroChen <[email protected]>
Co-authored-by: Kkkkkuro <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Thank you, @Kkkkkuro. You found a real bug, and your collision detector is now in gstack. #3254 (v1.91.126.0, 4e4f295) landed it with your authorship on the cherry-picked commits and Co-authored-by on the follow-ups, and it fixes #3220: brain-sync holds case-colliding paths instead of reporting success, skill start and gstack-doctor print a one-line warning, and docs/troubleshooting.md#artifact-case-collision documents the repair.

We're closing this PR without the writer-lease half. On current main it made python3 required for every skill, tripled gstack-slug latency, could stall skill start for about 5 s with a STOP, and refused separate Linux projects named MyApp and myapp. Automatic cross-device repair of existing collisions may come back later as its own design-reviewed PR. If you'd like to take that on, open an issue first and we'll scope it together.

@capy-ai capy-ai Bot closed this Oct 17, 2026
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