Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and the API is not frozen — breaking changes are possible between minor versio
This file supersedes the earlier `IMPROVEMENTS.md` and `REVIEW.md` snapshots,
whose still-accurate content has been folded in below.

## [Unreleased] — v0.3.0-decay
## [v0.3.0] — 2026-09-21

### Added
- **Decay layer** (`SynapseWeightState`): per-synapse decay math, rot scoring,
Expand All @@ -26,7 +26,15 @@ whose still-accurate content has been folded in below.
bidirectional prediction-error propagation, earned lighthouse floor, and the
`FaultInjectionSuite` calibration harness. (#12)

- Session coordinator (`SynapseManager`), persistent session state, circuit
observation passes, and RSA epoch rendering (`--rsa`).
- On-device opt-in `FoundationModelsClient` and local provenance/benchmark records.
- Typed run-log decay snapshots, persisted lighthouse migration and breadcrumbs,
dedicated `referee.json`, and the append-only observation ledger/CLI.

### Fixed
- Bounded prior evidence growth, GUI persistence error surface, and stderr drift
telemetry. See ADR-005 for the GUI verification perimeter.
- CLI export prints a `Successfully exported state to: <file>` confirmation again,
restoring symmetry with import and fixing the
`testExportAndImportAcceptUserFlagBeforeCommandFlag` integration test. (#14)
Expand Down Expand Up @@ -57,3 +65,5 @@ whose still-accurate content has been folded in below.
rather than failing silently.

[Unreleased]: https://github.com/mazze93/context-synapse/commits/main

[v0.3.0]: https://github.com/mazze93/context-synapse/releases/tag/v0.3.0
11 changes: 6 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Not a consumer product — built by and for a neurodivergent developer exploring
## CURRENT STATE — START HERE

**Version:** v0.3 bedrock layer is **merged to `main`** (PR #12: SynapticCircuit
actor, CircuitTypes, FaultInjectionSuite, ADRs). Latest release tag is still
`v0.1.0` — no v0.3 tag has been cut. Docs rewrite (PR #11) and CodeRabbit test
actor, CircuitTypes, FaultInjectionSuite, ADRs). Latest release tag is
`v0.3.0` (2026-09-21), including session persistence, on-device AI, and the
instrument ledger; v0.4 remains partially shipped. Docs rewrite (PR #11) and CodeRabbit test
generation (PR #13, added `Tests/SynapticCircuitTests.swift`) are also merged.
**Branch model:** all work on feature branches, PRs against `main`.

Expand Down Expand Up @@ -138,8 +139,8 @@ Key methods on `SynapseCore`:

### Layer 2: Decay & Rot (`SynapseWeightState.swift`)

Per-synapse mutable weight state. Currently instantiated **per-query** in the CLI.
`SynapseManager` (v0.4 target) will own session-level persistence.
Per-synapse mutable weight state. The CLI computes per-query display state; `SynapseManager` also persists
session-level synapse snapshots and RSA epochs in `session.json`.

Core math:
```
Expand Down Expand Up @@ -259,7 +260,7 @@ a lighthouse is loaded.
Surfaced and fixed: `@Sendable` on AIClient closures, per-call
`StandardErrorStream` instead of a shared mutable global.

### P1 — v0.3.0 remaining items — ALL DONE (branch `claude/v0.3-ci-repair-and-p1`)
### P1 — v0.3.0 acceptance items — ALL DONE on main

- [x] **`Tests/DecayWeightTests.swift`** — floor invariant, cauterization
threshold, decay monotonicity (+ lighthouse-never-rots, connectivity slows
Expand Down
37 changes: 21 additions & 16 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Architecture decisions live in [`docs/adr/`](docs/adr/) — start with the

---

## v0.3.0 — Decay Layer 🔧 IN PROGRESS
## v0.3.0 — Decay Layer ✅ RELEASED (2026-09-21)

### Shipped this sprint
- [x] `InteractionRecord.swift` — timestamped event classification + `successWeight` mapping; also houses `SynapseContent` and the `DecayConstants` single source of truth
Expand All @@ -42,22 +42,27 @@ Architecture decisions live in [`docs/adr/`](docs/adr/) — start with the
- [x] `Circuit/` + `FaultInjection/` — `SynapticCircuit` bedrock layer, Beta priors, fault-injection suite (#12)
- [x] Architecture decisions recorded — see the [ADR index](docs/adr/README.md)

### Remaining v0.3.0
- [ ] Unit tests: decay convergence, lighthouse floor invariant (never below 0.4), cauterization threshold (triggers at RotScore ≥ 0.82)
- [ ] Extend `RunLog` schema with: decay snapshot, rot score, lighthouse saliency, Referee mode, intervention flag
- [ ] Breadcrumb file writer: on session resume, emit lighthouse re-sync line immediately
- [ ] `RefereeConfig` round-trip: load/save from `default_config.json`
### Completed v0.3.0 acceptance items
- [x] Unit tests: decay convergence, lighthouse floor invariant (never below 0.4), cauterization threshold (triggers at RotScore ≥ 0.82)
- [x] Extend `RunLog` schema with: decay snapshot, rot score, lighthouse saliency, Referee mode, intervention flag
- [x] Breadcrumb file writer: on session resume, emit lighthouse re-sync line immediately
- [x] `RefereeConfig` round-trip: load/save in dedicated `referee.json` (avoids config overwrite)

---

## v0.4.0 — Rot Layer + Lighthouse

- [ ] `SynapseManager.swift` — coordinates session state, lighthouse designation, shadow context forking
- [ ] Lighthouse designation at session start (explicit or inferred from first high-utility interaction)
- [ ] Lighthouse re-sync UI message: `⚓ Lighthouse: [description] — saliency [X]% — last touched [N]min ago`
Partially shipped in the v0.3.0 tag. No v0.4.0 release tag exists yet.
The read-only session-diff CLI shipped on main in #52 (untagged). Next:
explicit Shadow Context forks and promotion with anchor-specific histories (#53). The manager does
not yet apply `cauterizedDecayConstant`; keep that integration open.

- [x] `SynapseManager.swift` — persisted session synapses, explicit lighthouse binding, circuit passes, and RSA epochs (included in v0.3.0; shadow forks remain below)
- [x] Explicit lighthouse designation with `--lighthouse`; inferred anchors are excluded by ADR-001
- [x] CLI lighthouse re-sync breadcrumb (SwiftUI integration remains separate): `⚓ Lighthouse: [description] — saliency [X]% — last touched [N]min ago`
- [ ] Shadow Context fork mechanism (side-quest sandbox, breadcrumb trail)
- [ ] Async affect vector integration (ADR-001): cursor scanpath, scroll cadence, webcam pupil proxies
- [ ] Session diff CLI command: compare two run logs across decay/rot/lighthouse trajectories
- Removed: cursor/scroll/webcam inference of operator state (Track A ADR-002 permanent boundary; opt-in does not override it)
- [x] Session diff CLI command: `--session-diff` compares two saved run logs' decay/rot/lighthouse snapshots (#52, on main, untagged; endpoints only, no reconstructed trajectory)
- [ ] `SynapseManager` integration: detect `requiresCauterization`, apply cauterized decay constant
- [ ] Lighthouse promotion workflow: explicit user choice to make side-quest the new primary

Expand All @@ -69,16 +74,16 @@ Architecture decisions live in [`docs/adr/`](docs/adr/) — start with the
- [ ] Context Intervention UI: surface `ContextIntervention.formattedMessage` with action buttons
- [ ] AbrasiveReferee cooldown persistence across sessions
- [ ] `shouldForkToShadowContext` wired to UI — dimmed Lighthouse indicator when side-quest active
- [ ] Async affect conditioning in trigger weight pipeline (ADR-001 full implementation)
- Explicit manual context choices only; operational/affective-state inference remains excluded (Track A ADR-001/002)
- [ ] TF-IDF distance strategy (`TFIDFCosineDistance` — Option B)

---

## v1.0.0 — Production

- [ ] Prior decay — exponential moving average for alpha/beta (fixes unbounded prior growth)
- [x] Bounded prior growth — mean-preserving evidence cap (200); EMA is not implemented or required for this fix
- [ ] File lock for write safety (single-writer assumption documented, needs enforcement)
- [ ] UI error surface for IO failures (known issue: silent write failures)
- [x] UI error surface for IO failures — save results, ViewModel error state, and banner (ADR-005)
- [ ] Full test harness
- [ ] README and contributor documentation (Show HN ready)
- [ ] arXiv preprint: *Intentional Fragility: Bayesian Context Decay and Semantic Rot in Local-First LLM Orchestration*
Expand All @@ -89,9 +94,9 @@ Architecture decisions live in [`docs/adr/`](docs/adr/) — start with the

| Issue | Severity | Status | Mitigation |
|---|---|---|---|
| Silent write failures | Medium | Open | Add UI error reporting, check AppSupport permissions on init |
| Silent write failures | Medium | Resolved | Bool-returning saves, ViewModel error state, SwiftUI banner; ADR-005 documents verification limits |
| Schema drift: key changes break region vectors | Medium | Open | Use `canonicalVector(for:)` to regenerate after schema changes |
| Unbounded prior growth | Low | Open | Add EMA decay to alpha/beta — target v1.0 |
| Unbounded prior growth | Low | Resolved | Mean-preserving cap on alpha + beta at 200 |
| Concurrency: multi-process write collision | Low | Open | Add file lock — single-writer assumption documented |
| `assemblePrompt` CLI wiring | High/Bug | ✅ Resolved | CLI calls `core.assemblePrompt(...)` correctly (`main.swift`) |
| No per-synapse decay tracking | High | ✅ Addressed | `SynapseWeightState` (v0.3) |
Expand Down
144 changes: 53 additions & 91 deletions docs/journal/CHECKPOINT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Checkpoint — resume here if the session drops
# Checkpoint — 2026-10-29

## Active — 2026-11-04: study v2 pre-registration (Phase A)

Expand All @@ -17,93 +17,55 @@ Deferred / needs-user:
- Local unpushed docs commits `81f9f14`, `c9a594f` (+ CHECKPOINT rewrite) sit off-main; untouched
- Stale conflicted bookmark `codex/jj-study-collector` (merged as #50); untouched

## Active — 2026-08-18: pivot from GitButler to jujutsu (jj)

Adopting jj for this repo after GitButler friction (raw commits were hook-
blocked; a stacked rebase wrote conflict markers that broke the build — see the
2026-07-22 salvage audit below). jj's first-class conflicts + `jj undo` + stable
change IDs + terminal-native model fit better. See DECISIONS 2026-08-18.

Done this session:
- [x] GitButler fully removed; jj 0.44.0 installed; global identity set
- [x] **Colocated** — `jj git init --colocate` ran; `.jj` + `.git` coexist, `trunk()` = main@origin
- [x] **Reclaim audit** — Fable lighthouse scene unrecoverable; all 4 branches carry 0 unique files vs main (proof in DECISIONS 2026-08-18)
- [x] **Journal made enforceable** — `scripts/ops/check_journal_append.sh` (guard, 4-case tested) + `docs/journal/archive/` + `LESSONS.md` + CI step + CLAUDE.md contract

Remaining / deferred:
- [ ] **Push + PR** the journal-enforceability work (branch `feat/journal-append-guard`) — awaiting your ok / review
- [ ] **Branch cleanup** — you didn't pick a scope; all 4 non-main branches verified content-free, deletion still your call (irreversible)
- [ ] **Edgar storm-flight rebuild** — brief captured in `docs/design/edgar-lighthouse-scene-brief.md`; build queued as focused next task

**Deferred/needs-user:** whether to colocate the rest of `~/Projects` (per-repo,
deliberate — not this session); keep `secure-pride/*` out of any experiment.

## 2026-07-22 — GitButler state discarded, repo realigned to origin/main

This repo is now on plain `main` @ `2b70c48`, clean, building, 216 tests green.
GitButler is fully removed here: no `gitbutler/*` refs, no `ml-branch-*`, no
`.git/gitbutler/`, no managed hooks. See DECISIONS.md 2026-07-22 for the
salvage audit that justified discarding the local branch (short version: it
contained zero unique code and was missing four files from merged PR #24).

**The section below is stale** — it describes the PR #22 sweep as in-progress.
PR #22 merged as `d25ace4` on 2026-07-18. Kept for history, not for resuming.

### Still open in this repo (not addressed 2026-07-22)
- **PR #20** (`chore/v0.3-cleanup-and-doc-sync`) is still open, with 22 commits
unpushed on the local branch. Untouched by the realignment.
- `claude/v0.3-ci-repair-and-p1` is ahead 1 / behind 1 of its remote.

## Active — 2026-07-18: known-issues cleanup sweep

**Branch:** `chore/known-issues-cleanup-v0.4` (off `main` @ `eab27fa`).
Read PLAN.md then DECISIONS.md, continue at first unchecked phase.

- [ ] **A. Scaffold** — journal + branch
- [x] **B. Unbounded prior growth** — renormalization cap + PriorGrowthTests (4 tests green)
- [x] **C. Silent GUI write failures** — Bool-returning saves + AppViewModel error surface + ContentView banner (full suite 198 green, CLI smoke ok, touchstone HELD)
- [x] **D. emitDriftEvent stdout** — injectable sink, stderr default (stdout confirmed clean; drift branch unreachable under shipped eta — noted in test perimeter)
- [x] **E. Multi-process write collision** — documented (README single-writer note + saveWeights doc comment); CLAUDE.md + README Known Issues tables updated for B–E; release build clean, full suite green, CLI smoke ok

## SHIPPED — 2026-07-21: on-device AI client + provenance (PR #24)

`FoundationModelsClient` (on-device, opt-in, macOS 26+ via canImport/@available
so macos-15 CI still builds) + generic `AIProvenanceRecord`/`AIBenchmarkReport`
(identity, provenance, repeatable benchmark). Records persist **on-device only**
(`SynapseCore.recordAIBenchmark` → Application Support); never stdout/CI/repo —
enforced by a portable containment test + `.gitignore`. **PR #24 MERGED**
(squash `4a1f65c`); all checks green (Analyze/Swift, Build+guardrails on
macos-15, CodeQL, Greptile). Proven end-to-end locally on M5 Pro / macOS 27:
real on-device round-trip + 3-iteration benchmark. See DECISIONS 2026-07-21.
Deferred: Core ML `LocalEmbeddingDistance`; bootstrap script (separate repo).

## SHIPPED — 2026-07-19

- [x] **F. Follow-up (post-review)** — Link 1 GUI-failure verification:
`baseOverride` seam + `PersistenceFailureTests` + ADR-005 (Links 2-3 deferred/
perimeter).
- **PR #22 MERGED** into `main` — squash merge commit `d25ace4` (mergedAt
2026-07-19T03:07Z). All required checks green on the merge: Analyze (Swift),
Build/test/guardrails, CodeQL, Greptile.
- Post-merge re-verification on `main` (2026-07-21): `swift build`,
`swift build -c release`, `swift test --parallel` (204 tests) all green; CLI
smoke ok; zero conflict markers on `origin/main` or on disk.
- **Cleanup:** a stale duplicate PR #23 (same head branch, re-pushed by
GitButler with unresolved conflict markers — Greptile 1/5, non-compiling) was
closed as superseded; the `chore/known-issues-cleanup-v0.4` branch was deleted
local + remote. All four known issues are resolved on `main`.

## Deferred limitations (documented, not gaps in shipped code)

- **GUI write-failure Links 2–3** (ADR-005): ViewModel→`lastError` reflection
test deferred until `AppViewModel` moves to a library target; SwiftUI banner
*render* is inherent perimeter (needs XCUITest). Link 1 (disk-I/O → `false`)
is verified.
- **Circuit drift branch:** `drift > 0.1` is unreachable via the public API
under shipped `etaBase = 0.1`; drift-sink firing is untested end-to-end by
design (no production behavior changed to force it).

## Historical (done, merged)

PR #20 merge task and the v0.3 CI-repair/P1 sprint are complete and on `main`
(`eab27fa`, `ac141f8`, `af16eab`). Detail in git history — do not reopen.
## Collection paused — 2026-10-29 correction

A controlled empty `jj commit` (`0fbe0004`) left the study ledger unchanged at
one event: Git post-commit hooks are bypassed. The CLI was absent from PATH too.
The LaunchAgent `com.contextsynapse.jj-collector` has been unloaded pending
agent/human attribution and a viable sampling plan. Both collector copies now
use `jj --ignore-working-copy log`; the dirty-working-copy probe confirmed no
new jj operation. Prior polling was a possible additional working-copy writer.
The first post-install jj event was verified in the existing ledger. The original
Git observer is preserved but inactive (non-executable) to prevent duplicates.

Installed runtime/state: `~/Library/Application Support/ContextSynapse/instrument/jj-collector/`.
Check `state/last-success` and `stderr.log`. Baseline excludes historical changes;
no backfill. One opted-in repo supplies one synapse. Varied outcomes and at least
five consented synapses are still needed to evaluate P1–P4.

The study clock is not restarted. The original window ended October 27;
DECISIONS records the pre-specified first seven-day extension through November 3
at 23:53:20 America/New_York. PR #50 now fills the protocol's own Extension 1 slot; hypotheses and thresholds
remain unchanged. The study is underpowered; further extensions are not automatic.

## Reviewable work

- #40: repaired compile failures earlier; now also preserves existing exact-owned
Default/DEFAULT user state. New revision `1153ae0a` passes local tests and GitHub
Build/test/guardrails. Merge is authorized only after review/checks pass; refresh
review and CodeQL state before merging. No merge has been claimed here.
App heartbeat `merge-context-synapse-40-after-review-passes` checks every
15 minutes and is authorized to merge only after those conditions pass.
- #50: collector repair plus correction `bedb18fb`: snapshot suppression in
source and pinned copy, collection paused, attribution confound recorded. Merged to main (`cf9e814`).
- #51: release/roadmap reconciliation, #44 close-proof entry, ethics correction,
and this checkpoint. v0.3.0 is released; v0.4 is partly shipped. No new tag cut.
- #52: read-only `--session-diff` for two saved RunLogs. Merged to main (`987dfe7`).
- #55: close study run 1 and pre-register run 2 (Phase A). Merged to main (`fc48f8c`).
- #53: draft explicit Shadow Context CLI fork/return/promotion, separate anchor
histories and atomic selection index; retained-shadow resume/list and SwiftUI
context selection remain deferred. No operator-state inference.

Local jj bookmark `codex/integration-validation` combines the five PRs for
verification without publishing or merging them to main. README and journal
append conflicts were resolved by preserving all additions. `swift build` and
the combined full suite pass: 236 tests, zero failures. Real-jj collector tests
also pass: repeated polls, rewrites, failure retries, interrupted checkpoint.

## Next steps

Refresh #40 checks/review and merge only when its condition is satisfied. Then
rebase the other PR bookmarks with jj onto updated main; journal additions must
be preserved when resolving append conflicts. Review #50/#51/#52 and draft #53
separately. Remaining v0.4 includes cauterized-decay integration, full trajectory
analysis, and the deferred Shadow/SwiftUI surfaces; completion is not claimed.
Loading
Loading