Repository navigation
v1.92.69.0 fix: lock developer-profile writers so overlapping derives keep every session (#3437, #3435) - #3738
Merged
Conversation
…e temp file (#3437) Concurrent background --derive runs shared developer-profile.json.tmp and rewrote the whole profile unlocked, so renames failed with ENOENT and a concurrent --log-session was dropped. Every read-modify-write now holds developer-profile.json.lock and writes a mktemp file. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Both lost their last production caller when --derive moved onto accumulateSignals; only three unit tests referenced them. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Use the PID in the lock token, anchor a relative state root once so do_derive's cd cannot leak the lock, and note the stale-takeover tradeoff. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Keep Windows drive-letter state roots absolute when anchoring a relative root, and say which writers do not take the lock yet. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Step 11 voices: a late stale-lock mv could evict a fresh owner, a failed mv spun past the timeout, and the 10 s give-up sat under the 30 s stale age. Takeover now checks the holder's pid, re-reads the owner under a takeover lock, falls through to the give-up on failure, and reports an unwritable state directory at once. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A crashed holder whose pid now belongs to a live process kept its lock forever. An owned lock past 5 minutes now counts as abandoned, and cleanup removes a takeover lock this writer holds. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… removal (#3435) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Overlapping background
--deriveruns no longer drop /office-hours sessions or fail with ENOENT (#3437).gstack-question-logstarts a backgroundgstack-developer-profile --deriveafter every append, and a multi-question AskUserQuestion logs several rows at once. Every derive wrote the same fixeddeveloper-profile.json.tmpand rewrote the profile without a lock.--derive,--log-session,--reconcileand--migratenow holddeveloper-profile.json.lockfrom before they read the profile until after the rename, and each writes its ownmktempfile.developer-profile.json.lock.takeover, and interrupt cleanup removes a takeover dir the process holds.Dead helpers removed (#3435).
applySignalandnewDimensionTotalsinscripts/psychographic-signals.tslost their last production caller when--derivemoved toaccumulateSignals; they and their three unit tests are gone.Proof
test/gstack-developer-profile.test.tseach failed on the code before their fix: directory at the old temp path, held lock blocking derive and log-session, stale, dead-holder and aged live-pid takeovers, a takeover in progress, an unremovable lock still giving up, a relative state root, and 6 rounds of 6 derives keeping every session.Security read
A local state writer only: no network calls, no new environment reads beyond the test-only
GSTACK_PROFILE_LOCK_TIMEOUT_MS, no permission widening, no workflow, setup or install edits, and no new dependencies. No outside code was carried over.Review notes
Below the blocking floor (would not fail a test, break production, or lose data); recorded, not fixed here.
C:foois not anchored.gstack-distill-applyand /plan-tune's declared-profile edits still read-modify-rename without the lock (pre-existing; called out in the changelog fragment).docs/troubleshooting.mdhas no entry for exit 5.Documentation
Status: blocked, with the owner's named risk.
Documentation exception: accepted by GStack Minder (Captain) 2026-10-31 via GSTA-216 Captain reply: Do it: docs risk accepted: Docs audit gsta216-docs-2 covered the diff before 022210e; the only later change is a one-line test type fix that no doc references.
Scope: base 3bfe566 to head 3b15c19 on garrytan/gsta216-plan-tune-profile-lock: 8 commits and 5 files (bin/gstack-developer-profile, scripts/psychographic-signals.ts, two test files and one changelog.d fragment), with no staged, unstaged or new files. I listed 909 tracked and new .md and .tmpl files, then searched them for gstack-developer-profile, applySignal and newDimensionTotals, psychographic-signals, the profile .tmp and .lock paths, and exit 5. I read the docs that matched.
Documentation health:
--log-session ... || truecalls are unaffected.Coverage debt:
--derive,--log-session,--reconcileand--migrateGSTACK_PROFILE_LOCK_TIMEOUT_MS(test-only)applySignalandnewDimensionTotalsThe common gap: neither exit-5 message ('another writer held for N ms' or 'cannot create ') has a docs/troubleshooting.md section with an anchor and a Fix line. I flagged it rather than filling it.
/document-generatecan fill it later.Diagram drift: none. No architecture diagram names the profile writer or the signal helpers.
Summary
Overlapping
gstack-developer-profilewriters no longer lose /office-hours sessions or fail with ENOENT (#3437).--derive,--log-session,--reconcileand--migratenow holddeveloper-profile.json.lockfrom before they read the profile until after they rename it, and each writes its ownmktempfile. The dead helpersapplySignalandnewDimensionTotalsare removed with their three tests (#3435).Why
gstack-question-logstarts a background--deriveafter every append, and a multi-question AskUserQuestion logs several rows at once. Every derive wrote the same fixeddeveloper-profile.json.tmpand rewrote the profile without a lock. On main at 3bfe566, 30 rounds of 8 overlapping derives plus one--log-sessionsaw 9 of 270 runs fail with ENOENT on rename and lost 2 of 30 sessions. On this branch the same run has 0 failures and keeps 30 of 30 sessions.Blast radius
One shell script and its tests. The owner file names the holder's process ID and release is ownership-checked. A lock is taken over when its holder is gone, or once it is 5 minutes old even if a process with that ID is running, since the ID may have been reused. Takeovers go one at a time under
developer-profile.json.lock.takeover, and interrupt cleanup removes a takeover lock the process holds. A writer that can't get the lock in 10 seconds writes nothing and exits 5; an unwritable state directory fails right away. A relative state root is anchored once, and Windows drive-letter roots stay as they are.gstack-distill-applyand /plan-tune's declared edits still write without the lock (noted in the changelog fragment).Pre-Landing Review
REVIEW_LOOP: passes=2 blocking_found=1 deferred=0 noted=7 fixed=6 scope=frozen fix_checks=4
The pid-reuse finding past the review cap was fixed under GStack Minder's written approval (2026-10-31). Below the blocking floor and not fixed here:
C:foois not anchored.docs/troubleshooting.mdhas no entry for exit 5.Issues
Fixes #3437
Fixes #3435