Skip to content

[WIP] Plan TraceDecay V2 brain rewrite#421

Draft
ScriptedAlchemy wants to merge 747 commits into
masterfrom
codex/tracedecay-total-redesign-plan
Draft

[WIP] Plan TraceDecay V2 brain rewrite#421
ScriptedAlchemy wants to merge 747 commits into
masterfrom
codex/tracedecay-total-redesign-plan

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Jul 10, 2026

Copy link
Copy Markdown
Owner

WIP: plan only

This PR contains only the TraceDecay V2 total-rewrite design: one master plan, one plan-set index, and 28 linked subsystem/crate/product plans (30 documentation files). It deliberately contains no implementation.

Unified product and architecture

  • Rebuild TraceDecay as one coherent profile-wide brain across projects, repositories, worktrees, branches, threads, turns, agents, workflows, tools, artifacts, code, Git, facts, memories, tasks, plans, delivery, and time.
  • Make an immutable sanitized observation/event stream the write authority; derive versioned projections, graph/read models, search indexes, analytics, hints, and UI views through fenced replayable projectors with checkpoints, dead letters, repair, and provenance.
  • Replace ambiguous project-only identity and split stores with canonical profile/project/repository/worktree/session/message/agent/task/artifact/code identities, explicit source bindings, temporal validity, variant safety, and protected consolidation/quarantine workflows.
  • Define crate ownership, dependency/release DAGs, anti-corruption boundaries, migration/deletion gates, negative-code budgets, and shared kernels so the rewrite converges instead of recreating fragmented subsystems.

Multi-machine shared Brain

  • Adds plan 28 for local-only, remote-authority, cached-client, read-replica, standby, and hybrid-placement operation under one BrainId.
  • Keeps every SQLite/WAL family host-local. Remote nodes exchange sanitized observations, signed snapshots/tails, immutable packs, and typed commands through the authenticated application/API contract; no network-mounted database or database URL is exposed.
  • Correlates equivalent clones across machines through credential-free Git remote evidence plus verified object/commit/tree/ancestry evidence. Paths and worktrees stay node-scoped; forks, shallow/rewritten histories, and contradictions remain explicit candidates.
  • Uses exactly one writable authority per mutable shard, signed/expiring node and cache grants, bounded causal frontiers, authority/placement epochs, offline idempotent capture, visible lag/pending/conflict state, and positive external fencing before standby promotion.
  • Makes Tailscale an optional connectivity profile only. Ordinary authenticated HTTPS/mTLS, LAN/VPN, reverse proxy, or tunnel deployments use the same TraceDecay identity, authorization, privacy, revocation, and fencing rules.
  • Adds wrapped-key disaster recovery after total authority-node/keyring loss, explicit remote schemas/retention, node/store/repository topology UI, Sync Observatory, Brain Settings, CLI/API/SDK bindings, compact default MCP status, operator-only MCP administration, and multi-machine fault/RPO/RTO gates.

Product surfaces and task execution

  • Replace the project-only dashboard with an All / Brain workspace plus scoped lenses; interactive Git, code, thread, turn, agent, task, plan, memory, impact, and timeline graphs; reasoning/code/artifact lineage; synchronized explorers; and accessible table/outline parity.
  • Add hermetic replay/debug labs for search, LCM, facts/memory, hooks, hints, context scouting, redaction, curation, automation, scheduling, configuration, and experiments with current-versus-historical policy comparisons and reproducible receipts.
  • Port and redesign the Hermes Kanban concept as a native TraceDecay task/plan graph—not an adapter—with federated initiatives/boards, DAG dependencies, multi-project work bundles, model/effort routing, executor/provider capabilities, offers/admission, leases, grants, work packets, nearby-agent awareness, and duplicate/conflict prevention.
  • Add validated sharded frontmatter/CommonMark task-graph edit workspaces for large agent edits, authoritative validate/diff/rebase/submit flows, safe temporary cleanup, exact candidate refs, and atomic owner-shard publication.

