[v0.8 Core 9] preserve recovered worker registry authority - #1336
Open
sethkarten wants to merge 2 commits into
Open
[v0.8 Core 9] preserve recovered worker registry authority#1336sethkarten wants to merge 2 commits into
sethkarten wants to merge 2 commits into
Conversation
Reconstruct the unique net delta from PR #1267, excluding propagation merges.
jonaowen
suggested changes
Aug 13, 2026
jonaowen
left a comment
There was a problem hiding this comment.
The worker override ordering is sound, but the registry authority is not pinned transitively yet.
getDaemonSupervisorRegistryDir()returns environment text verbatim. A relative or Windows drive-relative value is interpreted from the predecessor/supervisor cwd, while workers and the update successor can run with different session/default cwd values. The identical injected string can therefore name different physical registries. Normalize once to an absolute path (or reject non-absolute values) before ownership and forward that exact authority to workers and every successor supervisor.assertRecoveryAllowed()callsisDaemonShutdownAdmissionActive()without the captured registry, so it re-reads ambientprocess.env; self-relaunch does the same. Later environment drift can make admission checks consult B while ownership/fences live in A. Pass the capture explicitly through admission/recovery and relaunch, and ensure worker owner/admission/fence reads do not independently drift.
Please add behavioral coverage with distinct supervisor/worker/successor cwd values, persisted-descriptor recovery under a second generation, ambient A→B drift with admission held separately in A/B, update self-relaunch receiving A, and Windows relative/drive-relative plus case-varied caller env keys. The current mocked test only inspects worker SpawnOptions.env for one in-memory descriptor and does not exercise these authority boundaries.
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.
Replacement scope
This PR reconstructs and supersedes the unique implementation delta reviewed in #1267 without rewriting that historical branch. The original PR remains the immutable discussion record: #1267
v080/core-split-c7-lifecyclev080/core-split-c9-worker-registry5413a1ca6092689c1fb1eb2f5ced6c300d45b2ad77b188b92dc91365cb2bc41bdb46a50669d104a8) is the shared foundation. For reconstructed deltas it is a proven tree-compatible base, not an ancestry claim about the historical PR stack.Validation
tsgo --noEmit: passNo original PR was retargeted, closed, merged, or otherwise mutated.
Note
Medium Risk
Changes daemon ownership and worker spawn env for a security-sensitive coordination path; behavior shifts if anything relied on overriding the registry env var.
Overview
Pins the daemon supervisor registry directory so ownership, startup fences, and recovered workers all use the same on-disk authority instead of re-resolving from ambient
process.envon each call.DaemonSupervisorcapturessupervisorRegistryDirat startup and passes it intowaitForDaemonStartupFence,acquireDaemonSupervisorOwnership, and every worker spawn. WorkerenvsetsPRIME_AGENT_INTERNAL_DAEMON_SUPERVISOR_REGISTRY_DIRafter inherited and callerlaunchEnv, so untrusted overrides cannot redirect registry access.defaultDaemonSupervisorRegistryDiris renamed/exported asgetDaemonSupervisorRegistryDirwith the env constant exported for tests and spawn wiring.Tests assert both initial and relaunched workers receive the supervisor’s registry path and that
launchEnvcannot smuggle a different directory.Reviewed by Cursor Bugbot for commit 240b454. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Preserve daemon supervisor registry authority across recovered workers
DAEMON_SUPERVISOR_REGISTRY_DIR_ENVand renamesdefaultDaemonSupervisorRegistryDirtogetDaemonSupervisorRegistryDirin daemon-supervisor-ownership.ts so other modules can resolve the registry directory consistently.DaemonSupervisornow captures a singlesupervisorRegistryDirat startup and passes it explicitly to fencing and ownership calls, preventing drift between restarts.DAEMON_SUPERVISOR_REGISTRY_DIR_ENVinto the worker environment after merging all other env vars, so a caller-supplied value cannot override the supervisor's registry directory.Macroscope summarized 240b454.