You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
workspace conformance: a writer suite (writes only through chant, every file change chant's, amnesia test) #3159
@intentius/chant/workspace/conformance holds a reader to the read contract: one chant call per read, the document unchanged, the workspace byte for byte the same. hud runs it. Nothing holds a writer to the write contract, so a tool can keep facts in its own store, or write record files without chant, and still pass.
Proposal
Extend the conformance module with a writer suite, published the same way (no test runner, a vitest wrapper):
Writes go through chant. The writer is built over a recording transport. Each action it performs (record a decision, answer a point, keep a review, claim and release a lease, tick evidence) must produce only write-contract commands, with their JSON flag, and each command's output validates against its schema (records-new, records-amend, records-close, records-review, points-write, point-answer, work-lease, work-evidence).
Every file change is chant's. The workspace tree is hashed before and after each action; every changed path must be one the recorded chant commands report writing.
Amnesia. The writer declares its private state locations (a database file, a state directory). The suite performs actions, deletes those locations, rebuilds the writer, and asserts that reading back through the read contract returns every fact the actions produced, including uncommitted ones in the working tree.
No facts outside the repo. Optionally, the writer exposes a "list what you hold" hook; anything it reports that isn't in the repo (and isn't declared cache, telemetry or secret) fails.
A tool passes by wiring its writer to the transport, exactly as readers do today. hud and studio both run it in CI.
Done when
The suite ships, the reference workspace's own writes pass it, and its README names the actions a writer must cover.
Design notes for the writer suite, as built in the PR for this issue.
The suite ships from the reader suite's import, @intentius/chant/workspace/conformance (runWorkspaceWriterConformance, no test runner) and @intentius/chant/workspace/conformance/vitest (describeWorkspaceWriterConformance). A consumer passes a factory (chant, { stateDir }) => writer, the same shape as the reader's (chant) => reader plus a state directory. The writer has write(step), facts(), and optionally holds() and close(). Options are actions (the write actions the tool performs) and privateState (what it keeps in stateDir, each path tagged cache, telemetry, secret or runtime, the four exceptions ws-074 allows).
The actions are the thirteen write commands: records new|amend|review|close, points ask|answer, work claim|renew|evidence|release, and runs start|end|record (#3033). A fixed script drives each one at least once on a generated workspace. That workspace is the reader suite's fixture plus an overlay with the reference workspace's work, answer and session kinds, its decision points, and one open work item. When a writer doesn't list a step's action, the suite performs that step itself through chant, so a later step still has the decision, session or lease it depends on.
Two departures from the issue text:
workEvidence had no command, so a writer outside an Op had no way to attach evidence through chant. The PR adds chant workspace work evidence <id> --holder --token --from <file|->, a thin wrapper over attachWorkEvidence that prints the existing work-evidence.schema.json document. workspace upgrade is in ws-074's write list but isn't a fact a tool records, so the script doesn't cover it.
"Every file change is chant's" is checked on the working tree (outside .git) and on git refs separately. A record write may change only the path its document reports, and no ref. A lease may move its lease ref, and chant/lifecycle to the commit its document reports; a run may move only chant/lifecycle. A writer that commits moves HEAD and fails the check.
The state directory sits outside the workspace, so a tool points its database there (for hud, HUD_DB_PATH under stateDir). Any file left there that privateState doesn't declare is a problem. For amnesia, the suite closes the writer, deletes the whole state directory, builds the writer again with the same stateDir, and requires facts() to be deep-equal before and after. facts() may make read-contract calls only, and must not change files or refs. Independently, the suite reads every fact the script produced back through records --uncommitted, work history and runs.
"The reference workspace's own writes pass it": the writer fixture's kinds are the reference workspace's, checked byte for byte by a test. referenceWriter, the smallest conforming writer, passes every action in the e2e test, and so does the same writer with a declared cache. A second writer that breaks one rule per step is caught at each step and after.
Activity
lex00 commentedon Oct 3, 2026
Design notes for the writer suite, as built in the PR for this issue.
The suite ships from the reader suite's import,
@intentius/chant/workspace/conformance(runWorkspaceWriterConformance, no test runner) and@intentius/chant/workspace/conformance/vitest(describeWorkspaceWriterConformance). A consumer passes a factory(chant, { stateDir }) => writer, the same shape as the reader's(chant) => readerplus a state directory. The writer haswrite(step),facts(), and optionallyholds()andclose(). Options areactions(the write actions the tool performs) andprivateState(what it keeps instateDir, each path tagged cache, telemetry, secret or runtime, the four exceptions ws-074 allows).The actions are the thirteen write commands:
records new|amend|review|close,points ask|answer,work claim|renew|evidence|release, andruns start|end|record(#3033). A fixed script drives each one at least once on a generated workspace. That workspace is the reader suite's fixture plus an overlay with the reference workspace's work, answer and session kinds, its decision points, and one open work item. When a writer doesn't list a step's action, the suite performs that step itself through chant, so a later step still has the decision, session or lease it depends on.Two departures from the issue text:
workEvidencehad no command, so a writer outside an Op had no way to attach evidence through chant. The PR addschant workspace work evidence <id> --holder --token --from <file|->, a thin wrapper overattachWorkEvidencethat prints the existingwork-evidence.schema.jsondocument.workspace upgradeis in ws-074's write list but isn't a fact a tool records, so the script doesn't cover it..git) and on git refs separately. A record write may change only the path its document reports, and no ref. A lease may move its lease ref, andchant/lifecycleto the commit its document reports; a run may move onlychant/lifecycle. A writer that commits movesHEADand fails the check.The state directory sits outside the workspace, so a tool points its database there (for hud,
HUD_DB_PATHunderstateDir). Any file left there thatprivateStatedoesn't declare is a problem. For amnesia, the suite closes the writer, deletes the whole state directory, builds the writer again with the samestateDir, and requiresfacts()to be deep-equal before and after.facts()may make read-contract calls only, and must not change files or refs. Independently, the suite reads every fact the script produced back throughrecords --uncommitted,work historyandruns."The reference workspace's own writes pass it": the writer fixture's kinds are the reference workspace's, checked byte for byte by a test.
referenceWriter, the smallest conforming writer, passes every action in the e2e test, and so does the same writer with a declared cache. A second writer that breaks one rule per step is caught at each step and after.feat(workspace): writer conformance suite with the amnesia test, and …