Black box · flight recorder黑匣子 · 飞行记录仪

The black box recorder for overnight AI agents. 过夜 AI agent 的黑匣子记录仪

You start a run at 22:00 and wake up to a green checkmark and a confident summary. NightWatch records every event into a hash-chained, append-only ledger — and the morning debrief re-verifies the agent's claims instead of retelling its story. 你 22:00 启动一个运行,醒来看到绿色对勾和一段自信的总结。NightWatch 把会话的每个事件写入哈希链式、只可追加的账本——晨报逐条重验 agent 的声明,而不是转述它的故事。

Logs are claims. Replays are proofs.

What gets verified验证什么

Claims, checked against ground truth.每条声明,对照地面真相。

The agent's claimAgent 的声明Ground truth used使用的地面真相
“Tests passed”「测试通过了」re-run the exact recorded command (--verify)重跑录制下来的原始命令(--verify)
“I changed these files”「我改了这些文件」git diff against the run's first checkpoint — out-of-band writes surface对运行首个检查点做 git diff——绕过工具的写入无处可藏
“I stayed in scope”「我没有越界」declared globs vs. actually changed paths声明的 glob 范围 vs. 实际变更路径
“This is the full history”「这是完整历史」SHA-256 hash chain + head sidecar — tampering and truncation localize to the exact recordSHA-256 哈希链 + head 锚——篡改与截断定位到具体哪一条
Quickstart快速开始

Four steps, one night.四步,一夜。

01Install & wire up. npm i -g nightwatch-agent, then nightwatch init in your project — Claude Code by default, --agent alfred for Alfred.安装并接线。npm i -g nightwatch-agent,然后在项目里 nightwatch init——默认接 Claude Code,加 --agent alfred 接 Alfred。
02Start a NEW session (hooks load at session start) and check it's recording: nightwatch status.开一个新会话(hooks 在会话启动时加载),并确认在录:nightwatch status
03Hand over the night. Every event lands in the ledger; checkpoints snapshot the worktree as it goes.把夜晚交出去。每个事件落账,检查点沿途快照工作区。
04Morning: nightwatch debrief --verify — and in CI, nightwatch attest refuses any PR whose receipt doesn't vouch for its diff.清晨:nightwatch debrief --verify——在 CI 里,nightwatch attest 会拒签任何收据无法背书的 PR。
# try it right now — no agent session needed:
npm i -g nightwatch-agent
nightwatch demo            # English report
nightwatch demo --lang zh  # 中文晨报
The trust layer信任层

One run, two independent witnesses.同一次运行,两个独立见证者。

NightWatch is the Record leg of the Agent Trust Layer. Point it at an autonomous Alfred run (nightwatch init --agent alfred) and the night ends with two ledgers that would both have to be forged to tell one lie: NightWatch 是 Agent Trust Layer 的「记录」环节。把它接到 Alfred 的自主运行上(nightwatch init --agent alfred),一夜结束时会留下两本账——想撒一个谎,得同时伪造两本:

Witness 1 — the agent's receipt见证 1——agent 自己的收据

Alfred's HMAC-signed run ledger: verify-gate exits and feature outcomes, signed with a secret the agent never sees.Alfred 的 HMAC 签名运行账本:verify 门禁退出码与 feature 结果,签名密钥 agent 永远接触不到。

Witness 2 — the black box见证 2——黑匣子

NightWatch's external hash-chained ledger: every tool call, every claim, recorded by a process the agent cannot edit.NightWatch 的外部哈希链账本:每次工具调用、每条声明,由 agent 无法触碰的进程记录。

Both emit the same Agent Trust Report v0 — alongside trace-vault's replay gate — so CI consumes one verdict format for all three. A real dual-witness run, raw ledgers included, is committed in the spec repo. 两个见证者输出同一种 Agent Trust Report v0——连同 trace-vault 的重放门禁,CI 用一个消费端读完三道关。一次真实双见证运行(含原始账本)已提交在 spec 仓库