Skip to content

feat(context): explicit shadow forks, return, and promotion - #53

Merged
mazze93 merged 6 commits into
mainfrom
codex/shadow-contexts
Nov 9, 2026
Merged

mazze93 merged 6 commits into
mainfrom
codex/shadow-contexts

Conversation

@mazze93

@mazze93 mazze93 commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

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 build and 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 new ShadowContextStore and an atomic contexts.json index that points each context at its own lighthouse.json and session.json while 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 records contextID / shadowContext on 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.

@mazze93
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>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

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.

mazze93 and others added 2 commits November 9, 2026 20:42
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>
@mazze93
mazze93 merged commit afe4293 into main Nov 9, 2026
4 checks passed
@mazze93
mazze93 deleted the codex/shadow-contexts branch November 9, 2026 20:59
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.

2 participants