Skip to content

test(audit): check that captured memories keep their project tag - #562

Merged
kevintseng merged 6 commits into
mainfrom
test/hook-memories-keep-project
Sep 30, 2026
Merged

kevintseng merged 6 commits into
mainfrom
test/hook-memories-keep-project

Conversation

@kevintseng

Copy link
Copy Markdown
Contributor

Adds a npm run audit:memory check that reports every captured memory — a commit, a session summary or a task state — that has lost its project: tag, so a memory that silently drops out of its project is caught in the data, not only in a diff.

  • A memory someone deliberately made global without its capture tag is not reported.
  • An older version kept in replaced_history does not excuse a current memory that lacks a project.
  • Existing test fixtures that stored captured memories without a project now carry one.

Refs #519

A new memory invariant, `captured-memories-keep-a-project`: every memory a
hook captured (tagged `source:auto-capture`) and every task state must still
carry a `project:` tag, because every writer of those adds one. A memory of
that kind without one lost it afterwards, which is what
`kg rename-project --from X --to X --apply` did to every memory of project X
(#519).

It is keyed on the writers' own constants, not on names. It cannot see a
memory a person wrote without a project, a commit captured before the tag
existed, or a wrong but present project.

Two graph-repair fixtures now carry the project tag every real writer adds.

Refs #519
`captured-memories-keep-a-project` flagged a captured memory that a person
had deliberately turned into a global one (`remember` with `replace`,
`namespace: 'global'` and no project tag), including after export and import
into another graph. The global namespace is now excluded: a rename never
changes a memory's namespace, so #519's damage is still caught. A captured
session summary, not only a commit, is now tested as a violation too.

Refs #519
The data cannot tell a deliberate removal from damage: a replace record
describes an earlier write, not the later change that took the tag away.
So `npm run audit:memory` now reports every memory a hook captured, and
every task state, that has no project tag. To make a captured memory
global on purpose, replace it without the capture tag too; it is then a
person's own memory and is not checked.

Refs #519
@kevintseng
kevintseng merged commit 9d4e5bb into main Sep 30, 2026
12 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.

1 participant