Repository navigation
feat(context): explicit shadow forks, return, and promotion - #53
Merged
Merged
Conversation
Signed-off-by: Mazze LeCzzare Frazer <mazze@mazzeleczzare.com>
mazze93
marked this pull request as ready for review
November 1, 2026 10:17
# Conflicts: # README.md # Sources/contextsynapse/main.swift # docs/journal/DECISIONS.md
Resolve DECISIONS append-only conflict (main entries first). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because on-demand usage is turned off. To enable Bugbot Autofix, turn on on-demand usage and set a spend limit in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bf2bdfc. Configure here.
ShadowContextStore probed the active shadow's lighthouse and session in init, and the CLI built the store before dispatching --return-primary, so a missing or malformed shadow file blocked the documented way out. The return path now skips that probe; the index is still validated and every other path still fails closed. Regression tests cover a missing anchor, a malformed session and a corrupt index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Add explicit CLI commands to fork a Shadow Context, return to the primary, or promote the active shadow. Each fork gets its own lighthouse and session/RSA history, selected by an atomically written index; original primary files and earlier primary IDs are retained.
Commands require an explicit user choice. Shadow queries print a return breadcrumb and RunLogs record the context ID. Weights/referee settings remain shared. Instrument commands bypass context selection so a corrupt context index cannot stop observation collection.
This CLI increment does not add nested forks, retained-shadow resume/list UI, or SwiftUI context selection. These limits and recovery behavior are documented in README.md.
Validated with five tests covering actual CLI fork/query/return/promotion, independent persisted histories, promoted-primary reanchoring, restart selection, invalid inputs, corrupt indexes, and failed pointer persistence.
swift buildand the full suite pass (221 tests, zero failures). No operator-state inference, network collection, or study outcome analysis.Note
Medium Risk
Changes CLI persistence and session selection paths; corrupt or partial index writes can block context use, though design is fail-closed with tests for rollback and isolation.
Overview
Adds CLI shadow contexts:
--fork-shadow <goal>,--return-primary, and--promote-shadow, backed by newShadowContextStoreand an atomiccontexts.jsonindex that points each context at its ownlighthouse.jsonandsession.jsonwhile keeping prior primary files on disk.The CLI now runs instrument verbs (
--record,--export-events,--events-summary) before loading the context index, rejects mixed instrument/state flag combinations, routes lighthouse/RSA/query work through the selected context with caught load/save errors, prints a shadow return breadcrumb, and recordscontextID/shadowContexton run logs. Docs and five new tests cover usage, corrupt-index fail-closed behavior, independent histories, and end-to-end CLI flows.Reviewed by Cursor Bugbot for commit bf2bdfc. Configure here.