Skip to content

feat(autonomy): carry decision policies on the semi mode commands (#2253 Bolt semi-policy-carrier) - #2316

Merged
j5ik2o merged 6 commits into
mainfrom
bolt-semi-policy-carrier
Aug 6, 2026
Merged

feat(autonomy): carry decision policies on the semi mode commands (#2253 Bolt semi-policy-carrier)#2316
j5ik2o merged 6 commits into
mainfrom
bolt-semi-policy-carrier

Conversation

@j5ik2o

@j5ik2o j5ik2o commented Aug 5, 2026

Copy link
Copy Markdown
Member

概要

Intent 260805-semi-redefine-autonomy-f(Issue #2253)の Construction Bolt semi-policy-carrier(swarm batch 2)。set-autonomy --mode semi が受理した decision policies を無音破棄せず搬送・永続化する。

  • C8: semi mode コマンドへの policies 搭載 — state 遷移の after.semiPolicies へ載せる(withSemiPolicies は不在時 delete 方式)。SEMI_POLICY_SCOPE_ID = "intent" を単一定数化
  • C9: nonFullCommandDisplayDigest の 1 定義化と digest 照合(Q1 裁定準拠)
  • C10: 不正 policies の loud ガード(従来の「exit 0 のまま黙って捨てる」契約穴を封鎖)
  • C15: policyCount の表示投影

積み上げ(stacked PR)

本 PR は batch 1 の 3 PR(#2293 / #2294 / #2295)のマージコミット(2c0221d3f で 3 bolt ブランチを統合)を base に持つ。batch 1 の 3 PR が先にマージされるまで diff に batch 1 のコミットが含まれる。 マージ順: #2293/#2294/#2295 → 本 PR(着地後に再接地予定)。

テスト

  • tests/unit/t454-semi-policy-carrier.test.ts(新規)
  • tests/integration/t455-semi-policy-cli.integration.test.ts(新規、CLI 面)

検証(builder 実測)

build 0(drift なし)/ typecheck 0 / lint 0 / complexity 0 / registry 0 / source-only 0 / full bash tests/run-tests.sh --ci PASS(853 files)。referee amadeus-swarm check converged / finalize(batch 3)converged。

申告(レビュー観点)

  • SEMI_POLICY_SCOPE_ID = "intent" は実装時導出(FD に明示逐語なし)
  • policies: [] を既存 6 呼び出し面へ追加(シグネチャ伝播)
  • t455 は Red 非先行(実装後固定 — TDD 逸脱の申告)

既知の外部ブロッカー

「No silent drop (trusted base ratchet)」は main 側 reconcile の連続失敗(#2313)により本 PR と無関係に赤になる。#2313 解消待ち。

Refs #2253


Note

High Risk
Changes intent autonomy authorization, policy persistence, audit digests, and launch/orchestrate entry points—areas where mistakes could auto-approve workflow decisions or weaken provenance checks.

Overview
Semi mode now persists decision policies on the autonomy projection (semiPolicies), with one normalization path and nonFullCommandDisplayDigest so human confirmation matches what gets stored. set-mode / revoke-full commands carry raw policy inputs; non-empty sets require a matching confirmed digest. amadeus-bolt set-autonomy rejects --policies-file with --mode none.

Semi authorization is reworked around SemiAuthority (replacing the old semi-mode-gate shortcut): production supplies a semiScope, authorizeInteraction returns semi-authority, and routine stage-gates and questions can auto-decide under semi while milestones (walking skeleton, phase boundaries) stay human. The decision ladder uses a shared DecisionAuthority; policyCount in status counts grant or semi policies.

Launch-time --autonomy is parsed in parseNextFlags / takeAutonomyFlag and applied via applyLaunchAutonomyDeclaration (fail-closed on unreadable projection, no silent grant revoke, no overwriting an already human-declared mode). The statusline appends @none|semi|full from autonomySegment (FR-DISP-1).

Reviewed by Cursor Bugbot for commit a627277. Configure here.

Summary by CodeRabbit

  • 新機能
    • 半自律モードで意思決定ポリシーを設定・保存できるようになりました。
    • ポリシーに基づき、対象範囲や効果を確認したうえで自動判断できるようになりました。
    • 自律性ステータスに、適用中のポリシー数が正しく表示されます。
  • バグ修正
    • none モードでポリシーファイルを指定した場合、読み込み前にエラーを表示します。
    • 権限や監査リプレイ後のポリシー表示・確認結果の整合性を改善しました。
  • テスト
    • 半自律ポリシー、CLI操作、状態表示に関する検証を追加しました。

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c29433c8-8156-40c6-bc73-f8c26291b28f

📥 Commits

Reviewing files that changed from the base of the PR and between 873ce1d and 94bb0c7.

📒 Files selected for processing (17)
  • packages/framework/core/tools/amadeus-bolt.ts
  • packages/framework/core/tools/amadeus-intent-autonomy-production.ts
  • packages/framework/core/tools/amadeus-intent-autonomy-runtime.ts
  • packages/framework/core/tools/amadeus-intent-autonomy.ts
  • packages/framework/core/tools/amadeus-utility.ts
  • tests/.coverage-patch-allowlist.json
  • tests/.coverage-registry.json
  • tests/integration/t-coverage-mechanism-ratchet.test.ts
  • tests/integration/t432-intent-autonomy-runtime.integration.test.ts
  • tests/integration/t453-semi-ladder-runtime.integration.test.ts
  • tests/integration/t455-semi-policy-cli.integration.test.ts
  • tests/no-silent-drop/baseline.json
  • tests/no-silent-drop/exemptions.json
  • tests/unit/t431-intent-autonomy.test.ts
  • tests/unit/t451-semi-authority.test.ts
  • tests/unit/t452-authorize-interaction-semi.test.ts
  • tests/unit/t454-semi-policy-carrier.test.ts

📝 Walkthrough

Walkthrough

半自律ポリシーを保存・正規化し、スコープ付き権限でゲート、質問、エフェクトを判定します。非フルモードの確認ダイジェストとCLI制約を更新し、ポリシー数を投影状態から表示します。単体・統合テストで保存、監査リプレイ、拒否、状態表示を検証します。

Changes

Intent 自律性

Layer / File(s) Summary
半自律ポリシーと権限契約
packages/framework/core/tools/amadeus-intent-autonomy.ts, tests/unit/t454-semi-policy-carrier.test.ts
set-moderevoke-full がポリシー入力を受け取り、正規化済みポリシーを投影へ保持します。確認ダイジェストとポリシー不一致の拒否を追加しました。
認可付き意思決定の実行
packages/framework/core/tools/amadeus-intent-autonomy-runtime.ts, tests/unit/t431-intent-autonomy.test.ts, tests/unit/t451-semi-authority.test.ts, tests/unit/t452-authorize-interaction-semi.test.ts, tests/integration/t432-intent-autonomy-runtime.integration.test.ts, tests/integration/t453-semi-ladder-runtime.integration.test.ts
semiScope を意思決定へ渡し、半自律権限でゲート、質問、可逆エフェクトを判定します。承認失敗時は人間対応を返し、成功時はエフェクトを直接適用します。
CLI制約と状態表示
packages/framework/core/tools/amadeus-intent-autonomy-production.ts, packages/framework/core/tools/amadeus-bolt.ts, packages/framework/core/tools/amadeus-utility.ts, tests/integration/t455-semi-policy-cli.integration.test.ts, tests/.coverage-*.json, tests/integration/t-coverage-mechanism-ratchet.test.ts, tests/no-silent-drop/*.json
非フルコマンドがポリシーを保持し、表示ダイジェストへ含めます。none--policies-file の併用を拒否します。状態表示は投影由来の policyCount を使用します。CLI、監査リプレイ、状態表示の統合テストを追加しました。

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • amadeus-dlc/amadeus#2317: 同じ半自律認可とスコープ処理を変更し、Stop hook の質問処理を拡張しています。
  • amadeus-dlc/amadeus#2318: 同じ自律性モジュールと半自律判定を変更し、advisory の自動解決を拡張しています。
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、semi モードのコマンドで決定ポリシーを保持する主要変更を明確に示しています。

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/framework/core/hooks/amadeus-statusline.ts`:
- Line 334: Update the Completed/Complete status branch in the status-line
rendering flow to pass its output through withAutonomySegment before calling
printLine, matching the existing behavior at the later printLine call. Preserve
the branch’s current completion output and early return while ensuring valid
Intent Autonomy Mode values render `@semi`, `@full`, or `@none`.

In `@packages/framework/core/tools/amadeus-intent-autonomy-production.ts`:
- Around line 487-488:
「Scope」の解決ロジックがgrantScopeと半自律処理で重複しているため、getField(input.stateContent, "Scope")
??
"intent"を小さな共有ヘルパへ抽出してください。grantScopeと487行付近のscopeId生成の両方でそのヘルパを使用し、既定値が常に一致するようにしてください。
- Around line 296-305:
半自律経路のスコープ識別子が状態由来の値になり、確認済みポリシーの照合に失敗しています。semiPoliciesAfter
が保存する値と一致するよう、semiAuthorityScope および commitProductionStageGateDecision
から半自律認可へ渡すスコープを SEMI_POLICY_SCOPE_ID に統一し、状態の Scope は grant 用の処理にのみ使用してください。

In `@packages/framework/core/tools/amadeus-intent-autonomy.ts`:
- Around line 602-635: Update SemiAuthority.fingerprint and its call in
SemiAuthority.of to incorporate the complete SemiAuthorityScope, including
allowedInteractionKinds, into the authority digest rather than only
scopeFingerprint. Preserve the existing mode provenance and policy inputs so
distinct scope permissions produce distinct authorityFingerprint and downstream
basisFingerprint values.
- Around line 363-371: Update the decision-side semiAuthorityScope handling in
commitProductionStageGateDecision to use SEMI_POLICY_SCOPE_ID instead of the
state Scope value, ensuring it matches the "intent" fingerprint used when
storing semi policies. Add a test that detects mismatched Scope values and
verifies the stored semi policy remains eligible for resolveConfirmedPolicy.

In `@tests/integration/t450-autonomy-flag-branch.test.ts`:
- Around line 126-133: Update the test around the “the freeform intent text
survives the flag” case so its assertions verify the behavior named by the test:
seed the required state and positively assert that the downstream directive
preserves the intended text, or rename the test to describe only that “semi” is
not interpreted as intent content and align the assertions with that narrower
behavior.

In `@tests/unit/t452-authorize-interaction-semi.test.ts`:
- Around line 241-249: Remove the source-inspection test named “the ladder entry
names no autonomy mode” from tests/unit/t452-authorize-interaction-semi.test.ts;
the existing authorization-required behavior test already covers the intended
resolveAutoDecision behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d9a7578b-9f29-48ea-89c1-63103a2f4b50

📥 Commits

Reviewing files that changed from the base of the PR and between 00da4bd and a627277.

📒 Files selected for processing (23)
  • packages/framework/core/hooks/amadeus-statusline.ts
  • packages/framework/core/tools/amadeus-bolt.ts
  • packages/framework/core/tools/amadeus-intent-autonomy-production.ts
  • packages/framework/core/tools/amadeus-intent-autonomy-runtime.ts
  • packages/framework/core/tools/amadeus-intent-autonomy.ts
  • packages/framework/core/tools/amadeus-lib.ts
  • packages/framework/core/tools/amadeus-orchestrate.ts
  • packages/framework/core/tools/amadeus-utility.ts
  • tests/.coverage-patch-allowlist.json
  • tests/.coverage-ratchet.json
  • tests/.coverage-registry.json
  • tests/integration/t-coverage-mechanism-ratchet.test.ts
  • tests/integration/t432-intent-autonomy-runtime.integration.test.ts
  • tests/integration/t450-autonomy-flag-branch.test.ts
  • tests/integration/t453-semi-ladder-runtime.integration.test.ts
  • tests/integration/t455-semi-policy-cli.integration.test.ts
  • tests/unit/t431-intent-autonomy.test.ts
  • tests/unit/t448-autonomy-statusline-segment.test.ts
  • tests/unit/t449-autonomy-flag-parse.test.ts
  • tests/unit/t450-autonomy-flag-apply.test.ts
  • tests/unit/t451-semi-authority.test.ts
  • tests/unit/t452-authorize-interaction-semi.test.ts
  • tests/unit/t454-semi-policy-carrier.test.ts

if (agentDisplay) output += ` -- ${agentDisplay}`;

printLine(output, right);
printLine(withAutonomySegment(output, state), right);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

完了状態にも自律性セグメントを適用してください。

status === "Completed" || status === "Complete" の分岐は、Line 324 で直接 printLine を呼び、Line 334 より前に return します。
そのため、有効な Intent Autonomy Mode を持つ完了済み Intent は @semi@full、または @none を表示しません。完了時の出力も withAutonomySegment を通してください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/framework/core/hooks/amadeus-statusline.ts` at line 334, Update the
Completed/Complete status branch in the status-line rendering flow to pass its
output through withAutonomySegment before calling printLine, matching the
existing behavior at the later printLine call. Preserve the branch’s current
completion output and early return while ensuring valid Intent Autonomy Mode
values render `@semi`, `@full`, or `@none`.

Comment thread packages/framework/core/tools/amadeus-intent-autonomy-production.ts
Comment thread packages/framework/core/tools/amadeus-intent-autonomy-production.ts
Comment thread packages/framework/core/tools/amadeus-intent-autonomy.ts
Comment thread packages/framework/core/tools/amadeus-intent-autonomy.ts
Comment on lines +126 to +133
test("the freeform intent text survives the flag", () => {
proj = createTestProject();
const { directive } = runNextInProcess(proj, ["--autonomy", "semi", "build", "the", "auth", "service"]);
// Judgment 0 (no state) refuses, but the parse that got here consumed the
// mode: nothing downstream ever sees "semi" as intent words.
expect(directive.kind).toBe("error");
expect(String(directive.message)).not.toContain("semi build");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

このテストはテスト名の性質を検証していません。

テスト名は「freeform intent text がフラグを越えて生存する」と述べます。しかし状態ファイルが存在しないため、handleNext は Judgment 0 で error を返します。intent text の行き先は観測できません。残るのは not.toContain("semi build") という否定アサーションだけで、これは message に "semi" が単独で含まれても通ります。

状態ファイルを seed して intent text が下流に到達することを肯定的に検証するか、テスト名を実際の性質(モードが intent 語として解釈されないこと)に合わせてください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/t450-autonomy-flag-branch.test.ts` around lines 126 - 133,
Update the test around the “the freeform intent text survives the flag” case so
its assertions verify the behavior named by the test: seed the required state
and positively assert that the downstream directive preserves the intended text,
or rename the test to describe only that “semi” is not interpreted as intent
content and align the assertions with that narrower behavior.

Comment on lines +241 to +249
test("the ladder entry names no autonomy mode", () => {
const source = Bun.file("packages/framework/core/tools/amadeus-intent-autonomy.ts");
return source.text().then((text) => {
const body = text.slice(text.indexOf("export function resolveAutoDecision("));
const functionBody = body.slice(0, body.indexOf("\nexport type EffectAuthorization"));
expect(functionBody).not.toContain('mode !== "full"');
expect(functionBody).toContain('reason: "authorization-required"');
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

ソース文字列を読むメタテストは脆弱です。削除を推奨します。

問題は3点です。

  1. Bun.file に相対パスを渡すため、テストの CWD がリポジトリルート以外だと失敗します。
  2. body.indexOf("\nexport type EffectAuthorization") が該当シンボルを見つけられない場合、戻り値は -1 です。slice(0, -1) は末尾1文字だけを落とすため、functionBody がファイルのほぼ全体になります。アサーションは無言で緩みます。
  3. 実装のリファクタで容易に壊れます。

resolveAutoDecision が自律モードを見ないという性質は、220-225行の authorization-required テストが既に振る舞いとして検証しています。このテストは不要です。

♻️ 削除案
-  test("the ladder entry names no autonomy mode", () => {
-    const source = Bun.file("packages/framework/core/tools/amadeus-intent-autonomy.ts");
-    return source.text().then((text) => {
-      const body = text.slice(text.indexOf("export function resolveAutoDecision("));
-      const functionBody = body.slice(0, body.indexOf("\nexport type EffectAuthorization"));
-      expect(functionBody).not.toContain('mode !== "full"');
-      expect(functionBody).toContain('reason: "authorization-required"');
-    });
-  });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test("the ladder entry names no autonomy mode", () => {
const source = Bun.file("packages/framework/core/tools/amadeus-intent-autonomy.ts");
return source.text().then((text) => {
const body = text.slice(text.indexOf("export function resolveAutoDecision("));
const functionBody = body.slice(0, body.indexOf("\nexport type EffectAuthorization"));
expect(functionBody).not.toContain('mode !== "full"');
expect(functionBody).toContain('reason: "authorization-required"');
});
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/t452-authorize-interaction-semi.test.ts` around lines 241 - 249,
Remove the source-inspection test named “the ladder entry names no autonomy
mode” from tests/unit/t452-authorize-interaction-semi.test.ts; the existing
authorization-required behavior test already covers the intended
resolveAutoDecision behavior.

j5ik2o added 6 commits August 6, 2026 10:31
The semi arms of HumanAutonomyCommand now take raw policy inputs and
planHumanAutonomyCommand owns the single normalization call, seeded by the
command occurrence. nonFullCommandDisplayDigest folds the policy set into one
confirmation digest for both non-full previews, and a carried set has to match
the digest the human confirmed. The --status Policies line reads a
grant-independent count so a semi Intent no longer reports zero.
t454 covers the write-side table, the digest definition and the three
confirmation branches; t455 drives the same path through the CLI, the audit
replay and the status render. The existing autonomy suites gain the new
required field on their set-mode commands and keep their assertions.
The new integration test spawns the bolt and utility CLIs, so it joins the
none-to-cli reclassification set and the regenerated coverage registry.
The Policies line now reads the grant-independent count, which changes the
function's source fingerprint. The waived range is unchanged at 13 lines.
…ution

The guard body is only reachable through a CLI spawn, which Bun does not
attribute to the parent report. Collapsing it onto the predicate line matches
the sibling --mode guard and keeps the arm out of the patch population.
@j5ik2o
j5ik2o force-pushed the bolt-semi-policy-carrier branch from 7f8c458 to 94bb0c7 Compare August 6, 2026 01:32
@j5ik2o
j5ik2o marked this pull request as ready for review August 6, 2026 01:48
@j5ik2o
j5ik2o merged commit d3c5388 into main Aug 6, 2026
15 checks passed
@j5ik2o
j5ik2o deleted the bolt-semi-policy-carrier branch August 6, 2026 01:48
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

j5ik2o added a commit that referenced this pull request Aug 6, 2026
… (#2372)

Bring the workflow record for #2253 onto main: the build-and-test stage's seven
artifacts, the construction phase-boundary check, the goal reconciliation items
and receipt, the appended audit shard, and the terminal state. The registry row
advances in-flight → complete.

Implementation for this intent already landed in seven PRs (#2293, #2294, #2295,
#2316, #2317, #2318, #2321); this commit carries the record only — no source or
test changes.

Evidence recorded in the artifacts (measured on the conductor clone, values
transcribed from command output):
- bash tests/run-tests.sh --ci: exit 0, RESULT: PASS (11,494 pass / 0 fail)
- build / typecheck / lint / source-only:check / complexity-gate: exit 0
- declared sensors on the seven artifacts: FIRED 14 / PASSED 14 / FAILED 0
- requirement traceability: 33 of 33 ids trace into the construction tree
- formal-model-check: NOT_DETECTED (correlated run, no counterexample)
- goal reconciliation: goal-statement ACHIEVED over 14 digest-verified refs

The audit shard is a pure append over main's copy (main's bytes verified as a
byte-exact prefix); the registry keeps every other row untouched.

Refs #2253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant