Task — engineering-spec@1

memory-append CLI, doc-driven runs can append chained BRAIN rows

doneTASK-IMP-093
module improvement · class product · priority p1 · created 2026-07-17 · shipped 2026-07-17
depends on none · blocks none

TASK-IMP-093: memory-append CLI, doc-driven runs can append chained BRAIN rows

Summary

Every ship-tasks phase declares memory rows (workflow_phase_complete, workflow_complete, task_routed_back, artefact_write), but without the MCP writer a doc-driven run has nowhere to append them - the real consumer run parked payloads in a tracked _audits file instead of the chain. Ship memory-append.mjs in docs-tools: a minimal, protocol-honoring appender for exactly those four kinds, with a verify mode, so governed runs can keep the chain truthful from any environment that has node.

Problem

The BRAIN's value is the chain; rows that live in a parking file have no prev_chain, no HEAD ordinal, and no tamper evidence. The protocol is written and vendored - what is missing is a writer small enough to run inside a doc-driven session.

Proposed Solution

node .cyberos/docs-tools/memory-append.mjs append <store-root> <kind> <payload.json|-> and ... verify <store-root>. Append: acquire the store lock, read HEAD (8-byte LE u64), build the record (kind, payload, actor, at, prev_chain), compute chain = SHA-256(canonical(record_minus_chain) || prev_chain) per §6.3, two-phase-write the row file and the advanced HEAD per §4.1 (tmp + rename + fsync; the Darwin F_BARRIERFSYNC caveat documented in-file - node exposes fsync only), release the lock. A fresh store bootstraps HEAD=0 with a null prev_chain root. Verify: walk the rows, recompute every chain link, compare the tip to HEAD. Kinds outside the four workflow kinds are refused before any write. build.sh gains the guarded vendor copy alongside its three helper siblings.

Alternatives Considered

Success Metrics

Scope

In scope: the two subcommands, the four kinds, fresh-store bootstrap, the suite, the build.sh vendor line.

Out of scope / Non-Goals

Dependencies

AI Authorship Disclosure

1. Description (normative)

2. Acceptance criteria

3. Edge cases

Audit

TASK-IMP-093-memory-append-cli spec audit - audit_rubric@2.0 (machine floor + judgment)

Machine floor: task-lint clean (the batch's two TRACE-001 misses - uncited suite-landing clauses in 093/094 - were caught by the lint on first run and fixed before audit; the governed loop working as built). Judgment families: metrics carry baseline/target/deadline grounded in run evidence or the recorded 2026-07-16 research; alternatives distinct with real rejection reasons; scope subsections present; ops-verified ACs carry explicit rationales; COND-004 truthful; cone-sharing (install.sh trio, build.sh pair, ship-tasks.md pair) declared in Dependencies per §11a so the batch schedule serializes correctly.

ISSUE ISS-001 (QA-004, wontfix-info): consumer-repo and single-prose-line ACs are ops-verified with recorded-evidence rationales (same accepted pattern as TASK-IMP-086/087/090).

SUMMARY verdict: pass issues_open: 0 issues_human: 0 next_action: ship

§gate-log

Populated during implementation (ship-tasks testing phase).