Skip to content

fix(rank,ledger): review-confirmed defect fixes + feat(collide): parallel-session conflict radar - #120

Merged
CodeWithJuber merged 4 commits into
masterfrom
claude/repo-review-agentic-generics-tteyld
Aug 7, 2026
Merged

fix(rank,ledger): review-confirmed defect fixes + feat(collide): parallel-session conflict radar#120
CodeWithJuber merged 4 commits into
masterfrom
claude/repo-review-agentic-generics-tteyld

Conversation

@CodeWithJuber

@CodeWithJuber CodeWithJuber commented Aug 7, 2026

Copy link
Copy Markdown
Owner

What & why

Two things, same branch: (1) fixes for eight adversarial-review-confirmed defects in the v0.28.0 rank/ledger work, and (2) forge collide — the next everyday-agentic feature, built on the fixed foundations.

1. Review-confirmed fixes

An adversarial review workflow (4 finder dimensions → 8 findings → 2 independent skeptics each, 16/16 confirmations, 0 refutations, reproduced against the live modules):

  • The hazard join was silently dead in production — hook-minted claims store absolute paths, the atlas speaks repo-relative POSIX; history() never matched and hazard degenerated to bare centrality. Now relativized against the repo root, with the production path shape pinned by a test.
  • beliefDiff tombstone edges — a claim minted and retracted inside the window was reported as "appeared" with live confidence (now retired, from:null,to:null); claims dead before the window no longer move via pure decay.
  • Determinism — all rank orderings now use codepoint comparison (localeCompare is ICU/locale-dependent).
  • Hardeningcentrality() dedupes node ids; corrupt atlas.json degrades instead of crashing the CLI/hanging rank_code; negative --top clamps; ledger diff refuses <since> after <until>; impossible calendar dates rejected instead of Date.parse rollover.

2. forge collide — parallel-session conflict radar (+ collide_check MCP tool)

The everyday failure of the agent-fleet era: two sessions silently edit the same or import-coupled files, and the conflict surfaces at merge time. Every session already mints a ledger summary claim of the files it touched, and those claims team-merge over plain git — so "who else was just in here?" is a pure read: no server, no presence protocol, no new storage (workspace-awareness research à la Palantír, rebuilt on a CRDT ledger).

risk = 1 − ∏(1 − recᵢ × strengthᵢ) over recent foreign sessions — 7-day recency half-life (a collision is about now), direct hits full weight, 1-hop import neighbors half. Advisory, fail-open, own-author sessions skipped, absolute hook paths relativized. forge collide [<file>…] [--json] defaults to the working diff; agents get it as the collide_check MCP tool (21 tools).

All command tables, the MCP tool table, and every count phrase were regenerated by forge docs render — the doc-sync automation from #119 doing its job on its first real change.

Checklist

  • npm test passes (1,111 pass / 0 fail locally, Node 20)
  • npm run check passes (Biome lint + format)
  • New public functions have a test (12 new tests: 7 regression + 5 collide)
  • Conventional commit message (feat:/fix:/docs: …)
  • CHANGELOG.md updated under ## [Unreleased]
  • No new runtime dependency (dev deps ok)
  • Substrate/docs updated if this changes forge substrate, forge impact, router/gate, or MCP substrate tools (GUIDE + mintlify sections; generated tables/counts via forge docs render)

Risk & rollback

  • Risk level: low — fixes move behavior toward documented contracts; collide is an additive advisory surface (new command + MCP tool), fail-open everywhere.
  • Rollback plan: revert the three commits; no storage or format changes.

Extra checks (tick if applicable)

  • npm run typecheck passes
  • Input validated at boundaries; errors handled (no swallowing)
  • Authorization/ownership checked (if it touches access) — n/a
  • Logs contain no secrets/PII
  • If AI-assisted: I understand it, verified the package APIs, and it has tests

🤖 Generated with Claude Code

https://claude.ai/code/session_01LXmzxfRVDRVPU6LG8W39Rz

claude added 3 commits August 7, 2026 07:57
…fDiff tombstone edges; determinism hardening

Adversarial review (4 finder dimensions, 2 skeptics per finding, 16/16
confirmations) surfaced eight defects in the v0.28.0 rank/ledger work.
All fixed, each pinned by a regression test:

- history() never matched a production claim: hook-minted lessons and
  deja summaries store raw tool-input paths (ABSOLUTE — cortex_hook
  stores file_path verbatim), while atlas files are repo-relative POSIX.
  hazard silently degenerated to bare centrality; fail-open hid it, and
  tests passed only because fixtures hand-minted relative paths. The
  join now relativizes claim paths against the repo root, and the test
  uses the production path shape.
- beliefDiff: a claim minted AND retracted inside the window was pushed
  to appeared with a live val — a retracted claim presented as a current
  belief. The tombstone test now runs first (retired, from:null,
  to:null). Claims already dead at dayA no longer show up as
  strengthened/weakened via pure decay.
- Determinism: every ordering in rank.js now uses locale-independent
  codepoint comparison — localeCompare consults ICU collation tables
  that differ across machines, contradicting the module's own
  cross-machine guarantee.
- centrality() dedupes node ids like pagerank already did (a duplicate
  id no longer counts its file's score twice).
- rankReport survives a corrupt .forge/atlas.json (built:false instead
  of a CLI crash and a hung rank_code MCP call) and clamps a negative
  --top (slice(0, -n) returned nearly the whole graph).
- CLI: ledger diff refuses <since> after <until> (previously printed
  silently inverted classes); ledger at/diff reject impossible calendar
  dates instead of letting Date.parse roll 2026-02-31 into March.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXmzxfRVDRVPU6LG8W39Rz
…ool)

The everyday failure of the agent-fleet era: two sessions — your agent
and a teammate's, or two of your own — silently edit the same or
import-coupled files and the conflict surfaces only at merge time. The
ledger already holds the answer: deja mints a session-summary claim
(body.files) for every session and those claims team-merge over plain
git, so "who else was just in here?" is a pure read — no server, no
presence protocol, no new storage. (Workspace-awareness research —
Palantír-style conflict early warning — rebuilt on a CRDT ledger
instead of a central server.)

risk = 1 − ∏(1 − rec_i × strength_i): the house noisy-OR over recent
foreign sessions, where recency uses a deliberately short 7-day
half-life (a collision is about NOW, not the 45-day belief clock) and
strength counts direct file hits full, 1-hop import neighbors half.
Own-author sessions and tombstoned summaries are skipped; hook-minted
absolute paths are relativized like the rank history join; everything
is advisory and fail-open.

Surface: forge collide [<file>…] [--json] (Labs; default input is the
working diff via anchor's gitFiles, now exported) and the collide_check
MCP tool — an agent can ask "is anyone else in here?" before its first
edit. All command tables, the MCP tool table, and the 21-tools counts
were regenerated by forge docs render.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXmzxfRVDRVPU6LG8W39Rz
@CodeWithJuber CodeWithJuber changed the title fix(rank,ledger): repair the hazard join for production claims; beliefDiff tombstone edges; determinism hardening fix(rank,ledger): review-confirmed defect fixes + feat(collide): parallel-session conflict radar Aug 7, 2026
The format-on-edit hook rewrites at 80 columns; the repo's Biome config
is 100. Whole-scope `biome format --write .` sweep so the committed
bytes match the CI formatter exactly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXmzxfRVDRVPU6LG8W39Rz
@CodeWithJuber
CodeWithJuber marked this pull request as ready for review August 7, 2026 14:08
@CodeWithJuber
CodeWithJuber merged commit d8ed2ce into master Aug 7, 2026
13 checks passed
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