Search, hints, automation, APIs, CLI, and MCP

  • Redesign hybrid lexical/vector/graph/temporal retrieval, supersession-aware ranking, contextual retrieval IDs, cross-project scope, explainability, qrels/judgments, real-session replay evaluation, and precision/recall promotion gates.
  • Make adaptive hint arbitration and optional incremental model-backed context scouting compact, material, deduplicated, privacy-safe, nearby-work aware, and measurable against useful-silence baselines.
  • Make autonomous memory/skill curation and self-improvement event-driven and frontier-fenced: unchanged/no-activity inputs create no repeated runs or model/tool work.
  • Publish one typed application contract through an official HTTP API, Rust/TypeScript/Python SDKs, CLI, optional MCP, dashboard, hooks, and executors; centralize typed views, Markdown/JSON rendering, errors, pagination, and capability discovery.
  • Split MCP into independently installable context/work/operator trust-boundary registrations backed by one binary/daemon/catalog. Skills plus CLI remain the complete MCP-free baseline; eager clients must pass the same security/context budgets as deferred clients.

Claude Code, Codex, and Cursor bundles

  • Adds plan 27 with primary-source research for official Claude Code, Codex, and Cursor plugin, skill, command, agent/subagent, hook, MCP, configuration, marketplace, permission, and progressive-disclosure behavior.
  • Keeps one canonical HostIntegrationManifestV1; PR 22A owns its catalog/source IR, PR 22I deterministically emits unsigned HostBundlePayloadV1 trees, PR 36R independently rebuilds/scans/conformance-tests/attests/signs HostBundleManifestV1, and application alone binds a signed release to current host capability state.
  • Uses host capability evidence and stock-host conformance instead of assuming cross-host parity. Unsupported/version-gated behavior gets an explicit omission and skill/CLI/API fallback.
  • Ships a small skills-first core plus optional least-privilege MCP companions; commands remain thin compatibility/explicit-user affordances, hooks remain bounded, and specialist roles receive exact task/scope/worktree/retrieval-anchor handoffs.

Privacy and control plane

  • Add ingest/retrieval/export/presentation secret detection and redaction with policy versions, sensitivity labels, grants, audit receipts, protected quarantine, leak-regression tests, and UI/CLI controls.
  • Put configuration—including redaction, retention, providers/models, hints, hooks, search, automation, executors, task routing, host integrations, shared-Brain placement/sync/cache/failover, and sharing—in one versioned control plane available through UI, CLI, API, and optional MCP.
  • Preserve fully autonomous curation semantics; there is no generic preview/apply/rollback proposal queue.

