Skip to content

spec: H2 amendment, scope and abstention (#119) - #155

Merged
gosha70 merged 5 commits into
mainfrom
spec/119-h2-scope-abstention
Nov 24, 2026
Merged

gosha70 merged 5 commits into
mainfrom
spec/119-h2-scope-abstention

Conversation

@gosha70

@gosha70 gosha70 commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

The design for H2, scope and abstention (issue #119's FR-001, FR-005, SC-1, SC-4, SC-6), as a spec amendment before any code (D5). Spec only: one section appended to specs/memkernel-0-15-harness-foundations/spec.md, after H1's amendment. It leaves #119 open; the H2 build follows once the owner has decided B1–B5.

Decisions for the owner (B1–B5)

  • B1 retain(scope=…) takes project (default), agent or task, meaning the caller's own id; stored as agent:<id> / task:<id>; refused without that id.
  • B2 A record the caller cannot see answers as a missing one: get/ask not found, forget deleted: false, a supersedes= or promote target ignored or not found. The cost (a mistyped id gets "not found", not a scope error) is stated.
  • B3 wiki_export drafts from project records only, whoever calls it.
  • B4 (recommended: scoped to the agent) A hook checkpoint is agent:<MEMKERNEL_AGENT_ID> when that variable is set, project otherwise, so two agents on one project each recover their own. Tools sharing one store (One memkernel store across several coding tools (Claude Code, Codex, Cursor, Antigravity) #107) must set the same agent id or none; the README and the Codex and Cursor templates will say so. The alternative (all hook checkpoints project) and its limit are written beside it.
  • B5 Scope is filtered in Python by one predicate, not in the store: a store filter cannot match records without the key (SC-4), and BM25 has no metadata. Recall keeps widening its window until it has top_k visible results or the store runs out.

Stated so the review can check them (B6–B11)

  • B6 Metadata key scope, written only when not project; no migration: every path, dedup included, reads a missing key as project.
  • B7 The caller: agent_id/task_id on recall, retain, get, ask, forget, promote, consolidate (from the call or the process), the process's for hook blocks, the settings' for the Python API. Neither: project only. The admin API sees every record, /health/store included.
  • B8 Every read path: recall (both orders), get, list_memories, ask, consolidate's candidates, the hook blocks, wiki_export. Health reaches callers as counts only.
  • B9 Writes: dedup per scope (two scopes, two unlinked records); promote keeps scope, scope="project" publishes; targets must be visible; wiki import and capture write project; withdraw is the wiki import's own, with no caller.
  • B10 excluded adds out_of_scope and capped (the captured-records limit H1 left out); each candidate counts once, in the order out of scope, superseded, flagged, expired, capped; out-of-scope candidates never reach the receipt's memories or returned_chars.
  • B11 An empty recall records empty_reason: no_match, out_of_scope (every candidate) or excluded; the MCP response stays a JSON list.

Review so far

The reviewer's pre-review points are answered in the text: B4's recommendation and its #107 interaction, B5's widening and legacy records, the admin API and health, promote and withdraw. DeepSeek (two rounds, plan review): PASS; acted on: one reason per excluded candidate, the not-found answers per path, no migration and dedup on legacy records.

Review round 1 (4d139d3 → a730733)

  • A private record supersedes only its own scope (B9): an agent:/task: record supersedes only that scope; a project record anything the caller can see (project records and the caller's own private ones). A breaking supersedes= is refused with an error. Code's automatic supersede follows the rule: one live snapshot per source and scope.
  • Checkpoints an agent saves itself (B4): retain(checkpoint=true) without scope is agent when the caller has an agent id (a task id alone does not change it); explicit scope="project" shares it. B1 points to it.
  • Parts take their owner's scope (B9): a code chunk is visible exactly when its owner is; a document chunk resolves only to a visible summary, else counts as out_of_scope.
  • order="newest" (B11): an empty one records no_match or out_of_scope.
  • Receipt entries (B10) add scope when it is not project.
  • DeepSeek on the revision: PASS; its four ambiguities (task id alone, project-over-private, snapshots per scope, unresolved chunks) are settled in the text above.

Owner's decisions (2026-11-23) → f4bfe26

  • B1, B2, B3, B5: yes.
  • B4 revised by the owner: a caller's effective scope is task:<task_id> when it has a task id, otherwise agent:<agent_id> when it has an agent id, otherwise project. Automatic (hook) and implicit (retain(checkpoint=true) without scope) checkpoints are saved there; latest-checkpoint recovery (session start, compaction recovery, recall(checkpoint_only=true, order="newest")) uses only that scope, with no fallback to project; scope="project" is an explicit shared handoff, visible to everyone through relevance recall. Tools continuing the same work share a task id; tools acting as the same logical agent share an agent id (One memkernel store across several coding tools (Claude Code, Codex, Cursor, Antigravity) #107).
  • The amendment is marked approved. For the reviewer: for order="newest", empty_reason: out_of_scope means live checkpoints exist but none in the caller's effective scope (B11).

Review round 2 (f4bfe26 → 19c7264)

B4's consequences, written into the spec for the build: checkpoint recovery needs the ids in the environment of both the server and the hooks; a task id stays the same across sessions continuing the same work; setting an id the first time starts that scope empty. B8: the startup report of ended sessions without a checkpoint counts checkpoints in any scope.

The design for H2 before any code (D5): how retain names a scope, what a record
the caller cannot see answers, wiki export, hook checkpoints scoped to
MEMKERNEL_AGENT_ID (and what that means for tools sharing a store, #107),
filtering in Python, storage, the caller on each path, every read and write
path, exclusion counts with out_of_scope and capped, and empty_reason.
B1-B5 await the owner.
A private record supersedes only its own scope (explicit and code's automatic
supersede; one live snapshot per source and scope); a checkpoint retain without
a scope defaults to the caller's agent scope under B4; parts take their owner's
scope and a document chunk resolves only to a visible summary; empty_reason for
order="newest"; receipt entries show a non-project scope.
The owner confirmed B1, B2, B3 and B5 and revised B4: automatic and implicit
checkpoints use the caller's effective scope (task when it has a task id,
otherwise agent when it has an agent id, otherwise project); latest-checkpoint
recovery uses only that scope; scope="project" is an explicit shared handoff.
Tools continuing the same work share a task id; tools acting as the same
logical agent share an agent id.
…ids, a new scope starts empty; unsaved-session report store-wide (#119)
@gosha70
gosha70 merged commit e84ec6f into main Nov 24, 2026
9 checks passed
@gosha70
gosha70 deleted the spec/119-h2-scope-abstention branch November 24, 2026 01:52
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.

1 participant