Skip to content

feat(knowledge): consolidate claims by scope and supersede snapshots by their outcome - #186266

Merged
roboclaw-bot merged 20 commits into
mainfrom
openclaw/knowledge-claim-consolidation
Oct 28, 2026
Merged

roboclaw-bot merged 20 commits into
mainfrom
openclaw/knowledge-claim-consolidation

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Knowledge claims pile up on hub pages (one team vault's project hub page has about 1,400 linked claims, 138 of them about 62 individual PRs), but the claim review only ever looked at unlinked claims. A status snapshot replaced by a claim that already exists could only be withdrawn, or "corrected", which writes a duplicate copy of the replacement.

User Impact

User impact: agents can run one claim consolidation review over the unlinked residue, the claims on one page, or the claims about one subject since a date. The review files claims on their most specific subject page and supersedes status snapshots and replaced claims by an existing claim with the new knowledge_supersede tool. Superseded claims leave default reads but stay readable as history, and a supersession can be undone. The scheduled scribe is now Knowledge Consolidation; its scheduled runs still review only claims that name no page.

After deploying: the review skill is renamed from knowledge-unlinked-claims to knowledge-claim-consolidation, and the Review unlinked claims scribe becomes Knowledge Consolidation with the new id claim-consolidation (declaration key knowledge:scribe:claim-consolidation). There is no migration or alias. An existing Review unlinked claims scribe (the Team Gateway has one) goes stale: its automation keeps the old declaration key and a stored run message naming the old skill, and the Scribes tab no longer lists it. Remove that automation (Knowledge scribe · Review unlinked claims) from the Automations page, then turn on Knowledge Consolidation from the Scribes tab. This PR does not change saved jobs.

Why This Change Was Made

  • Skill structure. The review skill is renamed to knowledge-claim-consolidation and generalized, not split into a sibling skill. The procedure is about 95% of the skill and differs only by starting set, and the shared-reference sync copies every topic to every skill, so a sibling would have duplicated the whole procedure. There is no compatibility alias: the old name never shipped in a release. Step numbering is unchanged.
  • Scribe. The scheduled scribe matches the skill: title and dialog title Knowledge Consolidation, id claim-consolidation, and a blurb, purpose and run step that describe the consolidation it does (filing, new pages, superseding snapshots by their outcome, page State). Its scheduled scope is not widened: runs still review only claims that name no page, and the blurb and purpose say so. Its closing counts now include superseded claims.
  • Scope selectors (step 1): unlinked residue (knowledge_relink dry run, unchanged), one page (knowledge_connections direction: "claims"), or one subject with an optional date (knowledge_timeline entity/since plus knowledge_grep kind: "claim" for claims filed elsewhere). Existing read tools cover all three, so no new selector tool.
  • knowledge_supersede: one revision-fenced publication marks 1 to 25 active claims superseded by an existing current claim. It reuses the existing superseded lifecycle: each earlier claim keeps its text, evidence, attribution and history and gets superseded_by and lifecycle_change, like a corrected original. The superseding claim is not rewritten. Validation: claims only; no self-supersession or repeated IDs; by must be current in the caller's scope; every earlier claim must be active and share a linked page (entities or source page, merge redirects followed) with by. Because by must be current and every earlier claim active, no cycle can form. undo: true restores claims this tool superseded by the same claim and lifts their durable supersession guards when the restore publishes. Undo rejects supersessions made by knowledge_correct. Default reads already exclude superseded records; historical reads and knowledge_history keep them.
  • Snapshot series (step 4): a series of status snapshots about one specific item (same PR, commit or decision thread) is superseded by its outcome claim only when every snapshot and the outcome name the same item, the outcome is later and states a final state, and they share a subject page. Otherwise both stay and are reported; unattended runs never guess. "Replaced" claims are now superseded instead of withdrawn; duplicates are still withdrawn.
  • Relinking (steps 2 and 3): when a subgroup meets the page-creation threshold, the new page becomes the primary subject (first in entities) and the broad page stays only on claims that say something about it.

Accepted edge cases: Recent activity does not list supersede publications, which matches merges today. Viewing the superseding claim does not list the claims it superseded; they link to it.

Coordination with #186270 (page budgets and section extraction): this PR does not touch step 5 of the skill or any budget logic. #186270 adds one bullet to step 5 of skills/knowledge-unlinked-claims/SKILL.md; this PR moves that file to skills/knowledge-claim-consolidation/SKILL.md, so whichever PR lands second must carry the bullet to the new path and check it survived. A trial merge with #186270 at a6e323a (before the rename) otherwise conflicts only where both PRs add lines next to each other: the Receipt.operation union, Prepared fields, the receipt block in accept, the storage-host registrations, and the tool table and count in docs/plugins/knowledge.md. Each conflict resolves by keeping both sides; whichever PR lands second sets the tool count to 37. #186270's relinkClaim applies the same subject rule during extraction (destination page first, source kept only when the claim names it), decided by name match inside one publication. The review decides by judgment and writes through knowledge_annotate, so there is no server helper to share; a future bulk relink tool could reuse relinkClaim.

Evidence

  • Supersede tests in extensions/knowledge/src/lifecycle.test.ts, on the lifecycle suite's isolated temp-vault fixture through the real service and storage worker: supersede, then undo, of a snapshot series, with text, evidence, attribution, reason and history kept; a stale active file cannot revive a superseded claim; rejection of self-supersession, repeats, a reverse edge (cycle), other subjects, unlinked claims, pages, stale fences, already superseded or withdrawn claims, and undo of a correction.
  • Red/green: with the guard release disabled, the undo test fails (expected 'superseded' to be 'active'); with it, it passes.
  • node scripts/run-vitest.mjs run extensions/knowledge after merging main at eec15d7: 54 of 55 files and 425 of 426 tests passed. The one failure, live-state.test.ts ("Expected watcher notification"), is a filesystem-watcher timing test this PR does not touch; it passed twice when rerun on its own (6 of 6 each time). Within the Knowledge plugin, the later merges of main at b3aa84d, beb12fa and 2262f3d changed only extensions/knowledge/package.json.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test pass; oxlint clean on changed files; node extensions/knowledge/scripts/sync-skill-references.mjs --check passes; docs format, markdownlint and git diff --check are clean. No earlier skill name or scribe title or id from this PR remains in the repository. knowledge-maintenance still appears as the id of the scheduled maintenance pass and its internal agent (maintenance.ts, access.ts), which predate this PR and are unrelated to the skill.
  • Test-line ceiling set to 6,294,048 (config/test-lines-baseline.txt; main has 6,293,776), exactly the merged tree's counted total with no slack. Justification: main itself is already over its own ceiling. At 2262f3d it counts 6,293,974 test lines against a ceiling of 6,293,776, 198 over, so any PR that adds a test line fails the ratchet. This PR's net delta is +74 lines, all coverage for the new supersede operation, its undo, and the renamed scribe and skill: +86 in lifecycle.test.ts for the supersede tests, offset by sharing the repeated scribe and record fixtures. The supersede tests were moved into the lifecycle suite to reuse its fixture, which cut the delta from +205; going lower would mean rewriting unrelated tests or dropping supersede coverage. On the merged tree, check-test-lines-ratchet reports Test lines OK: 6294048; ceiling: 6294048; slack: 0.
  • Dry run (read only, nothing written) on a real team vault: the 15 claims about one merged PR, all filed only on the project hub page. The review would create one page for the PR and relink all 15 to it, dropping the hub from claims that say nothing about the project. It would supersede five status snapshots by the merge outcome once that outcome is saved as a claim; the vault had none, so an unattended run supersedes nothing and reports the series. It keeps nine proof results and decisions as history and reports one claim as uncertain. The claim-level plan is in the implementation session.
  • Gap: no live Gateway run of a model following the generalized skill end to end. The tool is proven through the real service in isolated vaults.

Work sessions

Worked on by

roboclaw-bot and others added 2 commits October 27, 2026 20:00
…by their outcome

Generalize the knowledge-unlinked-claims review into a claim consolidation
review over the unlinked residue, one page, or one subject since a date, and
add knowledge_supersede to supersede earlier claims by an existing claim
(with undo) without writing a duplicate replacement.

Co-authored-by: jalehman <[email protected]>
…by their outcome

Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 25b88168-87e2-40b7-a0ad-e5fb72a2b939
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation plugin: knowledge size: L labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR extends claim consolidation to page and subject scopes and adds reversible supersession by an existing claim.

Example: PR 4242 has two CI snapshots and an existing merge-outcome claim.

  • Before: Retiring the snapshots requires withdrawal or correction that creates another replacement claim.
  • After: knowledge_supersede links both snapshots to the existing outcome, preserves their history, and supports undo.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful owner-directed feature with meaningful service-level tests, but a definite retrieval regression and unresolved existing-store compatibility prevent a pass.
Proof confidence 🦐 gold shrimp (3/6) This maintainer/bot PR is outside the ordinary contributor proof gate; its supplied validation exercises supersede and undo through the real service and storage worker in fresh vaults, while the real-vault dry run writes nothing. Existing-state compatibility for the persisted restored journal field and durable guard release is not demonstrated.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Hub pages accumulate claims and status snapshots that agents cannot consolidate into an existing outcome without withdrawal or duplicate replacement records.
Reason: The maintainer-authored direction addresses a concrete vault-management problem while preserving historical content and the existing scheduled-review scope.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this maintainer-authored PR open: the consolidation feature has clear value, but supersession can hide its own replacement claim through an existing dependency.

Priority: P2
Reviewed head: addc6576a1ad2de40587833940651b8c5dd5035b

Before merge

  • Reject replacements that depend on claims being superseded (P2) - The current-membership check runs before the planned lifecycle changes. If active claims A and B share a page and B has dependencies: [A.id], superseding A by B passes every check and publishes successfully. Current retrieval then removes A and transitively removes B, leaving the replacement absent from default reads. The same failure occurs through an intermediate dependent. The correction path already prevents this at storage-publication.ts:182–189. Reject the request before publication when lifecycleImpact for any targeted claim includes the replacement, and cover direct and transitive dependencies through the service boundary.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Reject replacements that depend on claims being superseded — extensions/knowledge/src/supersede.ts:64-68

Tests

  • Missing end-to-end proof: The supplied evidence does not exercise a model completing consolidation through a Gateway, and does not demonstrate an existing-store upgrade or interrupted-undo recovery.
Agent review details

How this fits together

The Knowledge plugin receives scoped agent tool calls, validates claim revisions, and publishes lifecycle changes through its storage worker and durable journal; retrieval then filters inactive records and their dependents.

flowchart LR
  A[Agent consolidation skill] --> B[Knowledge tool contract]
  B --> C[Scoped service access]
  C --> D[Storage worker]
  D --> E[Supersession planner]
  E --> F[Publication journal]
  F --> G[Vault and lifecycle guards]
  G --> H[Eligible retrieval]
Loading

Technical review

Best possible solution:

Keep the existing publication owner and reject supersession when its replacement would become ineligible through any targeted claim.

Do we have a high-confidence way to reproduce the issue?

Source establishes the failing input: create current claims A and B on the same page with B.dependencies containing A, then supersede A by B; publication succeeds and eligible() subsequently excludes B. No target code was executed.

Is this the best way to solve the issue?

The feature appropriately reuses existing readers, lifecycle metadata, and journal publication; the missing replacement-dependency rejection should reuse lifecycleImpact, matching the correction path.

Full review comments:

  • [P2] Reject replacements that depend on claims being superseded — extensions/knowledge/src/supersede.ts:64-68
    The current-membership check runs before the planned lifecycle changes. If active claims A and B share a page and B has dependencies: [A.id], superseding A by B passes every check and publishes successfully. Current retrieval then removes A and transitively removes B, leaving the replacement absent from default reads. The same failure occurs through an intermediate dependent. The correction path already prevents this at storage-publication.ts:182–189. Reject the request before publication when lifecycleImpact for any targeted claim includes the replacement, and cover direct and transitive dependencies through the service boundary.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 63113761e0c5.

Provenance checked

  • Claim-review handling of status snapshots changes intended behavior with a stated reason (65ad180: The bundled skill preserved snapshots of different moments as history; earlier standalone origins could not be recovered beyond an unavailable ancestor.)
  • Durable supersession guards changes intended behavior with a stated reason (65ad180: Durable guards prevent stale active files from reviving superseded records; this PR explains why only a journal-confirmed undo may release the supersession guard.)
  • Scheduled review scope and editable scribe messages keeps the original intent (feat(knowledge): readable scribe prompts the operator can edit #185974: Scribe setup and run messages are readable and operator-editable, while maintenance remains separate from agent-mediated unlinked-claim review.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs run extensions/knowledge/src/supersede.test.ts extensions/knowledge/src/lifecycle.test.ts
  • pnpm tsgo:extensions
  • pnpm tsgo:extensions:test
  • git diff --check

What I checked:

PR surface

Source +238, Tests +201, Docs +100. Total +539 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 13 245 7 +238
Tests 1 201 0 +201
Docs 6 171 71 +100
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 617 78 +539

Labels

Label changes:

  • add P2: The introduced failure affects an optional plugin's consolidation operation and is recoverable through undo.
  • add merge-risk: 🚨 compatibility: The additive plugin operation introduces serialized receipt values and an undo journal field that removes durable supersession guards; existing-store compatibility remains unproven.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The introduced failure affects an optional plugin's consolidation operation and is recoverable through undo.
  • merge-risk: 🚨 compatibility: The additive plugin operation introduces serialized receipt values and an undo journal field that removes durable supersession guards; existing-store compatibility remains unproven.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 27, 2026, 4:16 PM ET / 20:16 UTC.

roboclaw-bot and others added 17 commits October 27, 2026 20:33
Picks up the raised test-lines ceiling on main so checks-fast-baseline-ratchets passes.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 80974ccb-0d5d-45eb-871f-1a6985858716
…enance

The skill now reviews claims over several scopes, not only unlinked ones.
The Review unlinked claims scribe keeps its title and still reviews only the
unlinked residue.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 46dda3e4-aff5-4767-b792-553d3fee8f02
… unlinked claims

The scribe follows knowledge-maintenance and now says what its scheduled run
does: consolidate the claims that name no page. Its id becomes
claim-consolidation; scheduled runs still cover only the unlinked residue.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 33313b44-96b9-4414-bbdc-5e89699e4e7f
… the scribe Knowledge Consolidation

The scribe keeps the claim-consolidation id and declaration key, and its
scheduled runs still review only claims that name no page.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 71007868-596b-41c0-8a9d-7ef1b7508e59
Reuse the lifecycle fixture for the supersede tests and share the repeated
record and scribe fixtures, cutting this PR's test-line growth from +205 to
+74 while keeping every supersede assertion.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 2f2e33e7-3467-4dbe-8ae9-3581599e633e
main at b3aa84d counts 6,293,484 test lines against its ceiling of
6,293,407. This PR adds 74 net lines of supersede coverage, so the ceiling
moves to the merged total of 6,293,558 with no extra slack.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 3e2f5815-39c7-4e17-9513-5a8de06aab96
Resolves the test-line ceiling conflict with #184502: main at beb12fa counts
6,293,568 test lines against its ceiling of 6,293,290, and this PR adds 74,
so the ceiling is the merged total of 6,293,642 with no extra slack.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 989a8f69-607b-439d-8bba-e1b6fa3b90b7
Resolves the test-line ceiling conflict: main at 2262f3d counts 6293974 test
lines against its ceiling of 6293776, and this PR adds 74, so the ceiling is the
merged total of 6294048 with no extra slack.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 015e2d74-fc67-42e7-aa5b-c97e67b94744
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: knowledge rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant