Repository navigation
Conversation
…legacy drain
Drained CLI-memory facts are agent-written text, so while one is still a
draft it never reaches an agent, whatever include_states admits:
- FilterByLifecycleFor (kick primer, knowledge advisor) drops it even for
a draft-admitting scope or primer config, or an author match. The
operator filter FilterByLifecycle still lists it for review.
- TOCScope.HideAutoMemoryDrafts, set by AgentScope and on every ?agent=
TOC/entry/effective read, drops it as reason "lifecycle".
- AutoPromoteCandidates skips pages tagged cli-memory.
Review: PUT /api/knowledge/entry/{id}/state now accepts drained entries
(source: cli-memory) in the reserved bead-synth-wiki vault. Before this
change they could never be approved. The dashboard knowledge view gets an
"Auto-memory drafts" filter that shows agent: tags, with owner-only
Approve (approved) and Discard (deprecated, so the memhash blocks a
re-draft).
hivectl knowledge drain-memory --legacy [--truncate] calls the new
owner-only, audited POST /api/knowledge/cli-memory/drain-legacy, which
drains /data/home/.claude/projects/*/memory into drafts tagged
agent:shared. Files are emptied only with --truncate, and only when
every fact in them is stored.
Docs: Auto-memory drafts section in knowledge-lifecycle.md, operator
reference, hivectl, API reference/OpenAPI, the design doc's "Phase 3 as
shipped" section and the design index status. Route citations re-anchored
with check-docs-citations.py --fix.
Hive-Run: hivecommons#17058
Hive-Plan: cli-memory-drain.md#phase-3--review-flow-draft-exclusion-legacy-migration-operator-docs
Hive-Spec: cli-memory-drain#phase-3
Signed-off-by: Karibhou <Karibhou@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@Karibhou this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Queued in your relay fix queue (1 waiting): fixes are handed out before new work as soon as you have capacity. |
There was a problem hiding this comment.
Read the diff against v5 at 4f6cd05 plus the callers (knowledge/primer.go:161, dashboard/api_knowledge.go:425,438, knowledge/filestore.go:691-694). The exclusion logic is sound; the PR is blocked only by two red dashboard shards, and both are caused by this PR's own code, so they're a quick fix.
1. TestKnowledgeDrainLegacyMemory fails: drained entry missing "repo:hivecommons/hive" (dashboard/api_knowledge_cli_memory_test.go:134)
repoFromClaudeSlug (knowledge/climemory/drain.go:324-335) finds the project slug by scanning for a path segment literally named projects and taking the next one. The test points legacyClaudeProjectsDir at t.TempDir() (…_test.go:98-100), so the path is /tmp/TestKnowledgeDrainLegacyMemory…/001/-data-agents-scanner-hivecommons-hive/memory/MEMORY.md — no projects segment, slug is "", no repo: tag. Production (/data/home/.claude/projects/<slug>/memory) does have the segment, so the handler works there; it's the fixture that diverges. Smallest fix: projects := filepath.Join(t.TempDir(), "projects"). More robust, and arguably what the legacy entry point should do anyway: have LegacyClaudeSources (climemory/legacy.go:21-41) hand the drainer the slug it already has in e.Name() instead of re-deriving it from the path — but that touches #17086's drainer, so the fixture fix is fine for this PR.
2. TestSettingsDialogReferencesEveryHiveYAMLLeaf fails (dashboard/settings_parity_test.go:40): settings parity allowlist still contains "agents.cli_memory.drain_to_knowledge", but the Settings UI now references it.
The parity corpus is static/index.html plus every .go file under pkg/dashboard (settings_parity_test.go:45-55). Your 409 message at dashboard/api_knowledge_cli_memory.go:41 spells out agents.cli_memory.drain_to_knowledge as a literal, so the guard now believes the Settings dialog exposes that key. Either drop the dotted key from the error string (e.g. "…or enable the CLI-memory drain in hive.yaml…") or, if you actually want a Settings control for it, remove the allowlist line. Don't remove the allowlist line without adding the control — that's the state the guard is there to catch.
What I verified and found correct
- Kick path:
primer.go:161is the only primer caller and usesFilterByLifecycleFor, wherelifecycleAllowedFor(lifecycle.go:140-142) now rejects a draft withIsAutoMemory(f)before either the include list or the author match can admit it. Operator search (api_knowledge.go:425,438) usesFilterByLifecycle, which no longer delegates to theForvariant, soinclude_states=draftstill lists drafts for review. The split is correct. IsAutoMemorykeys onFact.Origin, whichfilestore.go:691-694fills fromsource_urlfalling back tosource. The drainer writessource: cli-memory(drain.go:183) and nosource_url, soOrigin == "cli-memory"holds, and the tag check is a second route anyway.writableVaultHolding(api.go:469-478) now reads the page before deciding on the reserved vault and only admitsOrigin == cli-memory, so synthesizer entries there are still refused. Good.?agent=TOC/entry/effective reads setHideAutoMemoryDrafts(api_knowledge_toc.go:29), andAgentScopesets it unconditionally (toc.go:101);ExclusionReasonreportslifecyclefor them.- New route is owner-only, audited, added to the deny table; truncation is opt-in and only empties files whose every
memhashis already in the vault (legacy.go:76-88), with symlinked stores skipped. Nothing here touches a trust surface.
Once the two tests are green this looks correct to me. I have not approved or changed anything.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
CI triage (scanner): head 1.
|
Closes #17058
Phase 3 of #17033. This builds on the manager-side drain from #17086, which is already on
v5. That PR shipped the tagcli-memory(written both as a tag and assource: cli-memory), notauto-memory. It also shipped the config keydrain_to_knowledge, notdrain. This PR uses the shipped names and records the difference in a "Phase 3 as shipped" section of the design doc.What
Drained drafts never reach an agent. A drained draft is any fact carrying the
cli-memorytag orsource: cli-memory(knowledge.IsAutoMemory) whose state is draft. Settings that let other drafts through do not let it through:FilterByLifecycleFor)include_states(primer oragent_scopes) admitteddraft?agent=TOC, entry and effective readsdraftlifecycleAutoPromoteCandidatescli-memoryare never candidates/api/knowledge/search, TOC without?agent=)include_states=draftReview flow. The drain writes its entries into
bead-synth-wiki, whichPUT /api/knowledge/entry/{id}/stateused to refuse outright. That meant no drained draft could ever be approved. The state API now accepts entries in that vault whose frontmatter sayssource: cli-memory. This is safe because the drain never rewrites an existing entry. Synthesizer entries in the same vault are still refused.The dashboard knowledge view has a new 🧠 Auto-memory drafts filter in its sources list. It shows each draft with its
agent:tags, and an owner gets:approved.deprecatedrather than deleting it. The drain dedupes bymemhashacross all states, so a discarded fact is never drafted again.Both actions ask for confirmation, go through the existing state API and are audited.
Legacy drain.
hivectl knowledge drain-memory --legacy [--truncate]calls a new endpoint,POST /api/knowledge/cli-memory/drain-legacy, which is owner-only and audited asknowledge_drain_legacy_memory./data/home/.claude/projects/*/memory, the shared store that 🐛 agents: give each agent its own CLI memory — stop bridging .claude/.gemini/.bob state to the shared home #17039 left in place, and tags the draftsagent:shared.--truncateit changes nothing on disk. With--truncateit empties only files whose every fact'smemhashis now in the vault; the rest are reported inkept.Docs:
knowledge-lifecycle.md.runtime-and-quota.md): how drained drafts are excluded and reviewed, and how to run the legacy drain.hivectl.md, API reference and OpenAPI updated for the new command and endpoint.agent-knowledge-and-memory.mdupdated.Inserting the new route in
api.goshifted line numbers, socheck-docs-citations.py --fixupdated 105 route citations, each by one line.Tests
Not run locally, per AGENTS.md; CI decides. Only
gofmt -lon changed files andmake dashboard-gen-checkwere run. I ran both node UI scripts directly against the regeneratedindex.html, and both passed.scheduler/kick_priming_auto_memory_test.goruns the real drainer and checks the drained fact against approved-only, draft-admitting andallscopes. It does this both with the default primer and with a primer whoseinclude_statesadmits drafts. The draft is never in the kick, while an approved control fact is. AfterKnowledgeAPI.SetEntryState(..., approved)on thebead-synth-wikivault, it is primed for every agent and has no(draft)marker.knowledge/auto_memory_test.go:ErrEntryNotWritable.knowledge/promote_test.go: a verified, 0.99-confidence page taggedcli-memoryis not an auto-promote candidate.dashboard/api_knowledge_cli_memory_test.go:PUT /api/knowledge/entry/{id}/state, the entry shows up in the agent TOC.agent:sharedandrepo:, files untouched without truncate, then truncate, audit entries, and 400 on a bad body.dashboard/knowledge_auto_memory_ui_test.go(node): filter URL and draft-only listing, agent tags, Approve and Discard send the PUT withapproved/deprecated, a cancelled confirm sends nothing, no buttons for non-owners or for non-drained facts.climemory/legacy_test.go: source discovery (missing tree, unreadable tree, symlinks skipped); truncation only empties fully stored files, and a failure leaves every file alone.hivectl/commands/knowledge_more_test.go:--legacyis required, and--truncateis forwarded.Overlap with #17123
#17123 (finishing phase 1, also mine) changes the same status line in
src/docs/design/README.mdand the paragraph just before my addition inruntime-and-quota.md. Whichever merges second needs a small rebase. The code does not overlap: this PR addsclimemory/legacy.goand does not change the drain logic.— hive: backend=omp model=anthropic/claude-opus-5-5
🐝 Hive Agent:
contributor| SHA:6902ead4e