Accepted-base reconciliation and evidence

  • Current with master at 273f50c0372f063b97f4755563a3ded65ef324d5 (chore: release v0.0.53 (#437)); branch is not behind.
  • Incorporates accepted changes through fix(doctor): isolate registry diff conflicts #440, including fix(storage): add explicit split-store consolidation #425 split-store consolidation and fix(doctor): derive orphan stores from registry reconstruction #439/fix(doctor): isolate registry diff conflicts #440 registry-reconstruction truth/conflict isolation. At publication, this draft [WIP] Plan TraceDecay V2 brain rewrite #421 is the only open PR.
  • Planning used TraceDecay LCM/session/message/fact/code/Git/analytics/diagnostic/automation surfaces, supported CLI/provider-local fallbacks when context tools failed, several independent subagent audits, Hermes source analysis, and primary-source/web/arXiv research.
  • Private chronological exports remain outside Git under /fast/tracedecay-redesign-research (0700; files 0600): 34,352 secret-scanned role-user records and a 9,988-record best-effort human subset through 2026-07-11T01:04:10.875Z.
  • Retained sanitized-content SHA-256: broad 0c56ebd9c54edfc76cda10b62de05e0a9443004c3ddce960daf300208bbdf340; human 942f6662c77f820c4d8a2b7063889c4521cecee68bc0258c7c7c12ddc6309dc2.
  • No transcript, database, generated fixture, or private research artifact is committed or indexed by this PR.

Validation

  • 30/30 intended documentation files and no other changed paths.
  • Internal relative links valid; Markdown fences balanced; git diff --check clean.
  • Failure modes FM-001 through FM-137 contiguous and unique.
  • Cross-plan type owners, signed sync/cache contracts, positive failover fencing, recovery keys, physical schemas, PR sequencing, closed Brain operation bindings, host compiler/signing/runtime boundaries, task-edit ceilings, configuration targets, and integration operations reconciled by independent final audits.
  • Corpus ordering, deduplication, timestamps, content hashes, permissions, and redacted-copy equality validated.
  • Direct plan scan, private-corpus scans, and staged-diff scan pass with gitleaks and zero findings.

Draft/WIP remains intentional until the plan is reviewed as one flowing architecture.

@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2b2572e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy ScriptedAlchemy added the WIP Work in progress; do not merge label Jul 10, 2026
@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/tracedecay-total-redesign-plan branch from e50f8f5 to 4f5ab66 Compare July 10, 2026 05:54
@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 986f25cca6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/plans/2026-07-09-tracedecay-brain-rewrite.md Outdated
@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/tracedecay-total-redesign-plan branch 4 times, most recently from 5862bd6 to 53502de Compare July 11, 2026 16:52
ScriptedAlchemy and others added 21 commits July 19, 2026 08:05
Close the unbalanced WHEN predicate and bind receipt source_through to the
batch committed endpoint so non-empty multi-batch progress can persist.

(cherry picked from commit 0dc4954)
Preserve the in-place dashboard, MCP catalog, memory-store, Hermes migration, session-ingest, test-suite, and temporal integration work before merging the PR8 aggregate.
Integrate the PR8 temporal kernel, refresh lifecycle, compatibility authority, migration, runtime hardening, benchmark harness, and verification fixes into the V2 rewrite branch.
Resolve canonical observation payloads before legacy rows and preserve fail-closed authorization states for cross-root hydration.
Use canonical payload authority in hydration fixtures and remove disallowed query-kernel clippy exceptions while preserving deterministic error handling.
Normalize microsecond source timestamps once at the message persistence boundary so expanded LCM lineage retains the seconds-based compatibility contract.
Treat allowlisted lint paths as attribute syntax so unresolved code paths remain guarded.
Ensure fresh benchmark databases bind a production-generated signed key before temporal snapshots and retain attested Linux run evidence as provisional.
ScriptedAlchemy and others added 13 commits July 23, 2026 05:42
Extend the existing direct-evaluation-record-v1.json with a
pr10_semantic_vector_evaluation section (described by feature/surface and
date, not by commit hash; all results kept in the one record file). It
captures the executed offline test suites for the PR10 semantic/vector path
(vector generation, FastEmbed local-artifact runtime, fusion/calibration, and
PR9 semantic-abstention fallback): 153 tests across 6 binaries pass, 0 fail,
with no network or downloaded model runtime. It also records the default
all-profile generate-candidates CLI run through the CompositionKernel::compose
production boundary (6 train/validation outputs; semantic lane returns the
byte-identical PR9 fallback offline). Same honest style as the PR9 flow: no
receipts, gates, or invented thresholds; real-model benchmarks and any
accept/reject outcome remain pending on a locked-quality run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The parity lane added SessionStoreRow/Cursor/Table::SourceCursors. The
exhaustive (wildcard-free) shape matches require every new protocol
variant to be listed, so add the SourceCursors arms to
session_store_row_matches, session_store_row_digest, and
session_store_cursor_matches, plus a positive test case.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
install_mcp_server previously assigned config["lsp"]["tracedecay"] via
serde_json indexing, which panics when the existing OpenCode config sets
`lsp` to a boolean (e.g. `lsp: true`). Merge mcp/lsp entries through
as_object_mut with explicit Config errors instead, converting `lsp: true`
to an object map that retains built-in servers, and skipping injection
when `lsp: false`. Adds a regression test covering the `lsp: true` case.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Daemon operations (notably `tracedecay branch gc`) failed with
"configuration authority unavailable: no pinned resolved snapshot for
project <id>" for registered projects that plainly exist. The fail-closed
`runtime_configuration_for_layout` lookup — correct for hook paths that must
never invent authority — was also on the daemon branch-admin path, so any
project not yet opened in this process (first operation, or the first after a
daemon restart) was rejected even though the daemon owns the durable store.

Add `resolve_runtime_configuration_for_layout`: the daemon authority path
resolves the durable current revision read-only and pins it on demand when the
process-local cache is cold, falling through to the existing read-only loader.
Route branch administration through it. A genuinely uninitialized or unopenable
store still yields a typed error; no legacy config input is consulted and the
store is never mutated.

Also fix the sibling lifecycle gap surfaced by moved, consolidated projects:
open_runtime_configuration_for_layout_read_only hard-errored ("configuration
store has no current revision") when a durable store exists but its
configuration authority was never migrated in (e.g. a consolidated destination
reopened read-only after a repository move). Guard store.current() with the
store's own is_uninitialized() contract and degrade to the registry-default
read-only snapshot in that state, exactly as the never-writable-store branch
already does. A non-empty store with an unreadable current revision is not
uninitialized and still surfaces a typed error, so durable authority is never
silently replaced.

Tests: registered project with a cold cache gets pinned on first daemon
authority access and the fail-closed lookup then reads it; an unresolvable
layout still errors typed; a schema-initialized but unseeded store serves the
registry-default read-only snapshot instead of erroring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adopt the in-flight source_cursors (Observation family) extension and add
the new Fact session-store family: memory_v2_facts, memory_v2_current_facts,
memory_v2_assertions, memory_v2_lineage_events, and retrieval_anchors (the
highest-usage previously unproven table). Adds table specs, full-column
keyset page queries, canonical row decoding, cursor round-trips and
validation, seeded fixtures in the unit and subprocess harnesses, exact
canonical-digest oracles (source_cursors, retrieval_anchors), and two-page
pagination walks for every new table. Keysets mirror each table's primary
key; fixtures keep faithful column sets/order and omit CHECK/FK clauses per
the harness convention.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add the Diagnostics session-store family: generation_diagnostics and
diagnostic_generation_publications, mirroring src/diagnostics_store.rs DDL
(faithful column set/order, primary keys, CHECK/index clauses omitted per
harness convention). Adds table specs, full-column keyset page queries,
canonical row decoding, cursor round-trips and validation, seeded fixtures
in both harnesses, two-page pagination walks for both tables, and an exact
canonical-digest oracle for diagnostic_generation_publications.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add the Configuration session-store family: configuration_revisions,
configuration_entries, configuration_mutation_receipts, and
configuration_audit_events, mirroring src/global_db/configuration/schema.rs
DDL (faithful column set/order and primary keys; CHECK/FK clauses omitted
per harness convention). Adds table specs, full-column keyset page queries,
canonical row decoding, cursor round-trips and validation, seeded fixtures
in both harnesses, two-page pagination walks for all four tables, and an
exact canonical-digest oracle for configuration_revisions covering a NULL
parent revision.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Plan 38 §3 final clause: superseded/deleted anchor dispositions release the
storage of the append-only observation evidence stores (observations 1.8 GB,
retrieval_anchors 1.6 GB, observation_repository_provenance 1.4 GB in one
dogfood sessions.db).

Mirrors the sibling LCM retention slice: bounded three-pass engine, DryRun/
Apply, before/after reclaim metrics, inert-by-default config (all windows
None), typed entry point plus a reported (unwired) GlobalDb daemon seam.

The disposition ledger is the governing authority: only anchors whose current
(max-sequence) disposition is superseded or deleted are acted on; active and
unavailable evidence is never released (plan non-goal encoded in SQL). The
compact ledger, its lineage, and every foreign key are preserved intact and
their immutability triggers respected; storage is reclaimed by releasing the
fat payload columns in place (anchor_json/observation_json/availability_json/
capture_json rewritten to a compact tombstone marker) under generation-scoped,
windowed, batched passes. Re-runs are idempotent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The parity lane added the MemoryV2Facts, MemoryV2CurrentFacts,
MemoryV2Assertions, MemoryV2LineageEvents, and RetrievalAnchors
protocol variants. Extend the exhaustive (wildcard-free) session store
shape matches (row/cursor expected-table derivation and row_digest
extraction) plus positive test cases so the crate keeps compiling.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Backfill the session_assertions two-page composite-keyset walk with an
exact canonical-digest oracle (closing the count-only gap flagged in
review) by seeding a second assertion fixture row, and extract the
session-table DDL previously duplicated verbatim between the unit and
subprocess fixture builders into one shared crate const
(SESSION_STORE_FIXTURE_TABLES_DDL) so the closed-table schemas cannot
drift apart. The observations table stays harness-local because its
foreign-key clause differs between the two fixtures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Revert the manual 0.0.67 bump (the release drift guard requires the
tree to match crates.io until release-plz recreates the bump) and mark
the semver-checks job release-type=major for the intentional V2 break.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/tracedecay-total-redesign-plan branch from 6b032ca to 51a54a8 Compare July 23, 2026 06:11
ScriptedAlchemy and others added 2 commits July 23, 2026 06:18
Project open must not fail when the root has no git repository; the
code index has no identity there by design. Also switch semver-checks
release-type to major (its vocabulary for a breaking release; the
shipped bump remains the planned 0.x minor).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Final parity-lane sync: add the GenerationDiagnostics,
DiagnosticGenerationPublications, ConfigurationRevisions,
ConfigurationEntries, ConfigurationMutationReceipts, and
ConfigurationAuditEvents variants to the exhaustive (wildcard-free)
session store shape matches and row_digest extraction, plus positive
test cases. Unblocks the package test binary link for the fleet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the codex/tracedecay-total-redesign-plan branch from cccd508 to d6b7a55 Compare July 23, 2026 06:25
ScriptedAlchemy and others added 13 commits July 23, 2026 06:27
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Inject a type-erased CodeIndexHookSink into McpServer via the
construction context. The daemon builds it in open_project_server (and
the portable broker path) closing over its cloneable
CodeIndexSchedulerRegistryV1, so crate::mcp never names the
daemon-private scheduler type. handle_hook_event_notification delivers
the exact touched rel_paths into the mounted worktree's incremental
queue as soon as the routing event is observed, independent of
host-admission durability and without any standing filesystem watcher.

Adds a direct test proving an after-edit hook reaches the sink with the
served project root and the exact touched paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cap the per-line read wait so a stalled daemon cannot exceed the
probe's total deadline; recompute the remaining budget each iteration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Forward-only post-update now waits for storage quick-check, authority
audit, and session temporal health to converge before running Doctor,
so schema migration and compatibility projections cannot race the gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Let dogfood forward-only runs opt out of the heal pass and integration
reinstall via TRACEDECAY_DOGFOOD_NO_HEAL/NO_REINSTALL.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tests/distribution/fastembed/acceptance.rs is copied into the packaged
crate's examples/ dir by scripts/check-distribution-acceptance.sh and
built as --example fastembed_distribution_acceptance. It is not a
source-repo target, so cargo-shear's unlinked-file report is a false
positive; document it via ignored-paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Inject the daemon-owned code-index scheduler registry into the MCP
hook boundary via a type-erased CodeIndexHookSink. After-edit hooks
now deliver their touched rel paths straight into the mounted
worktree's incremental queue (notify_hook_paths), independent of
host-admission durability. Also reword two stale InputEdit tree-cache
doc comments in the code-index scheduler.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP Work in progress; do not merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants