kiokuko 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.ja.md +1 -0
  2. package/dist/akinator/agent-task.d.ts +2 -0
  3. package/dist/akinator/agent-task.d.ts.map +1 -1
  4. package/dist/akinator/agent-task.js +13 -59
  5. package/dist/akinator/agent-task.js.map +1 -1
  6. package/dist/akinator/capabilities.d.ts +4 -3
  7. package/dist/akinator/capabilities.d.ts.map +1 -1
  8. package/dist/akinator/capabilities.js +51 -52
  9. package/dist/akinator/capabilities.js.map +1 -1
  10. package/dist/akinator/capability-binding.d.ts +1 -1
  11. package/dist/akinator/capability-binding.js +1 -1
  12. package/dist/akinator/memory-probe-types.d.ts +1 -1
  13. package/dist/assurance/codex-hooks.d.ts +7 -0
  14. package/dist/assurance/codex-hooks.d.ts.map +1 -0
  15. package/dist/assurance/codex-hooks.js +217 -0
  16. package/dist/assurance/codex-hooks.js.map +1 -0
  17. package/dist/assurance/contracts.d.ts +54 -0
  18. package/dist/assurance/contracts.d.ts.map +1 -0
  19. package/dist/assurance/contracts.js +37 -0
  20. package/dist/assurance/contracts.js.map +1 -0
  21. package/dist/assurance/doctor.d.ts +7 -0
  22. package/dist/assurance/doctor.d.ts.map +1 -0
  23. package/dist/assurance/doctor.js +39 -0
  24. package/dist/assurance/doctor.js.map +1 -0
  25. package/dist/assurance/inspect.d.ts +16 -0
  26. package/dist/assurance/inspect.d.ts.map +1 -0
  27. package/dist/assurance/inspect.js +29 -0
  28. package/dist/assurance/inspect.js.map +1 -0
  29. package/dist/assurance/instructions.d.ts +2 -0
  30. package/dist/assurance/instructions.d.ts.map +1 -0
  31. package/dist/assurance/instructions.js +2 -0
  32. package/dist/assurance/instructions.js.map +1 -0
  33. package/dist/assurance/refresh.d.ts +3 -0
  34. package/dist/assurance/refresh.d.ts.map +1 -0
  35. package/dist/assurance/refresh.js +73 -0
  36. package/dist/assurance/refresh.js.map +1 -0
  37. package/dist/assurance/service.d.ts +54 -0
  38. package/dist/assurance/service.d.ts.map +1 -0
  39. package/dist/assurance/service.js +183 -0
  40. package/dist/assurance/service.js.map +1 -0
  41. package/dist/assurance/snapshot.d.ts +3 -0
  42. package/dist/assurance/snapshot.d.ts.map +1 -0
  43. package/dist/assurance/snapshot.js +44 -0
  44. package/dist/assurance/snapshot.js.map +1 -0
  45. package/dist/cli.d.ts.map +1 -1
  46. package/dist/cli.js +2 -0
  47. package/dist/cli.js.map +1 -1
  48. package/dist/commands/codex-hook.d.ts +4 -0
  49. package/dist/commands/codex-hook.d.ts.map +1 -0
  50. package/dist/commands/codex-hook.js +36 -0
  51. package/dist/commands/codex-hook.js.map +1 -0
  52. package/dist/commands/doctor.d.ts +1 -0
  53. package/dist/commands/doctor.d.ts.map +1 -1
  54. package/dist/commands/doctor.js +3 -0
  55. package/dist/commands/doctor.js.map +1 -1
  56. package/dist/commands/setup.d.ts +1 -1
  57. package/dist/commands/setup.d.ts.map +1 -1
  58. package/dist/commands/setup.js +2 -0
  59. package/dist/commands/setup.js.map +1 -1
  60. package/dist/commands/uninstall.d.ts.map +1 -1
  61. package/dist/commands/uninstall.js +2 -1
  62. package/dist/commands/uninstall.js.map +1 -1
  63. package/dist/context/delivery.d.ts.map +1 -1
  64. package/dist/context/delivery.js +5 -2
  65. package/dist/context/delivery.js.map +1 -1
  66. package/dist/context/scoped-broker.d.ts +3 -2
  67. package/dist/context/scoped-broker.d.ts.map +1 -1
  68. package/dist/context/scoped-broker.js +11 -4
  69. package/dist/context/scoped-broker.js.map +1 -1
  70. package/dist/context/scoped-memory-use.d.ts +5 -0
  71. package/dist/context/scoped-memory-use.d.ts.map +1 -0
  72. package/dist/context/scoped-memory-use.js +60 -0
  73. package/dist/context/scoped-memory-use.js.map +1 -0
  74. package/dist/gateway/agent-service.d.ts.map +1 -1
  75. package/dist/gateway/agent-service.js +2 -0
  76. package/dist/gateway/agent-service.js.map +1 -1
  77. package/dist/mcp/request-deadline.d.ts +1 -1
  78. package/dist/mcp/request-deadline.d.ts.map +1 -1
  79. package/dist/mcp/request-deadline.js +3 -0
  80. package/dist/mcp/request-deadline.js.map +1 -1
  81. package/dist/mcp/server.d.ts.map +1 -1
  82. package/dist/mcp/server.js +35 -1
  83. package/dist/mcp/server.js.map +1 -1
  84. package/dist/memory/checkpoint-contract.d.ts +6 -6
  85. package/dist/memory/federated-retrieval.d.ts +6 -0
  86. package/dist/memory/federated-retrieval.d.ts.map +1 -1
  87. package/dist/memory/federated-retrieval.js +19 -7
  88. package/dist/memory/federated-retrieval.js.map +1 -1
  89. package/dist/memory/interaction-contract.d.ts +24 -24
  90. package/dist/memory/scoped-memory.d.ts.map +1 -1
  91. package/dist/memory/scoped-memory.js +3 -0
  92. package/dist/memory/scoped-memory.js.map +1 -1
  93. package/dist/server/agent-application.d.ts.map +1 -1
  94. package/dist/server/agent-application.js +4 -1
  95. package/dist/server/agent-application.js.map +1 -1
  96. package/dist/server/routes/agent-capability-gate.d.ts.map +1 -1
  97. package/dist/server/routes/agent-capability-gate.js +5 -0
  98. package/dist/server/routes/agent-capability-gate.js.map +1 -1
  99. package/dist/server/routes/task-assurance.d.ts +5 -0
  100. package/dist/server/routes/task-assurance.d.ts.map +1 -0
  101. package/dist/server/routes/task-assurance.js +43 -0
  102. package/dist/server/routes/task-assurance.js.map +1 -0
  103. package/dist/setup/codex-hooks.d.ts +5 -0
  104. package/dist/setup/codex-hooks.d.ts.map +1 -0
  105. package/dist/setup/codex-hooks.js +69 -0
  106. package/dist/setup/codex-hooks.js.map +1 -0
  107. package/dist/setup/render.d.ts.map +1 -1
  108. package/dist/setup/render.js +3 -1
  109. package/dist/setup/render.js.map +1 -1
  110. package/docs/memory-assurance.md +127 -0
  111. package/migrations/004_memory_assurance.sql +74 -0
  112. package/package.json +4 -3
  113. package/skills/memory-reasoning/SKILL.md +24 -3
@@ -0,0 +1,127 @@
1
+ # Memory application and execution evidence
2
+
3
+ Kiokuko tracks whether applicable delivered memory has a current decision and
4
+ regression evidence. It cannot prove that a model understood a memory, that a
5
+ stated rationale is correct, or that a chosen verifier is sufficient.
6
+
7
+ ## Workflow
8
+
9
+ 1. Read the bundled SOUL and memory-reasoning Skills and call `task_prepare`.
10
+ Complete the existing Akinator intake with `task_answer`.
11
+ 2. Read `assurance` in the preparation response or call `task_memory_status`.
12
+ It reports the current revision, missing decisions and stale verification.
13
+ 3. Call `task_memory_review` for selected actionable entries. Bind the run,
14
+ delivery ID, entry ID/revision and expected assurance revision. Choose
15
+ `adopted`, `inapplicable` or `contradicted`. All decisions need current evidence;
16
+ adoption also needs an invariant, counterexample and verifier.
17
+ 4. For implementation, run the verifier and link its evidence IDs with another
18
+ review. `task_memory_status` with `snapshot: true` returns the pre-execution
19
+ state digest required by `task_execution_evidence`. Public evidence is always
20
+ **model-reported**. The Codex adapter records **client-observed** results only
21
+ when the client supplies a recognized completed exit status.
22
+ 5. Use `task_memory_refresh` when new paths or errors change the search. Preserve
23
+ the run and exact capability catalog. A different delivery or entry revision
24
+ requires reconfirming affected reviews. Finish with the existing checkpoint.
25
+
26
+ Only memories selected as actionable require decisions. Incidental retrieval
27
+ results do not impose formal checklists. Code PLAN/review requires grounded
28
+ application decisions; implementation requires passing regression evidence.
29
+ Failure, cancellation and interruption can terminate without passing evidence.
30
+ Existing non-terminal server checkpoints remain non-terminal. Legacy callers
31
+ without the assurance contract remain unobserved, never retrospectively verified.
32
+
33
+ Retries use the same `requestId`, complete input and `expectedRevision`. A changed
34
+ request under the same ID or a stale revision conflicts. Review and evidence
35
+ records are durable. The repository state hash covers Git-visible tracked and
36
+ unignored files plus conventional local environment and Codex/Kiokuko config
37
+ files; edits invalidate prior results. Other ignored files are outside that snapshot. Symlinks, non-regular files, more than 20,000 files or 64 MiB of content
38
+ make snapshot verification unavailable rather than silently incomplete.
39
+
40
+ ## API
41
+
42
+ The MCP tools and authenticated server routes share the domain implementation:
43
+
44
+ | MCP tool | POST route under `/api/v1/agent/runs/:runId/` |
45
+ | --- | --- |
46
+ | `task_memory_review` | `memory-review` |
47
+ | `task_execution_evidence` | `execution-evidence` |
48
+ | `task_memory_refresh` | `memory-refresh` |
49
+ | `task_memory_status` | `memory-status` |
50
+
51
+ For HTTP, put the request ID in `Idempotency-Key`, the run ID in the path, and
52
+ remaining fields in the body. The status body accepts `cwd` and `snapshot`.
53
+ `task_inspect` provides bounded preparation reads and bundled Skill access
54
+ without executing a model-supplied shell command.
55
+
56
+ Capability normalization v2 reserves identity space before spending description
57
+ space. More than 200 valid capabilities are accepted. Oversized descriptions are
58
+ omitted without losing identities. Malformed inputs or identity-budget exhaustion
59
+ remain explicitly `unknown`. Digest version 2 conflicts with older bound runs;
60
+ start a new logical request after upgrading instead of resuming a v1 binding.
61
+
62
+ Scoped retrieval distinguishes `no_entries`, `no_match`, `out_of_scope`,
63
+ `capability_withheld`, and `delivered` in assurance diagnostics. Search exceptions
64
+ remain errors and never become a normal empty result. Counts describe the bounded
65
+ search lanes; they are not an inventory of unrelated project memories.
66
+
67
+ ## Codex setup and limits
68
+
69
+ ```sh
70
+ kiokuko setup --clients codex
71
+ kiokuko doctor
72
+ ```
73
+
74
+ Setup adds only Kiokuko-owned event handlers to Codex `hooks.json`; reinstall and
75
+ uninstall preserve other handlers and settings. Review the new hook definitions
76
+ in Codex `/hooks` and restart/reopen the client as required by its configuration
77
+ lifecycle. Configuration presence does not prove that the current client executes
78
+ hooks. Doctor distinguishes configured hooks, historical observations and the
79
+ unconfirmed current client, plus pending reviews and verification.
80
+
81
+ The adapter handles UserPromptSubmit, PreToolUse, PostToolUse, Stop, Interrupt and
82
+ explicit child lifecycle identities. It derives request bindings from client
83
+ hook events, never from a model-supplied session ID. It does not fabricate
84
+ `soulRead`. The supported preparation route permits Kiokuko operations and
85
+ `task_inspect`; arbitrary shell strings are not classified as read-only.
86
+ Unidentified child execution cannot inherit a parent's run. Delegation is denied
87
+ on paths where distinct child tool identities cannot be established.
88
+
89
+ Hooks are not execution isolation. Unsupported tool paths, disabled/untrusted
90
+ hooks, adapter startup failures and already running processes remain outside
91
+ complete enforcement. In particular, `write_stdin` does not repeat PreToolUse.
92
+ Stop cannot retract text already emitted; an incomplete report stops with an
93
+ explicit message instead of generating unlimited continuation turns. Interrupt
94
+ never requests continuation. Unknown execution result formats stay unknown.
95
+ In a local test with **codex-cli 0.153.4**, Bash PostToolUse supplied stdout as
96
+ a string (empty for `true`) and no exit-status field. That path cannot produce
97
+ observed passing evidence: stdout, JSON printed by a command, and text resembling
98
+ an exit header are never trusted as completion metadata. The dedicated live test
99
+ therefore fails its required execution-observation check on that client. The
100
+ deterministic adapter fixture with structured exit metadata passes; it is not
101
+ evidence that the installed CLI or desktop exposes that metadata.
102
+ See the [official Codex hook protocol](https://developers.openai.com/ja-JP/docs/hooks).
103
+
104
+ ## Validation
105
+
106
+ `tests/integration/memory-assurance.test.ts` exercises the next-migration
107
+ counterexample, actual migration execution, failed/passing evidence, restart,
108
+ stale source and memory revisions, retries, cancellation, atomic refresh failure,
109
+ and the shared MCP/server decision path. Historical schema fixtures may retain
110
+ fixed versions; current-schema expectations derive from the bundled migration
111
+ snapshot in `tests/fixtures/current-migrations.ts`.
112
+
113
+ ```sh
114
+ npm run typecheck
115
+ npm test
116
+ npm run build
117
+ npm run test:evaluation
118
+ npm run test:sampledb
119
+ npm run test:global-install
120
+ npm run pack:check
121
+ node scripts/run-memory-assurance-live.mjs
122
+ ```
123
+
124
+ The dedicated CLI test exits nonzero when the required runtime or observations
125
+ are missing. Protocol fixtures, real CLI operation, desktop operation and
126
+ model memory-application quality are separate evidence. A CLI pass does not
127
+ establish desktop acceptance or a measured improvement in application rate.
@@ -0,0 +1,74 @@
1
+ -- New runs opt into assurance. Historical runs and delivery records are untouched.
2
+ CREATE TABLE task_assurance (
3
+ run_id TEXT PRIMARY KEY REFERENCES ledger_runs(run_id),
4
+ revision INTEGER NOT NULL DEFAULT 0 CHECK(revision >= 0),
5
+ delivery_id TEXT,
6
+ repository_root TEXT,
7
+ observed_changes INTEGER NOT NULL DEFAULT 0 CHECK(observed_changes IN (0, 1)),
8
+ retrieval_status TEXT NOT NULL DEFAULT 'pending',
9
+ updated_at TEXT NOT NULL
10
+ ) STRICT;
11
+ CREATE TABLE task_memory_reviews (
12
+ run_id TEXT NOT NULL REFERENCES task_assurance(run_id),
13
+ delivery_id TEXT NOT NULL,
14
+ entry_id TEXT NOT NULL REFERENCES entries(id) ON DELETE CASCADE,
15
+ entry_revision INTEGER NOT NULL,
16
+ decision TEXT NOT NULL CHECK(decision IN ('adopted','inapplicable','contradicted')),
17
+ basis TEXT NOT NULL,
18
+ invariant_text TEXT NOT NULL,
19
+ counterexample TEXT NOT NULL,
20
+ verification TEXT NOT NULL,
21
+ evidence_ids_json TEXT NOT NULL CHECK(json_valid(evidence_ids_json)),
22
+ created_at TEXT NOT NULL,
23
+ PRIMARY KEY(run_id, delivery_id, entry_id, entry_revision)
24
+ ) STRICT;
25
+ CREATE TABLE task_execution_evidence (
26
+ evidence_id TEXT PRIMARY KEY,
27
+ run_id TEXT NOT NULL REFERENCES task_assurance(run_id),
28
+ delivery_id TEXT,
29
+ repository_root TEXT NOT NULL,
30
+ cwd TEXT NOT NULL,
31
+ execution_digest TEXT NOT NULL,
32
+ state_digest TEXT NOT NULL,
33
+ outcome TEXT NOT NULL CHECK(outcome IN ('passed','failed','skipped','unknown')),
34
+ exit_code INTEGER,
35
+ provenance TEXT NOT NULL CHECK(provenance IN ('model_reported','client_observed')),
36
+ created_at TEXT NOT NULL
37
+ ) STRICT;
38
+ CREATE INDEX task_execution_evidence_run ON task_execution_evidence(run_id);
39
+ CREATE TABLE task_assurance_requests (
40
+ run_id TEXT NOT NULL REFERENCES task_assurance(run_id),
41
+ request_id TEXT NOT NULL,
42
+ request_digest TEXT NOT NULL,
43
+ response_json TEXT NOT NULL CHECK(json_valid(response_json)),
44
+ PRIMARY KEY(run_id, request_id)
45
+ ) STRICT;
46
+ CREATE TABLE codex_hook_requests (
47
+ identity_digest TEXT PRIMARY KEY,
48
+ repository_root TEXT NOT NULL,
49
+ run_id TEXT REFERENCES ledger_runs(run_id),
50
+ request_id TEXT NOT NULL,
51
+ state TEXT NOT NULL CHECK(state IN ('pending','bound','cancelled')),
52
+ stop_notified INTEGER NOT NULL DEFAULT 0,
53
+ last_event TEXT NOT NULL,
54
+ updated_at TEXT NOT NULL
55
+ ) STRICT;
56
+ CREATE TABLE codex_hook_tools (
57
+ identity_digest TEXT NOT NULL REFERENCES codex_hook_requests(identity_digest),
58
+ call_id TEXT NOT NULL,
59
+ run_id TEXT,
60
+ delivery_id TEXT,
61
+ input_digest TEXT NOT NULL,
62
+ state_digest TEXT,
63
+ evidence_id TEXT,
64
+ post_state_digest TEXT,
65
+ PRIMARY KEY(identity_digest, call_id)
66
+ ) STRICT;
67
+ CREATE TABLE codex_hook_observations (
68
+ observation_id TEXT PRIMARY KEY,
69
+ event_name TEXT NOT NULL,
70
+ tool_name TEXT,
71
+ response_shape TEXT NOT NULL,
72
+ decision TEXT NOT NULL,
73
+ observed_at TEXT NOT NULL
74
+ ) STRICT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiokuko",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Model-agnostic external memory for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -43,7 +43,8 @@
43
43
  "pack:check": "npm pack --dry-run",
44
44
  "prepublishOnly": "npm run typecheck && npm test && npm run build && npm run pack:check",
45
45
  "test:evaluation:akinator": "npm run build && node scripts/run-akinator-memory-evaluation.mjs",
46
- "test:benchmark:akinator": "npm run build && node scripts/run-akinator-memory-benchmark.mjs"
46
+ "test:benchmark:akinator": "npm run build && node scripts/run-akinator-memory-benchmark.mjs",
47
+ "test:memory-assurance:live": "npm run build && node scripts/run-memory-assurance-live.mjs"
47
48
  },
