Skip to content

feat: softly demote drifted code claims in the hook worker - #182

Open
divo12 wants to merge 1 commit into
Autoloops:mainfrom
divo12:codex/background-anchor-demotion
Open

feat: softly demote drifted code claims in the hook worker#182
divo12 wants to merge 1 commit into
Autoloops:mainfrom
divo12:codex/background-anchor-demotion

Conversation

@divo12

@divo12 divo12 commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Close the loop between deterministic anchor auditing and durable memory state.

When the existing auto-memory hook worker is due, it now audits each writable repository once. An active code_verified claim is softly demoted when any anchor has:

  • content drift (drifted)
  • a missing file (missing_file)
  • a missing symbol (missing_symbol)

Demotion creates a deterministic truth: unknown replacement, preserves the claim's wording, kind, intent, and about relationships, and supersedes the verified original. The original remains in history. The supersession metadata records the exact Git SHA and sorted anchor-audit evidence.

Why this shape

Issue #90 identifies the missing write action: anchor audit could prove that memory was stale, but the claim remained trusted. The fingerprint work behind #91 also makes same-symbol content changes actionable.

This PR deliberately uses the small existing controller loop instead of reviving the broad freshness engine from #96:

due hook worker -> clean default-branch check -> anchor audit -> one proposal -> applyProposal

That means no second worker, schema migration, checkpoint, reverse index, public flag, managed protocol, or LLM repair path.

Safety and scope

  • Reuses the existing worker lease, due-session cadence, auto-memory opt-in, and writable-role filtering.
  • Runs only on a clean tracked checkout of the stored default branch; unrelated untracked files are allowed.
  • Managed readers and revoked users are excluded before the pass is scheduled.
  • Local mode writes locally; managed contributors/admins continue through the existing personal working-scope provider and working-head validation.
  • Ambiguous, unsupported, anchorless, source-verified, unknown, and already-superseded claims are not changed.
  • A retry converges without duplicate replacements because IDs are stable and only active code_verified claims are eligible.

Verification

  • npm run typecheck
  • npm run build
  • node scripts/check-anchor-drift-worker.js
  • npm test
  • git diff --check
  • ECC pre-push: typecheck, full test suite, and build passed

The focused integration fixture exercises real fingerprint content drift, missing files, missing symbols, a partially drifted multi-anchor claim, preserved component relationships, superseded history, evidence metadata, checkout gates, and idempotent retry.

A read-only dry construction against the shared managed repository checked 323 active claims and produced 68 unique replacement/supersession pairs from real audit output: 46 drifted, 51 missing_file, and 4 missing_symbol evidence entries (some claims had multiple issues). Assertions confirmed every replacement was unknown, preserved wording/kind/intent, omitted anchors and evidence links, and superseded an active code_verified original. applyProposal was never called under the reader role.

Closes #90.

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.

feat: Anchor-drift auto-invalidation for code_verified claims

1 participant