Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Code Generation Plan — autonomy-review-observability

## スコープと追跡元

U4 `autonomy-review-observability`(Issue #2067)だけを `self-feature` として実装する。正本は U4 の Functional / NFR Design と U3 が提供する immutable autonomy projection である。active / completed Intent の自動判断一覧・詳細・未レビューqueue、人間本人による accept / flag、completed seal を保持する限定append、status、Event Registry / OTel provenance を一つの harness-neutral Core で閉じる。

Claude Code、Codex、Cursor、OpenCode、Kimi Code は同じ Core を利用し、eligibility、redaction、review authorization、remediation分類をharness別に複製しない。配布物は package generator から生成し、`dist/` を直接編集しない。

## 実装計画

- [x] **Step 1 — decision read model**: explicit Intent UUID と lifecycle から U3 の canonical projection を読み、eligible decision の一覧・詳細・未レビューqueueを構築する。decision IDからIntentを逆引きせず、raw evidence / prompt / secretを公開しない。
- [x] **Step 2 — snapshot-bound pagination**: query fingerprint、target audit revision、completed review extension head、projection event-set digestへcursorを束縛し、page間driftを `CONFLICT(cursorSnapshot)` で拒否する。
- [x] **Step 3 — real-human authorization**: canonical `HUMAN_TURN` とreview command bindingをsource Intentから直接再検証する。active targetは同一Intent、completed targetは現在のactive Intentをsource contextとし、synthetic / missing / stale provenanceを拒否する。
- [x] **Step 4 — terminal review append**: accept / flagを `AUTO_DECISION_REVIEWED` としてappendし、same choiceをidempotent、different choiceをterminal conflictにする。completed targetではcompletion sealを変更せず、denseなreview extension chainだけを進める。
- [x] **Step 5 — safe remediation**: flagは分類に応じて `self-fix`、`self-feature`、または `self-fix-with-feature-alternative` を提案するだけに留める。rollback、effect replay、grant変更、新規Intent生成を行わない。
- [x] **Step 6 — persistence / replay**: canonical payload digest、event identity、transaction、projection revision、extension chainを検証してsnapshotをreloadし、session / process / compaction / clone後もqueueとterminal receiptを再構築する。改変はfail-closedにする。
- [x] **Step 7 — status / telemetry**: human / machine statusを同じprojectionから組み立て、completed workflowをterminalのまま保持する。`AUTO_DECISION_REVIEWED` を canonical audit vocabulary の85件目としてEvent Registry、OTel attribute、audit formatへ同期する。
- [x] **Step 8 — shared projection**: Coreとregistry変更を package generator で全7生成treeへ反映し、現行5 self-install harnessへpromoteする。5 harness contractではexactly-once cohortと共通algorithmを検証する。
- [x] **Step 9 — verification**: focused test、Event Registry drift、typecheck、Biome、coverage、全体 `test:ci`、重いsuiteの個別再実行、package / promote drift、`git diff --check` を実測する。
- [x] **Step 10 — convergence follow-up**: 親再検証で検出された `t81` のaudit event count assertion漏れを統合側で85へ修正し、U4成果物に事実を記録する。

## 非目標

U5 の credential-attested terminal live completion、workflow completion判定、rollback、自動remediation実行、自動Intent生成、PR / merge / GitHub semantics、外部runner / supervisor、harness固有Core、U3 projectionの再実装は対象外とする。レビューqueueは中断点を増やさず、既存autonomy flowを途中でblockingしない。

## 検証基準

- focused U4 behaviorとEvent Registry driftがgreenである。
- 新規Coreのcoverageを計測し、主要なlist / detail / review / reload / status経路を通す。
- `bun run typecheck`、対象Biome check、`bun scripts/package.ts --check`、`bun run promote:self:check` がgreenである。
- default timeoutで失敗した重い5ファイルは120秒timeoutで個別再実行し、U4由来failureか環境・wall-clock由来かを切り分ける。
- 実装commitと親統合側の追補修正を区別し、未修正事項を隠さない。
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Code Summary — autonomy-review-observability

## 実装結果

U4 `autonomy-review-observability`(Issue #2067)を、U3 immutable autonomy projectionを消費する harness-neutral Core として実装した。active / completed Intent の自動判断を同じread modelで一覧・詳細表示し、未レビューqueue、real-human accept / flag、completed sealを保持する限定review extension、status / telemetry、永続snapshot reloadを追加した。実装commitは `6cdfcae8005c9d33d825f53ff506fa80a9f4fdc9`(`feat(autonomy): add decision review observability`)である。

## 主な変更

- `packages/framework/core/tools/amadeus-autonomy-review.ts`
- decision list / detail、redaction、review eligibility、snapshot-bound cursorを実装した。
- canonical human turnをsource Intentから再検証し、active targetの同一Intent reviewとcompleted targetのactive-source reviewを認可する。
- accept / flagのterminal append、same-choice idempotency、different-choice conflictを実装した。
- completed completion sealを変更せず、review eventだけを別extension chainへappendする。
- snapshot export / reload時にpayload digest、event identity、projection revision、extension headを検証し、改変を拒否する。
- human / machine status、safe Event Registry fields、safe OTel attributes、5 harness共通contractを公開する。
- `packages/framework/core/tools/amadeus-audit.ts`、`packages/framework/core/otel/event-registry.ts`、`packages/framework/core/knowledge/amadeus-shared/audit-format.md`
- `AUTO_DECISION_REVIEWED` を canonical 85件目のaudit eventとして追加し、event name、required / optional attributes、audit formatを同期した。
- `tests/unit/t433-autonomy-review-observability.test.ts`
- active / completed queue、cursor drift、redacted detail、real-human provenance、completed seal保持、tamper reject、synthetic reject、idempotency / conflict、completed status、safe telemetry、exact 5 harness cohortを検証した。
- package generatorにより Claude Code、Codex、Cursor、OpenCode、Kimi Code、Kiro、Kiro IDE の全7生成treeを同期し、現行5 self-install harnessへ共通Coreをpromoteした。

## 安全境界と非目標

- flagは `self-fix` / `self-feature` の提案だけを返し、rollback、選択effectの再実行、grant変更、新規Intent生成を行わない。`createdIntentCount` は常に0である。
- completed review後もworkflowはcompleted / terminalのままであり、completion sealを再計算しない。
- review queueは観測・事後レビュー用であり、既存autonomy flowへ新しいmid-flow gateを追加しない。
- PR / merge / GitHub semantics、外部runner / supervisor、U5 terminal live completionはCoreへ含めていない。
- U3のdecision projectionを入力正本とし、U4に別のdecision authorityを作っていない。

## 検証結果

- focused U4 test: 10 tests / 29 expects、全件pass。
- Event Registry driftを含むfocused suite: 36 tests / 579 expects、全件pass。
- focused coverage: 新規 `amadeus-autonomy-review.ts` は Functions 91.18%、Lines 87.24%。依存するU3 moduleを含む合算値ではなく、新規U4 module単体の値である。
- `bun run typecheck`: pass。
- 新規source / testへのtargeted Biome check: warning / errorともに0。
- `bun run lint`: exit 0。repository既存baselineとして398 warnings / 23 infosが出たが、新規U4 fileにはwarningなし。
- `bun scripts/package.ts --check`: Claude / Codex / Cursor / Kimi / Kiro / Kiro IDE / OpenCode の全7生成treeでpass。
- `bun run promote:self:check`: Claude Code / Codex / Cursor / OpenCode / Kimi Code の現行5 self-install harnessでpass。
- `git diff --check`: pass。

## 全体CIとdefault timeoutの切り分け

`bun run test:ci` は765 test filesを完走したが、default timeout / wall-clock driftとして次の5ファイル、合計7 assertionsが失敗した。

- `tests/integration/t-codex-hooks-migration.test.ts`
- `tests/integration/t-solo-standing-grant-opencode-mint.test.ts`
- `tests/integration/t225-upstream-v2-migration-preflight.test.ts`
- `tests/smoke/t05-run-tests-parallel.test.ts`
- `tests/unit/t17.test.ts`

この5ファイルを `bun test --timeout 120000` でまとめて再実行した結果は 212 pass / 1 skip / 0 fail、2,302 expects だった。skipはinvalid UTF-8 path bytesを扱う環境依存caseである。したがってdefault runの5件はU4 behaviorの回帰ではなく、既知の重いsuiteの時間制約として切り分けた。AWS credentials無効時のlive SDK / substrate testもrunner規則どおりskipされた。

## 親再検証で判明した追補修正

U4実装commitでは `t81` のaudit event count説明を85へ更新した一方、実assertion `expect(count).toBe(84)` の更新が漏れていた。親の再検証がこの不整合を検出し、親統合commit `5a1851593ed297f0942b63affac81a4be8bc8903`(`fix(autonomy-review): update audit count assertion`)で `expect(count).toBe(85)` へ修正済みである。本Boltでは親commitを取り込まず、コードを追加変更せず、収束事実だけを記録する。

## 残作業

U4の実装残はない。後続のU5はU4のreview / status projectionを消費するため、U4統合後に開始する。U5のterminal completion実装や検証はこの成果物の対象外である。
Loading
Loading