48
49
  "dependencies": {
49
50
  "@modelcontextprotocol/sdk": "^1.30.0",
@@ -54,7 +55,7 @@
54
55
  "zod": "^4.4.3"
55
56
  },
56
57
  "overrides": {
57
- "adm-zip": "0.6.0",
58
+ "adm-zip": "0.6.1",
58
59
  "sharp": "0.35.4"
59
60
  },
60
61
  "allowScripts": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memory-reasoning
3
- description: Use before Kiokuko task_prepare for a build or debug task, and whenever Kiokuko returns applicable stored memory. Convert recalled claims into verified premises, invariants, counterexamples, and regression tests before modifying code.
3
+ description: Use before Kiokuko task_prepare for code changes, code PLAN or code review, and whenever Kiokuko returns applicable stored memory. Convert recalled claims into verified premises, invariants, counterexamples, and regression tests before modifying code.
4
4
  ---
5
5
 
6
6
  <!-- KIOKUKO MANAGED STANDARD SKILL: memory-reasoning -->
@@ -15,11 +15,11 @@ repository, runtime, API, or other authoritative evidence before relying on it.
15
15
 
16
16
  ## Required workflow
17
17
 
18
- Before `task_prepare` for a build or debug task, read this Skill so the client can
18
+ Before `task_prepare` for code changes, code PLAN or code review, read this Skill so the client can
19
19
  truthfully advertise the exact local `memory-reasoning` capability. Setup
