Skip to content

feat(circuit): SynapticCircuit bedrock layer (v0.3) — Beta prior, prediction-error propagation, earned lighthouse floor#12

Merged
mazze93 merged 4 commits into
mainfrom
claude/circuit-bedrock-v0.3
May 29, 2026
Merged

feat(circuit): SynapticCircuit bedrock layer (v0.3) — Beta prior, prediction-error propagation, earned lighthouse floor#12
mazze93 merged 4 commits into
mainfrom
claude/circuit-bedrock-v0.3

Conversation

@mazze93

@mazze93 mazze93 commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces the static W_base(s) constant in the decay formula with a mutable Beta-distributed prior, and introduces the bidirectional prediction-error propagation substrate the v0.3 decay layer was missing.

  • Sources/SynapseCore/Circuit/CircuitTypes.swiftPrior, SynapticNode, CircuitEdge, CircuitConstants, plus all Sendable output value types (ForwardPassResult, BackwardPassResult, CircuitSnapshot, FaultInjectionReport, CalibrationReport).
  • Sources/SynapseCore/Circuit/SynapticCircuit.swift — Swift actor with forward/backward pass, connectivity cache, dynamic lighthouse floor, snapshot-first fault injection. Ordering enforced internally via lastForwardPassNumber.
  • Sources/SynapseCore/FaultInjection/FaultInjectionSuite.swift — calibration suite producing empirical recommendations for ROT_LAMBDA_AMPLIFIER and ROT_CAUTERIZE_THRESHOLD.

Architecture Decision Records

  • ADR-002W_base(s) → mutable Beta prior. connectivity_factor(s) derived from edge topology. Prediction error becomes a first-class learning signal.
  • ADR-003 — Lighthouse floor = prior.mean × 0.4. The floor is earned, not granted. Lighthouse misdesignation becomes self-correcting.
  • ADR-004 — Prediction error joins λ(s, t) as a dynamic decay amplifier alongside (not replacing) rot scoring. Two orthogonal failure modes captured independently.

Full ADRs in docs/adr/. Integration guide for SynapseWeightState consumption in docs/adr/INTEGRATION.md.

Scope discipline

No existing files modified. SynapseCore.swift, SynapseWeightState.swift, RavenRenderer.swift, the CLI, the SwiftUI app — all untouched. This PR is bedrock only; the consumer-side wiring (replacing W_base in SynapseWeightState.decayWeight) is the next PR.

Known threats (MAESTRO)

Documented in ADR-002 risk table:

Threat Mitigation
T1 — prior poisoning Learning rate decay; evidence weight cap (100)
T2 — error flooding Minimum α floor (1.0); backward-pass ordering guard
T3 — lighthouse ossification Dynamic floor (ADR-003) + FaultInjectionSuite.auditLighthouses
T4 — timing side-channel Actor isolation; no internal scheduling
T5 — schema drift schemaVersionHash in CircuitSnapshot

Out of scope for this PR

  • SynapseWeightState integration — separate PR, integration recipe in docs/adr/INTEGRATION.md
  • SynapseManager backward-pass wiring — v0.4
  • Persistence of CircuitSnapshot to disk — needed before v1.0; not blocking the bedrock
  • Package.swift bump to swift-tools-version:6.0 for strict concurrency — recommended follow-up, code is already actor-isolated and Sendable-compliant

Test plan

  • CI build passes on macos-15 (Swift 5.8+ toolchain)
  • Existing BayesianConvergenceTests continue to pass (no changes to consumed surfaces)
  • Manual: instantiate SynapticCircuit, register a few nodes, run forwardPass()backwardPass(observations:) → confirm BackwardPassResult.predictionErrors reflects |predicted − observed|
  • Manual: run FaultInjectionSuite.runFullSuite() against a small circuit and confirm CalibrationReport.formattedSummary produces a sensible recommendation

Bedrock unit tests will follow in a separate PR — keeping this one to net-new files and zero modifications for review clarity.

https://claude.ai/code/session_0193B19zr8PsbvJMphKxufw4


Generated by Claude Code

