KeiSeiKit-1.0/docs
Parfii-bot 0eb73d1bf2 fix(outcome-hook): production payload uses object.content[*].text shape
Hook never fired in production despite passing unit tests. Diagnosed
via debug-log + payload dump: real Claude Code PostToolUse:Agent sends
`tool_response` as an OBJECT (not string, not array), with the agent's
reply at `tool_response.content[0].text` — keys: agentId / agentType /
content / prompt / status / toolStats / totalDurationMs / totalTokens
/ totalToolUseCount / usage.

Original jq filter handled string + object (`$r.content // $r.text`)
but `$r.content` returns the array verbatim; `jq -r` then dumps the
JSON literal which has `\n` as escape sequences, defeating the
`grep -m1 '^shipped:'` line-anchor.

Fix: recursive `flatten` jq function:
  string                     → as-is
  array of any               → recurse, join "\n"
  object with .text          → return .text
  object with .content       → recurse into content
  anything else              → ""

Verified end-to-end: latest 4 code-implementer spawns now write
outcome=functional to ledger correctly. Beta posterior in
kei-model-router begins receiving signal.

Production cleanup:
- Removed verbose debug-log + payload-dump diagnostic. Toggle via
  `AGENT_OUTCOME_DEBUG=1` env if hook stops firing in some future
  Claude Code version.
- Hook source committed to `hooks/agent-outcome-backfill.sh` so
  `install.sh` deploys it on fresh installs (was only in user-home
  previously — gap from `feat/substrate-path-atoms` agent run).

=== STATUS-TRUTH MARKER ===
shipped: functional
stubs: 0
cargo-check: NOT-RUN
behaviour-verified: yes
follow-up-required:
  - none

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 01:09:15 +08:00
..
AGENT-ROLES.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
AGENT-SCHEMA-LOCKED.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
AGENT-SUBSTRATE-SCHEMA.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
ARCHITECTURE.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
CONVERGENCE-PLAN.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
DNA-INDEX.md fix(outcome-hook): production payload uses object.content[*].text shape 2026-05-02 01:09:15 +08:00
HANDOFF-WAKE.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
IMPORT-RUNTIME.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
INSTALL.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
PHILOSOPHY.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
PUBLISHING.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
QUICKSTART.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
REFERENCE.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
RULES-AS-BLOCKS.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
SCHEMA-LOCKED.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
SCHEMA-UNLOCKED.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
SECURITY.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
SLEEP-LAYER.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
SUBSTRATE-SCHEMA.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
TAXONOMY.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
USB-BRAIN-GUIDE-linux.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
USB-BRAIN-GUIDE-macos.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
USB-BRAIN-GUIDE-windows.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
USB-BRAIN-GUIDE.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00
WHY.md KeiSeiKit-public — clean state 2026-05-01 12:09:03 +08:00