20
20
  placement alone is not that proof.
21
21
 
22
- When Kiokuko delivers ordinary memory for a build or debug task:
22
+ When Kiokuko delivers ordinary memory for code changes, code PLAN or code review:
23
23
 
24
24
  1. Identify the recalled claims that could change the implementation or review.
25
25
  2. Separate current evidence from memory-derived premises and label uncertainty.
@@ -35,6 +35,27 @@ When Kiokuko delivers ordinary memory for a build or debug task:
35
35
  evidence is enough.
36
36
  7. Prefer current verified evidence when it conflicts with recalled material.
37
37
 
38
+ ## Application record
39
+
40
+ When the tools are available, use `task_memory_status` and `task_memory_review`
41
+ for the memories selected as applicable. Record adoption with current source or
42
+ reproduction evidence, an invariant, counterexample and verifier. Explain
43
+ inapplicability or contradiction instead of mechanically adopting every result.
44
+ The record is a model declaration, never automatic proof of correctness.
45
+
46
+ For code changes, obtain a target state digest before running validation. Link
47
+ passing `task_execution_evidence` IDs, or evidence returned by the Codex hook,
48
+ back to the review. Public evidence is model-reported; only the hook adapter
49
+ records client observation. Failed, skipped, unknown and stale results do not
50
+ satisfy completion. PLAN and review require the reasoning record, not execution
51
+ of implementation tests. Reconfirm affected reviews after a memory revision or
52
+ delivery changes. Use `task_memory_refresh` for newly discovered paths/errors
53
+ within the existing run and its capability/scope binding.
54
+
55
+ Save a correction through existing `memory_capture` with its exact entry ID and
56
+ revision, trigger, invariant, counterexample and validation result. Do not invent
57
+ a new capture channel or promote unverified records.
58
+
38
59
  ## General conversation
39
60
 
40
61
  Read this Skill before advertising it to `memory_recall`. Use retrieved