Replaces static W_base(s) constant with mutable Beta-distributed prior.
Implements bidirectional prediction-error propagation substrate.

- CircuitTypes.swift: Prior, SynapticNode, CircuitEdge, CircuitConstants,
  ForwardPassResult, BackwardPassResult, CircuitSnapshot, FaultInjectionReport,
  CalibrationReport
- SynapticCircuit.swift: actor with forward/backward pass, connectivity cache,
  dynamic lighthouse floor, fault injection (snapshot-first)
- FaultInjectionSuite.swift: calibration suite producing CalibrationReport

ADR-002: W_base -> mutable Beta prior + circuit topology for connectivity_factor
ADR-003: lighthouse floor = prior.mean * 0.4 (earned, not granted)
ADR-004: prediction error added as dynamic decay amplifier in lambda(s)

No existing files modified. SynapseWeightState integration: see docs/adr/INTEGRATION.md.

MAESTRO threats documented: T1 (prior poisoning), T2 (error flooding),
T3 (lighthouse ossification), T4 (timing side-channel), T5 (schema drift).

https://claude.ai/code/session_0193B19zr8PsbvJMphKxufw4
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (8)
  • CLAUDE.md is excluded by none and included by none
  • Sources/ContextSynapseApp/RegionModel.swift is excluded by none and included by none
  • Sources/SynapseCore/Circuit/CircuitTypes.swift is excluded by none and included by none
  • Sources/SynapseCore/Circuit/SynapticCircuit.swift is excluded by none and included by none
  • Sources/SynapseCore/FaultInjection/FaultInjectionSuite.swift is excluded by none and included by none
  • docs/adr/ADR-002-bidirectional-prediction-error-propagation.md is excluded by none and included by none
  • docs/adr/ADR-003-004-lighthouse-floor-and-decay-amplifier.md is excluded by none and included by none
  • docs/adr/INTEGRATION.md is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fc248a7b-9ffd-475e-b05d-bae5ded05b74

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)

❌ Error creating Unit Test PR.

  • Create PR with unit tests
  • Commit unit tests in branch claude/circuit-bedrock-v0.3

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@mazze93 mazze93 marked this pull request as ready for review May 29, 2026 05:24
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

✅ Created PR with unit tests: #13

claude added 3 commits May 29, 2026 05:32
…dule conflict

SynapseCore.swift:183 defines `public struct Prior` (simple Beta wrapper,
serialized to disk). CircuitTypes.swift originally defined a second `public
struct Prior` (the richer SynapticPrior). Both land in the SynapseCore module
— duplicate type definition, build failure.

Fix: rename the circuit-layer type to SynapticPrior throughout CircuitTypes.swift.
SynapseCore.Prior is untouched — it is part of the on-disk config.json schema.

Also update CLAUDE.md with full architecture map, PR status, sprint backlog,
and known issues from the current session.

https://claude.ai/code/session_0193B19zr8PsbvJMphKxufw4
Mutating `nodes[id] = node` while the for-in loop iterates over `nodes`
triggers a Law of Exclusivity violation in debug mode (simultaneous read
and write access to the same dictionary). Fix by taking a value-type
snapshot before the loop; writes go to the live `nodes` dict as before,
but the iterator walks the immutable snapshot.

https://claude.ai/code/session_0193B19zr8PsbvJMphKxufw4
…lVector

RegionModel.swift (ContextSynapseApp) re-declared public func
canonicalVector(for:scale:) as an extension on SynapseCore while the
identical method already exists inside the SynapseCore class body at
SynapseCore.swift:579. Swift produces an invalid redeclaration error
when building ContextSynapseApp, causing swift build -c release to fail
for every PR branched from main — the systemic CI failure.

The method is never called from ContextSynapseApp; the canonical
definition in SynapseCore.swift is unaffected.

https://claude.ai/code/session_0193B19zr8PsbvJMphKxufw4
@mazze93 mazze93 merged commit 545c23a into main May 29, 2026
3 of 5 checks passed
@mazze93 mazze93 deleted the claude/circuit-bedrock-v0.3 branch May 29, 2026 07:54
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

No files have been changed in this PR. Unable to generate unit tests.

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