Skip to content

実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "controller-owned actual AGY invocation trusted boundary"
change_kind: workflow

Parent Issue

なし(単独改善)。本 Issue は分割しない。

Parent Goal Ref

  • Goal: caller-supplied delegation result ではなく controller-owned actual invocation を唯一の production trust boundary にする。
  • Destination: advisory の controller-owned operational/provider availability failure は fallback、request/policy/permission violation・不整合・explicitly_required failure は fail-close。

Current Validated Scope

Remaining Parent Gaps

  • AGY OAuth、credential/keyring/config、retry、実 provider availability/behavior は変更しない。crypto signature、persistent DB、self-declared provenance/flag、taxonomy mirror/positive allowlist、consumer-side full schema duplicate は trusted boundary の代替にしない。

Outcome

Public controller accepts only exact AGY_ADVISORY_INVOCATION_REQUEST_V1: schema: "AGY_ADVISORY_INVOCATION_REQUEST_V1", schema_version: 1, mode: "codebase_local_asset", nonempty purpose, nonempty repo-relative target_paths list, optional repo-relative context_paths list, and agy_investigation_requirement: advisory|explicitly_required. No public field accepts raw prompt, wrapper result/output path/projection, failure class, provenance, or old opt-in flag. Before spawn it validates requirement and fields and resolves every public local target/context path from the controller repository root. It rejects an absolute path, any .. traversal, a normalized/resolved target outside that root (including a symlink resolving outside it), a non-regular or nonexistent file, and a request exceeding 32 combined paths, 1 MiB per file, or 4 MiB aggregate. Validated target_paths and context_paths use the sole canonical target-first/context-second --context-file serialization specified below; neither can select an output or executable path.

Every production actual-wrapper spawn uses a controller-owned child environment with AGY_BIN removed. No public CLI/API field, request value, or AGY_BIN environment value can select the executable. The wrapper resolves the literal agy command through its inherited deployment PATH; that PATH and installed binary identity are explicitly deployment-boundary concerns outside the caller-provenance guarantee, not public controller inputs. Only a module-private/test-only invocation seam can inject an AGY_BIN fake; public request mode/CLI/API cannot reach it. The sole new module-private fixed-proposal_only actual-wrapper smoke driver deterministically reaches that fake, shares controller-owned builder → wrapper → exact-output readback → decision core, changes no production local_asset_research profile, and replaces the retired legacy composed smoke.

The controller uses private TemporaryDirectory request/output paths and argv lists, shell=False, bounded subprocesses: canonical builder → actual wrapper → exact same-invocation output readback including nonzero → minimal projection → shared internal pure decision core. Before parsing, it reads at most 1 MiB of the controller-owned wrapper result file; oversize, partial, unreadable, or strict-JSON-invalid output (including a duplicate key) yields only failed/fail_closed, no sidecar, and no native fallback. A local-asset failure before _run_agy (e.g. Serena), or any non-AGY/pre-AGY result, is explicit failed/fail_closed, never operational fallback.

The canonical run_gemini_headless.py normalizer emits producer-owned agy_failure_kind and agy_invocation_attempted: boolean on every AGY delegation_result/v1 output. Attempted transitions to true through a producer-owned pre-exec callback immediately before the actual agy -p subprocess execution, and remains false for validation, Serena, policy-before-exec, and every pre-AGY result. Success is attempted:true/kind:null; actual attempted failure is attempted:true/non-null kind; pre/non-AGY is attempted:false. The producer alone exports canonical_agy_failure_kind(failure_class) -> operational|policy_or_permission|contract|null: it returns the canonical kind only for producer-defined actual agy_* values and null for unknown/non-AGY values. The controller invokes it without mirroring taxonomy and requires its non-null returned kind to exactly equal the readback agy_failure_kind; unknown, malformed, or kind/class-inconsistent pairs fail closed. For a success result only, it also requires actual readback response_text to be a nonempty string of at most 256 KiB UTF-8; the controller copies that exact same-invocation value byte-for-byte into the success sidecar and must not generate, substitute, truncate, or reconstruct it from caller input. The sidecar envelope is controller-produced, while its response_text is invocation-derived untrusted research content. Fallback requires attempted:true, the canonical pair to be operational, and a valid actual agy_*; all other values fail closed. The existing explicit deny fields remain deny behavior; no taxonomy mirror, positive allowlist, or full producer-schema duplicate is introduced.

AGY_ADVISORY_FALLBACK_ROUTE_DECISION_V1 is exact closed stdout JSON, not taxonomy SSOT: exactly schema: "AGY_ADVISORY_FALLBACK_ROUTE_DECISION_V1"; schema_version: 1; status: ok|degraded|failed; next_action: continue_agy_result|native_non_mutating_fallback|fail_closed; failure_class: null|string; reason_code: controller_input_invalid|builder_failed|wrapper_result_invalid|deny_policy|explicitly_required|non_agy_or_pre_agy|agy_success|advisory_operational. reason_code is routing-only. ok/continue_agy_result requires null failure_class; degraded/native_non_mutating_fallback requires nonempty actual agy_*; failed/fail_closed permits nullable. Other combinations, missing/extra keys, or invalid types are malformed. stdout is the UTF-8 encoding of exactly one strict duplicate-key-rejecting decision JSON object, optionally followed by one LF byte and with no other byte, diagnostic, or JSON value. On the same successful invocation only, stderr is the UTF-8 byte encoding of exactly one controller-owned AGY_ADVISORY_SUCCESS_RESULT_V1 JSON object, optionally followed by one LF byte and with no other bytes, diagnostics, child stderr, or JSON values. It has exactly schema: "AGY_ADVISORY_SUCCESS_RESULT_V1", schema_version: 1, and nonempty response_text: string; the response text is the <=256 KiB exact value projected from the validated same-invocation actual output, not a generated, substituted, truncated, or caller-reconstructed value. Strict parsing rejects duplicate keys. It is a narrow result delivery surface, not the raw wrapper result, projection, path, executable selection, or caller-supplied data. Non-ok decisions emit no success sidecar. Agent/caller captures stdout and stderr separately; it uses the sidecar only with an exact ok/continue_agy_result exit-0 decision, and treats a missing/multiple/malformed/unpaired sidecar or decision as fail-close/no native. Exit 0 is valid ok/degraded, exit 1 valid failed, exit 2 transport/runtime with no trusted decision. Agent/caller require exact closed decision plus allowed status/action/exit pairing; only degraded/native enables native. malformed/missing/multiple/exit2/unpaired always fail-close/no native.

  • target_paths (nonempty) and optional context_paths are validated as deduplicated ordered lists. The canonical builder argv appends every target_paths element in list order first as --context-file <resolved path>, then every context_paths element in list order as additional --context-file <resolved path>; duplicates across lists reject pre-spawn. This is the sole builder serialization, so target-only has at least one canonical context file and reaches local_asset_research. The fixed controller prompt includes target paths under Targets: and context paths under Additional context: but no raw caller prompt. Controller enforces the same existing local-asset downstream limits of 32 total files, 1 MiB each, and 4 MiB aggregate before spawn. Do not use evidence_targets and do not change build_request.py.

  • Existing agy_failure_kind contract is EXTENDED, never replaced, by producer-owned top-level agy_invocation_attempted: boolean for every AGY delegation_result/v1 output. It is true iff the producer-owned pre-exec callback has run immediately before canonical agy -p subprocess execution; it is false for validation, local_asset/Serena, policy-before-exec, and every other pre-AGY result. Success is attempted:true + kind:null; actual attempted failure is attempted:true + non-null kind; pre/non-AGY is false. agy_failure_kind remains null|operational|policy_or_permission|contract. Producer-owned canonical_agy_failure_kind(failure_class) returns the canonical kind only for known actual agy_* values; controller requires that returned non-null kind to equal the observed kind and never mirrors the taxonomy. Fallback requires attempted:true and an operational canonical pair; missing/nonbool/false attempt, unknown class, or other inconsistency always failclose.

  • Exact legacy adapter is at agent/issue-refinement-loop pre-controller compatibility ingress, not public controller: it accepts only optional agy_investigation_requirement strict enum and optional legacy agy_advisory_native_fallback_allowed strict boolean. requirement present + legacy absent -> requirement unchanged; requirement absent + legacy true -> advisory; requirement absent + legacy false -> explicitly_required; both absent -> explicitly_required; both present -> fail_closed, even if semantically same; any nonboolean legacy/type-invalid enum -> fail_closed. Adapter constructs exact V1 with requirement and deletes legacy; controller rejects legacy field/unknown keys. No other layer sees old flag.

Runtime Verification Applicability

decision: immediate
reason: "actual wrapper exact-output readback, shared decision core, and real codebase-investigator native sentinel require end-to-end evidence"
applicable_acs: [AC8]
execution_environment: "clean worktree; module-private fixed-proposal_only test driver with AGY_BIN fake; canonical builder; actual wrapper; shared controller core; real codebase-investigator. OAuth/network/provider are unnecessary"
skip_conditions: "Only unavailable SubAgent launch runtime may report exit 77 SKIP; artifact records reason"
fallback_policy:
  fallback_success_is_pass: false
  notes: "fake failure, unconsumed exact output, absent sentinel, mutation, or tracked-status change never becomes PASS"
artifact_requirements: ["tracked status before/after", "fake invocation evidence", "actual output consumption", "native sentinel"]

In Scope

  • Add public controller exact request validation, repository-root-contained target/context path validation with 32-combined-path, 1-MiB-per-file, and 4-MiB-aggregate limits plus mode mapping, fixed canonical prompt, and local_asset_research profile mapping.

  • Strip ambient AGY_BIN from production child env; reject public executable injection; allow fake only through module-private/test-only seam and fixed-proposal_only smoke driver sharing owned builder/readback/decision core.

  • Implement private paths → canonical builder → actual wrapper → exact nonzero-inclusive readback → projection → exact decision. Builder/request/pre-AGY/non-AGY failures fail-close.

  • Preserve legacy alias only as current compatibility ingress: one-way map only when requirement absent; dual input fail-close; requirement only downstream.

  • Update router, agent, loop caller, focused units, retire/delete the legacy composed smoke, and add the sole new actual-wrapper smoke. Native only on exact degraded/native with valid exit pairing.

  • Add canonical producer-owned agy_failure_kind, agy_invocation_attempted, and canonical_agy_failure_kind(failure_class) returning the exact known producer kind or null; controller consumes and pair-validates it without mirroring taxonomy. Enforce 1-MiB raw wrapper read limit and strict duplicate-key-rejecting parse for wrapper output, controller decision stdout, and success sidecar stderr. Preserve the small explicit deny set: advisory fallback is only for attempted actual producer-marked operational required agy_*; future operational classes require that explicit producer update, while policy/boundary classes are producer-marked policy_or_permission and fail-close with same-PR deny-set/controller-test updates. No taxonomy mirror, positive allowlist, full schema duplicate, or regex classification.

  • Implement the target-first/context-second sole --context-file serialization, fixed Targets:/Additional context: prompt, duplicate rejection, and matching 32-total-file/1-MiB-each/4-MiB-aggregate boundary acceptance/rejection tests without evidence_targets or build_request.py changes.

  • Implement producer run_gemini_headless.py top-level agy_invocation_attempted extension by wiring a producer-owned pre-exec callback immediately before the actual agy -p subprocess, and add focused timing coverage in test_agy_provider.py that proves callback-to-subprocess ordering, false pre-AGY behavior, and success/failure correlation; implement controller consumption and actual-wrapper smoke consumption.

  • Implement the exact five legacy mappings and controller rejection with focused units; old flag exists only at the named pre-controller ingress.

Out of Scope

  • build_request.py、failure taxonomy producer の変更(ただし canonical run_gemini_headless.py の最小 additive agy_failure_kind output とその producer test は In Scope)
  • OAuth、credentials/token、GH_CONFIG_DIR、keyring/config mutation、実 provider invocation/availability、retry redesign
  • crypto signature、persistent DB、self-declared provenance/flag、taxonomy mirror/positive allowlist、full schema duplicate、CODEBASE_INVESTIGATION_RESULT_V1 の変更、root control-plane routing、second smoke、新規 Issue、branch/PR/Issue 分割、native fallback 中の write/GitHub/Issue mutation

Acceptance Criteria

  • AC1: Public controller accepts only exact closed AGY_ADVISORY_INVOCATION_REQUEST_V1 fields/types: literal schema/version, fixed mode, nonempty purpose, nonempty target_paths, optional context_paths, requirement enum; raw prompt/result/output/projection/failure_class/provenance/old flag reject before spawn.

  • AC2: Before spawn, target_paths and context_paths are deduplicated ordered lists. Duplicates within/across lists, absolute paths, .., nonexistent/non-regular files, outside-root resolution/symlinks, and violations of 32 total files/1 MiB each/4 MiB aggregate reject. The sole builder serialization is targets first then contexts, each as --context-file <resolved path>; fixed Targets:/Additional context: prompt and unchanged builder profile are used.

  • AC3: Production wrapper child env strips AGY_BIN; no public CLI/API field, request value, or AGY_BIN environment value can select executable. Literal agy resolution through inherited PATH/installed identity is explicitly deployment-boundary behavior outside caller provenance. Focused proof covers AGY_BIN stripping and public injection rejection.

  • AC4: Private TemporaryDirectory → builder → actual wrapper (argv/shell=False/bounded) → at-most-1MiB exact output readback including nonzero → strict duplicate-key-rejecting parse → projection → shared deterministic core. Oversize, partial, unreadable, or malformed wrapper output and request/builder failures emit only failed/fail_closed, no sidecar, and no native fallback.

  • AC5: Focused unit proves production local_asset_research mapping and pre-_run_agy/non-agy result is failed/fail_closed, never operational fallback.

  • AC6: Canonical producer actual delegation_result/v1 output contains producer-owned agy_failure_kind and agy_invocation_attempted, plus sole canonical_agy_failure_kind(failure_class) returning the exact known producer kind or null. Attempted transitions true only through a producer-owned pre-exec callback immediately before the actual agy -p subprocess, and is false pre-AGY; success is attempted:true/kind:null and actual attempted failure is attempted:true/non-null kind. Controller invokes the classifier without a taxonomy mirror and requires its non-null result to equal observed kind. A successful response additionally requires actual same-invocation response_text to be nonempty and at most 256 KiB UTF-8; controller-focused tests prove the success sidecar copies that exact value only, rejects invalid/oversize text, and never generates, substitutes, truncates, or reconstructs it from caller input. Unknown, invalid, contradictory, false-attempt, non-AGY, or nonconforming values fail closed. Fallback requires attempted:true + canonical operational pair + actual agy_*; policy_or_permission, contract, and explicitly_required fail close.

  • AC7: stdout is exactly the UTF-8 bytes of one strict duplicate-key-rejecting closed decision JSON object, optionally followed by one LF and with no other byte, diagnostic, or second JSON value. On ok/continue_agy_result only, stderr is exactly the UTF-8 bytes of one closed AGY_ADVISORY_SUCCESS_RESULT_V1, optionally followed by one LF, with no other byte, diagnostic, child stderr, second JSON value, or duplicate key. It has only literal schema/version and a nonempty <=256 KiB response_text copied byte-for-byte from the validated actual same-invocation success output; it is untrusted research content, and controller never generates, substitutes, truncates, or reconstructs it from caller input. No raw wrapper result/projection/path/caller data is delivered. Non-ok emits no sidecar. Agent/caller capture streams separately, require the exact exit-0 ok/continue + strict-sidecar pairing before consuming the success text, and reject malformed/missing/multiple/unpaired output; native remains permitted only by exact degraded/native. Exit 0 only valid ok/degraded, exit 1 only valid failed, exit 2 no trusted decision.

  • AC8: The sole new actual-wrapper smoke uses module-private fixed-proposal_only driver and AGY_BIN fake through shared builder→canonical producer wrapper→exact-output (including agy_failure_kind and agy_invocation_attempted)→decision core before real codebase-investigator/native sentinel; proves fake evidence, ambient strip, public injection rejection, private seam core, producer discriminator consumption, unchanged tracked status/no mutation. The old legacy smoke is retired/deleted; no second smoke/harness; exit77 is SKIP not PASS; no OAuth/provider/network/keyring/config mutation or credential artifact.

  • AC9: Focused controller tests prove target/context ordered serialization, duplicate rejection within/across lists, target-only canonical context reachability, fixed prompt sections/no raw caller prompt, and matching local-asset 32/1MiB/4MiB boundary acceptance/rejection; no evidence_targets or build_request.py change.

  • AC10: run_gemini_headless.py wires producer-owned agy_invocation_attempted transition through a pre-exec callback immediately before the actual agy -p subprocess, and focused test_agy_provider.py timing coverage proves callback-to-subprocess ordering, false pre-AGY behavior, and success/attempted-failure correlation; controller and actual-wrapper smoke consume both fields and fallback only for attempted:true + operational + actual agy_*.

  • AC11: Focused units prove all five exact legacy mappings at agent/issue-refinement-loop pre-controller ingress and controller legacy/unknown-key rejection.

Verification Commands

# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q
# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q
# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q
# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q
# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q
# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_route_agy_advisory_fallback.py -q
# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_route_agy_advisory_fallback.py -q
# AC8
# preflight-scope: runtime_only
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_codebase_investigator_actual_wrapper_fallback_smoke.py -q -m claude_live
# AC9
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q
# Producer discriminator
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provider.py -q
# AC10
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_route_agy_advisory_fallback.py -q
# AC11
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py -q

Allowed Paths

  • .claude/agents/codebase-investigator.md
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/scripts/route_agy_advisory_fallback.py
  • .claude/skills/issue-refinement-loop/scripts/tests/test_route_agy_advisory_fallback.py
  • .claude/skills/issue-refinement-loop/scripts/run_codebase_investigator_agy_advisory.py
  • .claude/skills/issue-refinement-loop/scripts/tests/test_run_codebase_investigator_agy_advisory.py
  • .claude/skills/issue-refinement-loop/tests/test_codebase_investigator_actual_wrapper_fallback_smoke.py
  • .claude/skills/issue-refinement-loop/tests/test_codebase_investigator_agy_fallback_smoke.py (delete)
  • .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provider.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agy_invocation_argv_allowlist.py
  • .claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_e2e.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_e2e.py

Anchor Finding Disposition

  • P0: resolved: production strips ambient AGY_BIN; fake injection is module-private test-only. PATH/installed identity is deployment-boundary outside caller provenance.

  • P1: resolved: producer-owned attempted/kind/class correlation makes actual AGY invocation controller-verifiable; only attempted:true, producer-marked operational valid actual agy_* failures may fall back. Exact decision protocol, target-first/context-second serialization, pre-AGY fail-close, focused producer/controller tests, sole new actual-wrapper smoke, and old-smoke retirement are retained; no taxonomy mirror, positive allowlist, regex, or full schema duplicate.

  • P2: resolved: exact pre-controller-only five-case legacy mapping deletes the old field before exact V1; controller legacy/unknown-key rejection is retained.

  • P0: resolved by target-first/context-second --context-file serialization, target-only reachability, and matching downstream limit tests.

  • P1: resolved by producer-owned agy_invocation_attempted extending existing agy_failure_kind, controller attempted/kind/class correlation, producer/controller/actual-wrapper consumption, and no taxonomy mirror/regex/full schema duplication.

  • P2: resolved by exact pre-controller-only legacy adapter mappings, deletion of old flag before exact V1, and controller legacy/unknown-key rejection.

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合

  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合

  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)

  • 後続 Phase / 別スコープへの波及が判明した場合

  • nested SubAgent delegation が必要になった場合

  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

  • Exact public request, repository-root path containment/32-path/1-MiB-per-file/4-MiB-aggregate/mode mapping, requirement-only policy, AGY_BIN-stripped production env, private test seam, canonical builder/wrapper sequence, producer-owned attempted/kind correlation, exact decision protocol, or the sole new actual-wrapper smoke plus old-smoke retirement cannot be retained.

  • PATH/installed AGY deployment management, taxonomy mirror/positive allowlist/full schema duplicate/regex classification, root routing/CODEBASE result change, mutating native work, GitHub/Issue mutation, OAuth/credential/keyring/config mutation, or real provider availability is required.

  • Stop if target-first/context-second canonical --context-file serialization, same existing downstream limits, no-evidence_targets/no-build_request.py boundary, producer-owned pre-exec callback transition immediately before actual agy -p subprocess with focused timing coverage, producer attempted/kind correlation, exact pre-controller legacy adapter, single new smoke plus old-smoke retirement, or all focused producer/controller/smoke consumptions cannot be retained.

Required Skills

なし

Required Design References

  • .claude/agents/codebase-investigator.md
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/gemini-cli-headless-delegation/scripts/build_request.py
  • .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
  • .claude/skills/gemini-cli-headless-delegation/references/failure-class-taxonomy.md
  • docs/dev/runtime-verification-policy.md

Scope Delta(任意)

  • Remove caller-owned result/projection trust and ambient-production AGY_BIN trust; add stripped child env, exact canonical request/profile/repository-root-contained path mapping with 32-path/1-MiB-per-file/4-MiB-aggregate/mode limits, private fake seam, and owned invocation/private paths.

  • Add producer-owned attempted/kind correlation, target-first/context-second canonical context-file serialization, exact prompt sections, and exact pre-controller legacy ingress mapping; retain the sole-new-actual-wrapper-smoke/old-smoke-retirement contract without builder, taxonomy, or public-controller compatibility expansion.

  • Add target-first/context-second canonical context-file serialization and exact prompt sections; add producer-owned attempted boolean correlation and exact legacy ingress mapping. Restore the fixed single-new-smoke/old-smoke-retirement contract. This is a narrow contract clarification, not a builder, taxonomy, or public-controller compatibility expansion.

Delivery Rule

1 Issue = 1 PR は repository delivery rule として維持するが、本 Issue 本文の semantic rewrite は canonical controlled transaction のみで行い、new Issue、branch、PR、Issue split は作成しない。

Notes for Reviewer

  • Ambient AGY_BIN is stripped in production; fake injection is module-private/test-only only. PATH/installed agy identity is deployment boundary, not caller provenance.

  • reason_code is routing-only. The small explicit deny set remains; advisory fallback requires a canonical producer-marked agy_failure_kind: operational and conforming agy_* class, while policy/boundary and invalid/unknown results fail close.

  • Agent/caller require exact closed decision plus exit pairing; only degraded/native starts native work.

  • The sole new actual-wrapper smoke uses proposal_only only in private driver, not production local_asset; exit77 SKIP is not PASS.

  • agy_invocation_attempted is producer-owned top-level output, not caller provenance; its true transition is immediately before canonical subprocess exec. agy_failure_kind is extended, never replaced.

  • Legacy agy_advisory_native_fallback_allowed is accepted nowhere except the named pre-controller ingress and is deleted before controller validation.

  • Keep AGY_BIN strip/private seam, exact decision protocol, producer allowed path, P0/P1/P2, single new smoke, and old-smoke retirement unchanged.

  • The existing owner boundary is explicit: deployment-managed inherited PATH/installed agy is outside caller provenance; only public request/API fields and ambient AGY_BIN are executable-selection inputs that the controller rejects or strips.

  • Wrapper output is capped at 1 MiB before strict parsing. Wrapper/stdout/stderr duplicate keys, extra bytes, partial data, or unpaired streams fail close without native fallback.

Source

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 30, 2026
  2. squne121 commented on Aug 30, 2026

    @squne121
    OwnerAuthor

    結論

    判定: REQUEST_CHANGES — reframe_in_place 推奨。

    #2434 の方向性そのもの、つまり

    • prose / mirror predicate ではなく production deterministic helper に fallback 判定を集約する

    • test-only AGY_BIN を使い、canonical builder → actual run_gemini_headless.py → route decision → real codebase-investigator native fallback を通す

    • root/preflight へ AGY post-runtime routing を戻さず、SubAgent-local architecture を維持する

    の3点は妥当です。特に run_gemini_headless.py は既に AGY_BIN の hermetic test injection を意図して実装しているため、実OAuthや実providerを使わず wrapper 境界を検証する設計はきれいです。

    ただし、fallback policy が現行 main と過去のOwner判断から後退しています。ここは実装前に直すべきです。

    Findings

    Severity | Finding | 判定 -- | -- | -- P0 | agy_auth_required / agy_timeout / agy_not_found の3種類だけを fallback allowlist にする設計 | 変更必須 P0 | 既存 agy_advisory_native_fallback_allowed と新規 agy_investigation_requirement が二重のpolicy inputになる | 変更必須 P1 | wrapper result 全体を closed-schema として再定義すると producer schema と二重管理になる | 変更推奨 P1 | unknown failure_class を一律 fail-close にすると taxonomy 追加で advisory workflow が突然停止する | 変更推奨 P1 | AC5 の実wrapper smoke は価値があるが、恒久ハーネスを広げすぎる余地がある | 縮小推奨 P2 | #2155 を Required Design References に置く意味がほぼない | 削除推奨

    P0: 3-class allowlist は現行設計の可用性を壊す

    ここが最大の問題です。

    現行 codebase-investigator.md は既に明示的に negative policy を採用しています。すなわち「taxonomy の値を全部allowlist化しない。advisory AGY failure は原則 native fallback し、明白な contract / policy / permission-boundary violation だけ止める」という設計です。

    これは偶然ではなく、#2360 の敵対的レビューでもOwnerがまさに同じ結論を出しています。大量の failure class allowlist をconsumer側に複製するのではなく、advisory provider failure は原則 fallback、boundary/policy violation のみ block が個人開発には適切だと整理されています。 PR #2365 のレビューでも、この「小さなdenylist」方式が再度推奨され、その後 main に反映されています。

    ところが #2434 は再び

    agy_auth_required
    agy_timeout
    agy_not_found

    だけを許可します。Issue本文でもそれ以外の既知classを全部 fail-close と明記しています。

    これは taxonomy とも噛み合いません。現行 taxonomy には agy_rate_limited、agy_capacity_exhausted、agy_web_grounding_quota_exhausted など、明らかに「AGY が今使えないだけ」で native repository investigation を止める理由にならない operational failure が存在します。

    たとえば、

    AGYがrate limit → native Read/Grep/Globが利用可能 → しかしIssue refinement全体をfail-close

    は、ユーザーの用途では完全に逆です。

    Web側の現状もこの判断を補強します。Antigravity CLI は headless permission の設定が期待通り作用しない報告や、非対話認証の未解決要求が現在もあり、-p automation の availability は完全に安定した前提にはできません。(GitHub) upstream自身も過去に headless permission、keyring、sandbox、noninteractive behavior を継続的に修正しています。(GitHub)

    推奨policyは次です。

    advisory + opt-in + well-formed AGY failure
        ↓
    明白な contract / request / policy / permission violation ?
        yes → fail_closed
        no  → native_read_only_fallback

    deny対象だけ小さく固定するのがよいです。具体的には少なくとも、

    request_schema_invalid
    request_policy_denied
    github_research_command_denied
    agy_invocation_policy_denied
    agy_permission_denied
    agy_permission_boundary_unavailable
    agy_permission_boundary_inconclusive

    あたりです。

    rate-limit / capacity / quota / timeout / auth / executable unavailable / ordinary nonzero provider termination は advisory なら fallback でよいです。


    P0: policy input が二重になる

    現行 Step 1 は codebase-investigator に

    agy_advisory_native_fallback_allowed: true

    を渡す契約です。

    #2434 はさらに、

    agy_investigation_requirement: advisory | explicitly_required

    を追加します。

    すると、

    fallback_allowed=false + requirement=advisory
    fallback_allowed=true  + requirement=explicitly_required

    のような矛盾状態が生まれます。

    しかも issue-refinement-loop の現行 Step 1 には「誰がどの根拠で explicitly_required を決めるのか」という deterministic producer がありません。つまり failure判定だけhelper化しても、required/advisory の判定は依然prompt semantics です。

    ここは単一入力にした方がいいです。

    agy_investigation_requirement:
      advisory
      explicitly_required

    そして advisory 自体が fallback opt-in を意味する形にして、旧 agy_advisory_native_fallback_allowed は削除またはcompatibility aliasとして一時的にのみ扱うことを勧めます。

    少なくとも二つを独立したpolicy truthとして残すべきではありません。


    P1: closed-schema にする場所が違う

    AGY_ADVISORY_FALLBACK_ROUTE_DECISION_V1 出力を closed schema にするのは賛成です。

    一方、run_gemini_headless.py の delegation_result/v1 全体を新helperでもexact closed-schema validationするのは避けた方がいいです。

    そうすると、

    run_gemini_headless.py producer schema
            +
    route_agy_advisory_fallback.py の複製schema

    という二重authorityになります。

    将来wrapperに harmless な追加fieldが1つ増えただけで、fallback consumerが突然fail-closeする可能性があります。

    helperが必要なのはせいぜい、

    schema/version
    provider
    ok
    failure_class

    と要求種別だけです。

    helper自身のinput envelopeはclosed、埋め込まれたwrapper resultは必要fieldだけprojectして検証くらいが適切です。taxonomy全値のコピーも不要です。


    P1: unknown class の扱いも availability 寄りでよい

    #2434 は unknown failure class を全部 fail-close にします。

    これは malformed JSON と同一視しない方がいいです。

    例えば upstream に将来、

    agy_service_unavailable

    が追加された場合、wrapper result自体は完全にvalidなのに、issue-refinement-loop が更新されるまで全調査が停止します。

    私なら、

    malformed result
    provider != agy
    ok/failure_class が矛盾
    failure_class が AGY failure と確認できない
        → fail_closed
    

    valid result + failure_class="agy_*"
    → 明示denyでなければ advisory fallback

    とします。

    これなら、contract破損にはfail-closeしつつ、provider taxonomy追加ではworkflowを止めません。


    実wrapper smoke は採用してよい。ただし1本で十分

    ここは #2434 の改善点です。

    現在の smoke は実 codebase-investigator を起動するものの、promptへ pre-completed fake delegation_result/v1 を渡しており、wrapper producerまでは通していません。つまりconsumer proofとしては有効でも「wrapper-to-fallback E2E」と呼ぶには弱いです。

    一方で AGY_BIN injection は既存wrapperの正式なtest seamです。したがって、

    canonical builder
    → AGY_BIN=fake
    → actual run_gemini_headless.py
    → real delegation_result/v1
    → production route helper
    → real codebase-investigator
    → native evidence sentinel

    という1本だけのthin integration smokeは追加価値があります。

    ただし、ここから新しい sandbox、permission broker、OAuth emulator、keyring emulator、永久permission baseline、巨大なtool-trace auditorへ広げるべきではありません。

    Claude Code公式も tools / disallowedTools と permissionMode: dontAsk を組み合わせて非対話のbounded SubAgentを構成できるとしています。dontAsk はpromptを自動拒否し、明示許可されたtoolは動作します。(Claude) 現行 Read/Grep/Glob + bounded Bash のままで十分です。

    PR #2365 では、意図したpermission変更まで止めていた pre_migration_git_history 恒久テストが「harness scope leakage」と判断され削除対象になった前例もあります。 同じ失敗を #2434 で再導入しない方がよいです。

    #2155 は参照から外してよい

    #2155 は #2119 の performance/reliability close-grade 実CI evidenceを扱う verification-only Issue です。

    #2434 自身も「dependencyではない」「実CI evidenceは対象外」と書いています。

    であれば Required Design References に置くメリットがなく、むしろ「runtime verificationなら #2155 型の重いevidence governanceも必要なのか」という誤読を誘います。削除を推奨します。

    #2431 の overlap は確認しましたが、こちらは Step 0f structural repair producer の known_scalars/source_spans wiring が目的で、今回の AGY fallback decision boundary とは編集意図が別です。directory-level C1 advisory の扱いで問題ありません。

    推奨する #2434 の着地点

    Issueを分割する必要はありません。その場でreframeすれば十分です。

    中心契約は、

    1. AGY advisory/required のpolicy inputを一つにする
    2. actual wrapper resultをproduction helperがconsumeする
    3. advisoryでは valid AGY operational failureを原則native fallback
    4. contract / policy / permission violationだけsmall denylistでfail-close
    5. malformed wrapper resultはfail-close
    6. CODEBASE_INVESTIGATION_RESULT_V1は変更しない
    7. AGY_BIN fakeによるactual-wrapper smokeを1本だけ追加
    8. root preflight/control-planeへroutingを戻さない

    が最も整合しています。

    実装優先度としては、P0の2点を修正してから implementation-ready にするのを推奨します。 deterministic helper と wrapper smoke はそのまま進めてよく、問題は「deterministic化の中身を3-class allowlistとして固定してしまっていること」です。そこさえ直せば、#2360/#2365/#2368 で積み上げた設計を壊さず、AGY障害で作業が不要に止まる問題もかなり減らせます。

    ## 結論

    判定: REQUEST_CHANGES — reframe_in_place 推奨。

    #2434 の方向性そのもの、つまり

    • prose / mirror predicate ではなく production deterministic helper に fallback 判定を集約する
    • test-only AGY_BIN を使い、canonical builder → actual run_gemini_headless.py → route decision → real codebase-investigator native fallback を通す
    • root/preflight へ AGY post-runtime routing を戻さず、SubAgent-local architecture を維持する

    の3点は妥当です。特に run_gemini_headless.py は既に AGY_BIN の hermetic test injection を意図して実装しているため、実OAuthや実providerを使わず wrapper 境界を検証する設計はきれいです。

    ただし、fallback policy が現行 main と過去のOwner判断から後退しています。ここは実装前に直すべきです。

    Findings

    Severity Finding 判定
    P0 agy_auth_required / agy_timeout / agy_not_found の3種類だけを fallback allowlist にする設計 変更必須
    P0 既存 agy_advisory_native_fallback_allowed と新規 agy_investigation_requirement が二重のpolicy inputになる 変更必須
    P1 wrapper result 全体を closed-schema として再定義すると producer schema と二重管理になる 変更推奨
    P1 unknown failure_class を一律 fail-close にすると taxonomy 追加で advisory workflow が突然停止する 変更推奨
    P1 AC5 の実wrapper smoke は価値があるが、恒久ハーネスを広げすぎる余地がある 縮小推奨
    P2 #2155 を Required Design References に置く意味がほぼない 削除推奨

    P0: 3-class allowlist は現行設計の可用性を壊す

    ここが最大の問題です。

    現行 codebase-investigator.md は既に明示的に negative policy を採用しています。すなわち「taxonomy の値を全部allowlist化しない。advisory AGY failure は原則 native fallback し、明白な contract / policy / permission-boundary violation だけ止める」という設計です。

    これは偶然ではなく、#2360 の敵対的レビューでもOwnerがまさに同じ結論を出しています。大量の failure class allowlist をconsumer側に複製するのではなく、advisory provider failure は原則 fallback、boundary/policy violation のみ block が個人開発には適切だと整理されています。 PR #2365 のレビューでも、この「小さなdenylist」方式が再度推奨され、その後 main に反映されています。

    ところが #2434 は再び

    agy_auth_required
    agy_timeout
    agy_not_found

    だけを許可します。Issue本文でもそれ以外の既知classを全部 fail-close と明記しています。

    これは taxonomy とも噛み合いません。現行 taxonomy には agy_rate_limited、agy_capacity_exhausted、agy_web_grounding_quota_exhausted など、明らかに「AGY が今使えないだけ」で native repository investigation を止める理由にならない operational failure が存在します。

    たとえば、

    AGYがrate limit → native Read/Grep/Globが利用可能 → しかしIssue refinement全体をfail-close

    は、ユーザーの用途では完全に逆です。

    Web側の現状もこの判断を補強します。Antigravity CLI は headless permission の設定が期待通り作用しない報告や、非対話認証の未解決要求が現在もあり、-p automation の availability は完全に安定した前提にはできません。([GitHub]1) upstream自身も過去に headless permission、keyring、sandbox、noninteractive behavior を継続的に修正しています。([GitHub]2)

    推奨policyは次です。

    advisory + opt-in + well-formed AGY failure
        ↓
    明白な contract / request / policy / permission violation ?
        yes → fail_closed
        no  → native_read_only_fallback
    

    deny対象だけ小さく固定するのがよいです。具体的には少なくとも、

    request_schema_invalid
    request_policy_denied
    github_research_command_denied
    agy_invocation_policy_denied
    agy_permission_denied
    agy_permission_boundary_unavailable
    agy_permission_boundary_inconclusive

    あたりです。

    rate-limit / capacity / quota / timeout / auth / executable unavailable / ordinary nonzero provider termination は advisory なら fallback でよいです。


    P0: policy input が二重になる

    現行 Step 1 は codebase-investigator に

    agy_advisory_native_fallback_allowed: true

    を渡す契約です。

    #2434 はさらに、

    agy_investigation_requirement: advisory | explicitly_required

    を追加します。

    すると、

    fallback_allowed=false + requirement=advisory
    fallback_allowed=true  + requirement=explicitly_required
    

    のような矛盾状態が生まれます。

    しかも issue-refinement-loop の現行 Step 1 には「誰がどの根拠で explicitly_required を決めるのか」という deterministic producer がありません。つまり failure判定だけhelper化しても、required/advisory の判定は依然prompt semantics です。

    ここは単一入力にした方がいいです。

    agy_investigation_requirement:
      advisory
      explicitly_required

    そして advisory 自体が fallback opt-in を意味する形にして、旧 agy_advisory_native_fallback_allowed は削除またはcompatibility aliasとして一時的にのみ扱うことを勧めます。

    少なくとも二つを独立したpolicy truthとして残すべきではありません。


    P1: closed-schema にする場所が違う

    AGY_ADVISORY_FALLBACK_ROUTE_DECISION_V1 出力を closed schema にするのは賛成です。

    一方、run_gemini_headless.py の delegation_result/v1 全体を新helperでもexact closed-schema validationするのは避けた方がいいです。

    そうすると、

    run_gemini_headless.py producer schema
            +
    route_agy_advisory_fallback.py の複製schema
    

    という二重authorityになります。

    将来wrapperに harmless な追加fieldが1つ増えただけで、fallback consumerが突然fail-closeする可能性があります。

    helperが必要なのはせいぜい、

    schema/version
    provider
    ok
    failure_class
    

    と要求種別だけです。

    helper自身のinput envelopeはclosed、埋め込まれたwrapper resultは必要fieldだけprojectして検証くらいが適切です。taxonomy全値のコピーも不要です。


    P1: unknown class の扱いも availability 寄りでよい

    #2434 は unknown failure class を全部 fail-close にします。

    これは malformed JSON と同一視しない方がいいです。

    例えば upstream に将来、

    agy_service_unavailable

    が追加された場合、wrapper result自体は完全にvalidなのに、issue-refinement-loop が更新されるまで全調査が停止します。

    私なら、

    malformed result
    provider != agy
    ok/failure_class が矛盾
    failure_class が AGY failure と確認できない
        → fail_closed
    
    valid result + failure_class="agy_*"
        → 明示denyでなければ advisory fallback
    

    とします。

    これなら、contract破損にはfail-closeしつつ、provider taxonomy追加ではworkflowを止めません。


    実wrapper smoke は採用してよい。ただし1本で十分

    ここは #2434 の改善点です。

    現在の smoke は実 codebase-investigator を起動するものの、promptへ pre-completed fake delegation_result/v1 を渡しており、wrapper producerまでは通していません。つまりconsumer proofとしては有効でも「wrapper-to-fallback E2E」と呼ぶには弱いです。

    一方で AGY_BIN injection は既存wrapperの正式なtest seamです。したがって、

    canonical builder
    → AGY_BIN=fake
    → actual run_gemini_headless.py
    → real delegation_result/v1
    → production route helper
    → real codebase-investigator
    → native evidence sentinel
    

    という1本だけのthin integration smokeは追加価値があります。

    ただし、ここから新しい sandbox、permission broker、OAuth emulator、keyring emulator、永久permission baseline、巨大なtool-trace auditorへ広げるべきではありません。

    Claude Code公式も tools / disallowedTools と permissionMode: dontAsk を組み合わせて非対話のbounded SubAgentを構成できるとしています。dontAsk はpromptを自動拒否し、明示許可されたtoolは動作します。(Claude) 現行 Read/Grep/Glob + bounded Bash のままで十分です。

    PR #2365 では、意図したpermission変更まで止めていた pre_migration_git_history 恒久テストが「harness scope leakage」と判断され削除対象になった前例もあります。 同じ失敗を #2434 で再導入しない方がよいです。

    #2155 は参照から外してよい

    #2155 は #2119 の performance/reliability close-grade 実CI evidenceを扱う verification-only Issue です。

    #2434 自身も「dependencyではない」「実CI evidenceは対象外」と書いています。

    であれば Required Design References に置くメリットがなく、むしろ「runtime verificationなら #2155 型の重いevidence governanceも必要なのか」という誤読を誘います。削除を推奨します。

    #2431 の overlap は確認しましたが、こちらは Step 0f structural repair producer の known_scalars/source_spans wiring が目的で、今回の AGY fallback decision boundary とは編集意図が別です。directory-level C1 advisory の扱いで問題ありません。

    推奨する #2434 の着地点

    Issueを分割する必要はありません。その場でreframeすれば十分です。

    中心契約は、

    1. AGY advisory/required のpolicy inputを一つにする
    2. actual wrapper resultをproduction helperがconsumeする
    3. advisoryでは valid AGY operational failureを原則native fallback
    4. contract / policy / permission violationだけsmall denylistでfail-close
    5. malformed wrapper resultはfail-close
    6. CODEBASE_INVESTIGATION_RESULT_V1は変更しない
    7. AGY_BIN fakeによるactual-wrapper smokeを1本だけ追加
    8. root preflight/control-planeへroutingを戻さない
    

    が最も整合しています。

    実装優先度としては、P0の2点を修正してから implementation-ready にするのを推奨します。 deterministic helper と wrapper smoke はそのまま進めてよく、問題は「deterministic化の中身を3-class allowlistとして固定してしまっていること」です。そこさえ直せば、#2360/#2365/#2368 で積み上げた設計を壊さず、AGY障害で作業が不要に止まる問題もかなり減らせます。

  3. squne121 commented on Aug 30, 2026

    @squne121
    OwnerAuthor

    推奨は、#2434 を分割せず、指定コメントを OWNER の explicit human context として reframe_in_place し、そのまま issue-refinement-loop を approval-less で完走させることです。

    現行 issue-refinement-loop 自体、iteration gate は既定で承認不要です。また anchor comment 付きの direct human context には preflight.run.with_human_context → 必要なら contract_update.run.with_human_context という canonical mutation lane が既にあります。 現行 codebase-investigator も「taxonomy 全値の allowlist を作らず、明白な contract/policy/boundary violation だけ deny」という negative policy を既に採用しています。

    指定コメントの P0 は特にそのまま反映すべきです。つまり、3-class allowlist を撤回し、agy_advisory_native_fallback_allowed と agy_investigation_requirement の二重 policy truth を一本化することです。wrapper 全体の schema 複製を避ける、valid な未知 agy_* operational failure は原則 fallback、actual-wrapper smoke は1本の thin integration に留める、#2155 は design reference から外す、という P1/P2 も一緒に reframe するのが適切です。 upstream AGY には現在も headless permission や noninteractive auth の未解決事例があるため、operational failure で refinement 全体を止めない availability-oriented な設計とも整合します。([GitHub]1)

    以下をそのまま Claude-GPT に渡せます。

    以下の対象に対して issue-refinement-loop を実行してください。

    対象リポジトリ:
    https://github.com/squne121/loop-protocol

    対象 Issue:
    #2434

    authoritative anchor comment:
    #2434 (comment)

    目的

    Issue #2434 を、上記 OWNER anchor comment の REQUEST_CHANGES / reframe_in_place 指示に従って refinement し、実装着手可能な Issue contract まで改善してください。

    今回は issue refinement のみ が対象です。

    この依頼は explicit human authorization である

    このメッセージは、リポジトリオーナーによる明示的な human instruction として扱ってください。

    指定 anchor comment は agent_report や unlabeled anchor として扱わず、canonical な direct human context として扱ってください。

    したがって、必要なら canonical lane:

    preflight.run.with_human_context
    → contract_update.run.with_human_context
    → fresh preflight
    → fresh review

    を使用してください。

    anchor comment が既に明示的に決定している事項について、再度人間へ承認を求めてはいけません。

    特に、anchor comment に明示された以下の reframe は、このプロンプトによって適用を承認します。

    必須 reframe

    P0-1: 3-class fallback allowlist を撤回する

    現在の Issue #2434 にある

    • agy_auth_required
    • agy_timeout
    • agy_not_found

    だけを automatic native fallback の eligible class とする positive allowlist 方針は撤回してください。

    現行 main / #2360 / PR #2365 で確立された思想に合わせ、

    advisory AGY investigation では valid な AGY operational failure は原則 native non-mutating fallback し、明白な contract / request / policy / permission violation だけ small negative policy で fail-close

    という契約へ reframe してください。

    少なくとも anchor comment が列挙した以下は fail-close 側として扱ってください。

    • request_schema_invalid
    • request_policy_denied
    • github_research_command_denied
    • agy_invocation_policy_denied
    • agy_permission_denied
    • agy_permission_boundary_unavailable
    • agy_permission_boundary_inconclusive

    一方、以下のような provider availability / operational failure は advisory なら原則 native fallback 可能な方向にしてください。

    • auth unavailable
    • timeout
    • binary/provider unavailable
    • rate limit
    • capacity exhaustion
    • quota exhaustion
    • ordinary AGY nonzero termination
    • valid AGY provider failureで、small deny policy に該当しないもの

    taxonomy 全値を consumer 側にコピーした巨大 allowlist を作る契約にはしないでください。

    P0-2: policy input を一本化する

    現行の

    agy_advisory_native_fallback_allowed

    と、新たに提案されている

    agy_investigation_requirement: advisory | explicitly_required

    を独立した二つの policy truth として残さないでください。

    矛盾状態を作れない single source of truth に reframe してください。

    推奨形は:

    agy_investigation_requirement: advisory | explicitly_required

    を唯一の semantic policy input とし、

    • advisory = AGY-first。ただし eligible failure 時の native non-mutating fallback を許可
    • explicitly_required = AGY failure 時は fail-close

    とする形です。

    既存 agy_advisory_native_fallback_allowed を即時削除することで migration 問題が出る場合のみ、compatibility alias / migration detail として扱って構いません。

    ただし、二つを独立した authority として残すことは禁止します。

    P1-1: wrapper result schema の二重 authority を作らない

    新 helper の output AGY_ADVISORY_FALLBACK_ROUTE_DECISION_V1 は closed / deterministic schema で構いません。

    しかし run_gemini_headless.py が生成する delegation_result/v1 全体の schema を helper 側でも完全複製しないでください。

    helper input envelope 自体は必要なら closed にしてよいですが、embedded wrapper result は routing に必要な projection のみ検証する契約にしてください。

    例:

    • schema/version
    • provider
    • ok
    • failure_class
    • requirement

    など。

    wrapper producer schema に harmless field が追加されただけで fallback consumer が停止する設計にしないでください。

    P1-2: unknown class と malformed result を区別する

    malformed / contradictory wrapper result は fail-close のままにしてください。

    例:

    • malformed JSON / invalid structure
    • provider != agy
    • ok と failure_class の矛盾
    • failure_class が AGY failure と判断できない
    • request / policy / permission boundary violation

    一方、

    well-formed result かつ failure_class が valid な agy_* provider failure で、明示 deny category に該当しない場合は、将来 taxonomy に operational class が追加されても advisory workflow が即停止しないようにしてください。

    つまり「unknown enumだから即 fail-close」という taxonomy mirror allowlist を避けてください。

    P1-3: actual-wrapper smoke は thin integration 1本にする

    以下を実際につなぐ verification contract は維持してください。

    canonical builder
    → test-only AGY_BIN fake
    → actual run_gemini_headless.py
    → real delegation_result/v1
    → production route helper
    → real codebase-investigator
    → native non-mutating fallback evidence

    ただし 1本の thin integration smoke に限定してください。

    以下の新規ハーネスを #2434 に持ち込まないでください。

    • OAuth emulator
    • keyring emulator
    • permission broker
    • 新規 sandbox framework
    • 永続 permission baseline の追加
    • 巨大 tool-trace auditor
    • 実 provider availability を PASS 条件にする仕組み

    既存の test-only AGY_BIN seam、既存 SubAgent permissions、既存 non-mutating investigation policy を利用してください。

    smoke の claim は実測できる範囲に限定してください。

    例:

    • tracked worktree status unchanged
    • mutating tool use がない
    • fake AGY invocation evidence がある
    • actual wrapper result が route helper に consume された
    • native fallback evidence sentinel に到達した

    「全 side effect が存在しない」等の過剰 claim は作らないでください。

    P2: #2155 を Required Design References から外す

    #2155 は reference-only の verification issue であり #2434 の dependency ではありません。

    Required Design References から削除してください。

    必要なら historical/background mention 程度に留めてください。

    維持する設計

    以下は anchor comment が approve しているため維持してください。

    1. fallback route decision を prose / test mirror predicate ではなく production deterministic helper へ集約する
    2. actual wrapper result を production helper が consume する
    3. CODEBASE_INVESTIGATION_RESULT_V1 の既存 contract は変更しない
    4. root preflight / control-plane へ AGY post-runtime routing を戻さない
    5. fallback は codebase-investigator / SubAgent-local architecture 内で完結させる
    6. test-only AGY_BIN fake で実 OAuth / credential mutation / provider invocation を不要にする
    7. OAuth login automation、credential/keyring/config mutation、provider retry redesign は Out of Scope のまま
    8. 実装: issue-refinement-loop の structural repair producer に known_scalars/source_spans の実抽出を配線する #2431 などとの directory/path-level overlap だけで停止しない。semantic edit intent が独立している限り C1 advisory として扱う

    #2431 は Step 0f structural repair producer の known_scalars/source_spans wiring が目的であり、#2434 の AGY wrapper-result decision/fallback boundary とは semantic scope が異なります。
    単なる directory-level overlap を human approval gate にしないでください。

    issue-refinement-loop の実行

    まず repository の現行 issue-refinement-loop skill と関連 SSOT を読み、独自の refinement 手順を再実装しないでください。

    canonical planner / reviewer / consumer の出力をそのまま consume してください。

    対象 anchor は direct human context なので、必要に応じて canonical human-context preflight / contract-update route を使ってください。

    preflight が deterministic repair / deterministic structural repair / trusted contract update / issue-editor rewrite を要求した場合は、canonical consumer を使って自動適用してください。

    raw な ad-hoc GitHub Issue edit で canonical control-plane を迂回しないでください。

    人間承認不要の実行権限

    今回の refinement を完遂するために必要な以下の操作を事前承認します。

    これらについて逐次「実行してよいですか」と聞かないでください。

    loop iteration approval gate は不要です。

    human_judgment_required の扱い

    anchor comment とこのプロンプトで既に結論が与えられている事項を、再度 human_judgment_required に送らないでください。

    たとえば、

    はすでに human decision 済みです。

    preflight がこれらの既決事項を human context として認識できず停止した場合は、勝手に別方針を選ぶのではなく、canonical with_human_context lane / trusted anchor consumption が正しく使われているか確認し、可能な範囲で正規 route を再実行してください。

    ただし次のような、本プロンプトにも anchor comment にも答えがなく semantic contract を新たに決める必要がある真の未解決事項だけは、repository の hard stop contract に従って停止して構いません。

    単なる routine repair、known template normalization、readback、label hygiene、path overlap、既決 reframe の適用を human escalation にしないでください。

    SubAgent 実行指示

    planner / skill が SubAgent investigation を要求する場合は、適切な SubAgent を使用してください。

    特に repository investigation が必要なら codebase-investigator を使用し、現行 skill contract の AGY-first / advisory native fallback を尊重してください。

    重要:

    • SubAgent を起動したら、その作業完了を必ず待つこと
    • SubAgent が実行中なのに main thread だけで結果を推測して先へ進まないこと
    • 複数 SubAgent を並行起動できる独立タスクなら並行化してよい
    • ただし全 relevant SubAgent の terminal result を受け取ってから join / classification / rewrite を行うこと
    • SubAgent の self-report を blindly trust せず、canonical artifact / repository evidence と照合すること
    • nested SubAgent delegation が repository Stop Condition に抵触する場合は行わないこと

    推奨する refinement 後の #2434 contract

    最終 Issue が概ね次の中心契約になるよう refinement してください。

    1. AGY advisory / explicitly-required の policy truth は一つ
    2. actual wrapper result を production deterministic helper が consume
    3. advisory + well-formed AGY operational failure は原則 native non-mutating fallback
    4. contract / request / policy / permission violation だけ small negative policy で fail-close
    5. malformed / contradictory wrapper result は fail-close
    6. valid unknown agy_* operational failure は small deny policy に該当しない限り advisory fallback を阻害しない
    7. CODEBASE_INVESTIGATION_RESULT_V1 は変更しない
    8. AGY_BIN fake を使う actual-wrapper thin integration smoke を1本追加
    9. root preflight / root control-plane に post-runtime AGY routing を戻さない
    10. 実OAuth、provider availability、credential mutationを verification requirement にしない
    11. 検証: #2119 AC9/AC10 の close-grade 実CI証跡を確認する #2155 は dependency / Required Design Reference にしない
    12. harness の追加は検証に必要な最小限に留める

    Acceptance Criteria / In Scope / Out of Scope / Verification Commands / Stop Conditions / Allowed Paths も、この reframe と矛盾しないよう全面的に整合させてください。

    特に旧方針で残りやすい、

    を stale text として残さないでください。

    完了条件

    次の状態まで、途中の人間承認なしで refinement loop を継続してください。

    • Issue 実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434 の本文 rewrite が GitHub readback で確認済み
    • anchor comment の P0 findings がすべて反映済み
    • P1/P2 findings が反映または、repository evidence に基づく明示的 disposition 済み
    • Machine-Readable Contract / Outcome / In Scope / Out of Scope / AC / Verification / Allowed Paths / Stop Conditions が相互整合
    • fresh preflight が pass/proceed 相当
    • fresh canonical review が approve/proceed 相当
    • semantic design review が applicable ならそれも terminal approve
    • implementation-ready と判断できる
    • unresolved blocker がない

    最大 iteration に達する前に needs-fix が出た場合は自動で rewrite → fresh review を継続してください。

    最終報告

    最後に簡潔に以下を報告してください。

    途中経過だけで終了せず、起動した SubAgent の完了を待ち、refinement loop の terminal state まで実行してください。

    この形なら、単に「--no-approval で回して」と言うより、今回の anchor comment 自体を human decision として canonical human-context lane に供給する点を明示しているため、以前のように「semantic reframe なので人間判断待ち」で止まる可能性をかなり減らせます。特に #2434 は Issue 本文そのものが既に implementation phase なので、今回は「refinement 完了後も実装には入らない」を明示的に入れています。

  4. squne121 commented on Aug 30, 2026

    @squne121
    OwnerAuthor

    結論として、今回の semantic review: blocker / needs-fix は、現在の #2434 の契約に対しては妥当です。ただし、3-class allowlist や small negative deny policy が悪いという判定ではありません。止められているのは 「この failure_class が本当に canonical wrapper producer から来た値だと、どう機械的に保証するのか」 が未定義だからです。

    現在の #2434 はかなり改善されていて、agy_investigation_requirement の単一 policy truth、small negative deny policy、future valid agy_* の availability 寄り fallback、wrapper 全体の schema 複製回避まで反映されています。 これは anchor comment の P0/P1 の方向とも一致し、PR #2365 でも small negative policy が明示的に採用されています。

    問題は、現在の契約が「actual run_gemini_headless.py --output-file JSON を渡す」としながら、同時に「任意に作った agy_foo は拒否するが、将来 producer が追加した正規 agy_foo は許可する」と要求している点です。JSON の中身だけ見れば両者は同じ文字列なので、provenance を別に定義しない限り判別不能です。実際、最終 semantic finding も「future valid agy_* と arbitrary prefix-only を決定論的に区別できない」を blocker としています。 そのため deterministic review は approve でも、最終 join が needs-fix になっています。

    ここで provenance flag や taxonomy allowlist を新設する必要はありません。一番小さく、実装もしやすい解決は「production route helper 自身が wrapper invocation を所有する」ことです。run_gemini_headless.py は既に _classify_agy_failure() で stdout/stderr から canonical class を作り、_normalize_agy_result() がそれを delegation_result/v1.failure_class に格納しています。 現行 taxonomy も rate limit / capacity / quota / auth / timeout / ordinary nonzero 等を canonical producer の分類として定義しています。

    したがって、production API に arbitrary result JSON を渡させないのが推奨です。route helper/controller が canonical request を受け、自分で private temporary output path を作り、run_gemini_headless.py を shell=False で起動し、その自分で生成させた output だけを読み、minimal projection → route decision とします。内部の pure decision function は unit test 用に dict を受けてもよいですが、production caller から直接呼べる contract にはしません。これなら self-declared canonicalized: true も、全 taxonomy mirror も不要です。

    なお、途中の「Issue edit permission denied」は この semantic blocker とは別問題です。自動 repair lane は permission denied になりましたが、その後同じセッションで canonical edit_issue_txn.py を使った更新自体は成功しています。 したがって次のプロンプトでは、#2434 の refinement に必要な controlled Issue body mutation を今回の明示的 human authorization として扱わせ、同じ承認を再度聞かせないようにしています。

    以下を Claude-GPT にそのまま渡すのを推奨します。

    以下の対象に対して issue-refinement-loop を継続実行してください。

    対象リポジトリ:
    https://github.com/squne121/loop-protocol

    対象 Issue:
    #2434

    canonical direct human context / anchor:
    #2434 (comment)

    目的は Issue #2434 自体を reframe し、fresh deterministic review と fresh semantic design review の両方が terminal approve / implementation-ready 相当になるまで refinement を完了することです。

    Issue の分割、新規 Issue 起票、実装、branch 作成、Draft PR 作成は行わないでください。今回は Issue refinement のみです。

    Explicit human authorization

    これはリポジトリオーナーによる明示的な human instruction / owner decision です。

    このメッセージを、今回の issue-refinement-loop に必要な以下の作業に対する直接の human authorization として扱ってください。

    Issue #2434 の本文を canonical controlled mutation lane で必要回数更新すること、candidate body / transaction input / review artifact / temporary artifact を作成すること、preflight.run.with_human_context、contract readiness、root deterministic review、semantic design review、join review を必要回数実行すること、repository の read-only 調査、関連 Issue / PR / canonical artifact の readback、read-only gh / Git operations を行うことを許可します。

    edit_issue_txn.py 等の repository-sanctioned controlled Issue mutation を使った #2434 本文更新について、同じ human approval を再度要求しないでください。

    auto repair dispatcher / permission wrapper が permission/control-plane 理由だけで mutation を拒否した場合でも、この explicit authorization が失われたとは解釈しないでください。repository が許可している別の canonical controlled transaction lane が存在する場合はそれを使用してください。ただし raw gh issue edit、permission bypass flag、guard 無効化、credential manipulation 等で迂回してはいけません。

    Issue body の semantic refinement に必要なら、#2434 自体の Allowed Paths / In Scope / AC / Verification Commands / Stop Conditions を in-place で狭く整合させることも許可します。これを理由に新規 Issue を起票したり、人間承認を再要求したりしないでください。

    今回の semantic blocker に対する owner decision

    直前の semantic review の blocker:

    future valid agy_* operational failure と、任意に偽造された prefix-only agy_* failure_class を raw delegation_result/v1 JSON だけから区別できない

    について、owner decision は以下です。

    production trust boundary は「caller が渡した JSON の自己申告 provenance」ではなく、「production routing entry point が canonical wrapper invocation 自体を所有していること」で確立してください。

    つまり、production entry point が caller-supplied delegation_result/v1 JSON、caller-created routing projection、caller-supplied failure_class override、canonicalized: true のような self-declared provenance flag を直接 trust する設計にはしないでください。

    推奨する contract は、production routing entry point/controller が canonical request を受け、自身で collision-resistant / private temporary output path を作成し、actual .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py を shell=False の bounded subprocess として起動し、その invocation が生成した exact output のみを直後に読み取って routing projection を構築する形です。

    その invocation-owned result に対してのみ、schema/version、provider、ok、failure_class、requirement、および相関する failure state の minimal projection validation を行ってください。

    内部実装上、pure decision function が dict/projection を受けること自体は構いません。ただしそれを caller-facing production trust boundary にしてはいけません。fixture / unit test が直接 pure function に値を渡す経路は test-only と明確に分離してください。

    この設計により、

    canonical wrapper producer が生成した将来の valid agy_* operational failure
    と
    prompt / caller / arbitrary JSON から注入された prefix-only agy_*

    を production contract 上区別してください。

    暗号署名、persistent provenance DB、自己申告 provenance field、failure taxonomy 全値 mirror、巨大な harness は導入しないでください。

    canonical producer を再実装しない

    現行 main の run_gemini_headless.py::_classify_agy_failure() / AGY result normalization が canonical failure classification producer です。

    consumer 側に classification regex、全 failure-class allowlist、producer schema 全体の duplicate validator を作らないでください。

    必要なのは canonical producer invocation の ownership と、その actual output の minimal routing projection です。

    まず既存 implementation / taxonomy / #2360 / merged PR #2365 を repository evidence で再確認してください。

    fallback policy

    agy_investigation_requirement: advisory | explicitly_required を fallback semantics の唯一の semantic policy authority としてください。

    agy_advisory_native_fallback_allowed を残す必要がある場合は transitional compatibility alias に限定し、独立した二つ目の policy truth として扱わないでください。

    advisory かつ canonical actual AGY wrapper invocation が well-formed failure を返した場合、small negative deny policy に該当しない operational/provider-availability failure は native non-mutating fallback eligible としてください。

    rate limit、capacity exhaustion、quota exhaustion、auth unavailable、binary/provider unavailable、timeout、ordinary AGY nonzero termination、および将来 canonical producer が生成する valid AGY operational failure を、taxonomy mirror / positive allowlist を作らず fallback 可能にしてください。

    一方、少なくとも

    request_schema_invalid
    request_policy_denied
    github_research_command_denied
    agy_invocation_policy_denied
    agy_permission_denied
    agy_permission_boundary_unavailable
    agy_permission_boundary_inconclusive

    は small negative deny policy として fail-close にしてください。

    explicitly_required は AGY failure 時に native fallback せず fail-close としてください。

    malformed wrapper result、non-AGY provider、schema/version mismatch、ok と failure state の contradiction、missing/type-invalid requirement 等も fail-close としてください。

    「unknown class だから」という理由だけで、canonical wrapper invocation から来た future valid AGY operational failure を fail-close にしてはいけません。

    #2434 の reframe 方針

    現在の Issue にある route_actual_agy_wrapper_result という名前または contract が「caller が arbitrary result JSON を production input として渡す」意味を持つなら、その名前・signature・説明を維持する必要はありません。

    実装可能性を優先し、たとえば production controller と internal pure projector/decision function の二層に整理してください。

    production controller:
    canonical request / requirement を受ける
    → private output path を確保
    → actual wrapper invocation
    → exact output readback
    → minimal projection
    → deterministic route decision

    internal pure decision:
    production controller が構築した projection を評価
    → AGY success continuation / native non-mutating fallback / fail-close を決定

    という責務分離を Issue contract 上で明確にしてください。

    ただし exact function name は repository の既存 naming / implementation conventions を調査した上で最適化して構いません。

    AGY_ADVISORY_FALLBACK_ROUTE_DECISION_V1 を維持する場合も、それが provider taxonomy の SSOT にならないようにしてください。

    Allowed Paths の扱い

    第一選択は、現在の #2434 の Allowed Paths 内で解決することです。

    特に routing helper 自身が run_gemini_headless.py subprocess invocation を所有する設計で解決できるなら、canonical producer file 自体を変更する必要はありません。

    repository evidence 上どうしても producer-side public interface の最小変更が必要であることを証明できた場合のみ、#2434 を分割せず in-place reframe し、必要最小限の producer file / focused test path を Allowed Paths に追加してください。この narrow Allowed Paths rewrite は本メッセージで明示的に許可します。

    ただし security framework、permission broker、OAuth/keyring emulator、persistent permission baseline、taxonomy registry の大規模再設計等へ scope expansion してはいけません。

    thin runtime smoke

    actual-wrapper smoke は一つだけにしてください。

    証明する経路は概ね、

    canonical builder
    → test-only AGY_BIN fake
    → actual run_gemini_headless.py
    → canonical delegation_result/v1
    → production invocation-owned routing entry point
    → deterministic route decision
    → real codebase-investigator
    → native non-mutating fallback sentinel

    です。

    実 OAuth、実 provider、実 network availability、credential/keyring/config mutation は不要です。

    runtime unavailable の場合のみ canonical policy に従って exit 77 / SKIP を記録し、SKIP を PASS に変換しないでください。

    tracked worktree status unchanged、mutating tool use なし、fake invocation evidence、actual wrapper output consumption、native fallback sentinel だけを必要な runtime claim にしてください。

    smoke を複数追加したり、大型 harness を追加したりしないでください。

    anchor finding disposition

    anchor comment の P0/P1/P2 をすべて fresh Issue body に照合してください。

    3-class positive allowlist は撤回済みであることを確認すること。

    dual policy truth は撤回し agy_investigation_requirement に一本化すること。

    wrapper full-schema duplicated validation は行わず minimal routing projection にすること。

    future canonical agy_* operational failure は unknown だけを理由に fail-close しないこと。

    actual-wrapper smoke は one thin integration smoke に限定すること。

    #2155 を dependency / required design authority として残さないこと。reference-only としても不要なら削除してください。

    stale text が別節、AC、Verification Commands、Notes、Machine-Readable Contract、Source 等に残っていないか全文検索してください。

    SubAgent を使用すること

    repository investigation、semantic design review、必要な Issue rewrite review には適切な SubAgent を使用してください。

    少なくとも repository/canonical contract の独立確認と semantic design review は、利用可能な適切な SubAgent に委譲してください。

    SubAgent には現在の Issue body SHA、調査対象、必要な canonical refs を明示してください。

    SubAgent の self-report を blindly trust せず、返却結果を repository evidence / pinned artifact / canonical review artifact と照合してください。

    起動した SubAgent は必ず完了を待ってから次の依存ステップへ進んでください。

    background のまま最終回答してはいけません。

    既存の別 Herdr tab、別 Claude Code session、人間が操作中の session へプロンプトを送ったり、そこで作業させたりしないでください。今回の current session から起動した bounded SubAgent のみを使ってください。

    repository Stop Condition が nested delegation を禁止している場合、SubAgent にさらに SubAgent を起動させないでください。

    review loop

    fresh remote Issue readback から開始してください。以前の tmp candidate、古い semantic bundle、古い body SHA を現在値として再利用しないでください。

    canonical preflight を fresh に実行してください。

    deterministic/root review が approve でも、semantic review applicability が true ならそこで終了せず semantic review まで完了してください。

    semantic review は canonical semantic-design-review procedure に従い、fresh body を pin し、issue-design reviewer の完了を待ち、その fresh result を transport してください。

    body SHA の sha256: prefix 有無を独自推測で混在させず、canonical transport が要求する exact representation を使用し、freshness mismatch を発生させないでください。

    semantic review が blocker/high finding を返した場合は、自動的に semantic rewrite lane へ進み、finding の recommended fix と本 owner decision を Issue body に反映し、fresh preflight → fresh deterministic review → fresh semantic review を繰り返してください。

    今回明示した「invocation-owned trusted boundary」を採用するかどうかについて人間へ再質問しないでください。これは既に owner decision 済みです。

    requires_owner_choice が同じ trusted-boundary 論点について再度出た場合も、このメッセージを owner choice として consume し、contract を具体化して fresh review を続行してください。

    最大 iteration に達する前に no-progress を検出した場合は、同じ文章の言い換えを繰り返さず、semantic finding が要求する実装可能な interface / trust boundary / validation order が AC と In Scope に具体化されているかを確認してください。

    本メッセージで決めていない、本当に別の不可逆・scope-changing owner decision が新たに必要になった場合だけ Stop Condition としてください。

    terminal condition

    以下をすべて満たすまで refinement 完了として扱わないでください。

    fresh preflight: pass / proceed

    fresh deterministic/root review: approve

    fresh semantic review: clear / approve 相当で、open blocker/high finding がない

    join/effective verdict: approve / implementation-ready 相当

    Issue body SHA と各 review artifact の binding が fresh

    anchor comment の P0/P1/P2 disposition がすべて説明可能

    unresolved blocker がない

    SubAgent がすべて完了している

    最終報告

    最後に簡潔に、

    refinement の最終 verdict
    最終 body SHA
    Issue #2434 をどう reframe したか
    semantic blocker をどう解消したか
    anchor P0/P1/P2 各 finding の disposition
    preflight / deterministic review / semantic review の最終結果
    SubAgent の完了状況
    最終 Issue URL

    を報告してください。

    Issue #2434:
    #2434

    このプロンプトのポイントは、「semantic reviewer を無視して approve 扱いにする」のではなく、reviewer が要求している trusted boundary を、現在の small-denylist 方針を壊さない形で実装可能な契約に変えることです。これなら #2434 のまま terminal approve を目指せる可能性が高いです。

  5. squne121 commented on Aug 30, 2026

    @squne121
    OwnerAuthor

    確認した限り、#2434 は現在の Issue 本文を SSOT として、そのまま impl-review-loop に入れるのが推奨です。旧 adversarial review の P0/P1 はすでに本文へかなり詳細に織り込まれており、AC1〜AC11、Verification Commands、Allowed Paths、Stop Conditions まで固定されています。特に、producer-owned agy_failure_kind / agy_invocation_attempted、actual-wrapper smoke 1本、旧 smoke 削除、build_request.py 非変更、production AGY_BIN strip などが明文化されています。

    また impl-review-loop 自体が、implementation-worker → test-runner → pr-reviewer → judgment を SubAgent で回し、APPROVE と live mergeability が揃った時点で draft_pr_ready として終了し、マージ判断は人間に残す設計です。SubAgent の単なる human_review_required: true 自己申告は原則停止権限を持たず、正式な HUMAN_REVIEW_REQUIRED verdict、secret gate、実 Git conflict などが真の停止条件です。

    したがって、旧レビューコメントを直接仕様として再解釈せず、実行開始時に live Issue を再取得し、current-run contract review を通して現在本文を正本にするのが重要です。旧コメントでは reframe が要求されていましたが、現在本文はその後更新されています。

    以下を Claude-GPT にそのまま渡すのを推奨します。

    対象リポジトリ:
    https://github.com/squne121/loop-protocol

    対象 Issue:
    #2434

    Issue #2434 を対象に、repository-native の impl-review-loop を実行してください。

    目的は、現在の live Issue contract を正本として、

    実装
    → 独立検証
    → PR 作成
    → PR review
    → review finding 修正
    → 再検証
    → current-head 再レビュー
    → CI / live mergeability 確認

    を自律的に反復し、マージ操作そのものを行う直前の draft_pr_ready / approved 状態まで、人間の途中承認なしで到達することです。

    Owner authorization

    これは repository owner からの明示的な実行承認です。

    以下の通常作業について、追加の人間承認を求めず実行してください。

    • canonical preflight / current-run issue-contract-review
    • live Issue / comments / related Issue / related PR / current repository state の read
    • impl-review-loop の canonical root-owned synchronous entry transition
    • repository-defined worktree の作成・再利用
    • implementation branch の作成
    • Issue 実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434 の 現在の Allowed Paths 内での編集・追加・削除
    • Issue に列挙された Verification Commands の実行
    • focused unit / regression test
    • Issue で要求されている actual-wrapper runtime smoke
    • lint / typecheck / test / build 等、変更内容に必要な repository quality gate
    • commit
    • bounded normal push
    • PR 作成
    • PR title / body の hygiene 修正
    • Closes #2434 の設定
    • PR review の実行
    • review finding に対するコード修正
    • review comment への応答
    • resolved と判断できる review thread の resolve
    • current-head verification の再実行
    • stale-head re-review
    • current branch が BEHIND の場合の repository-defined update_branch
    • update_branch 後の再検証・再レビュー
    • failed CI の原因調査
    • deterministic / transient と判断できる CI job の bounded rerun
    • live mergeability の再取得
    • impl-review-loop が通常の mechanical operation として定義しているその他の bounded action

    これらについて「実行してよいですか」「PRを作ってよいですか」「pushしてよいですか」「修正してよいですか」と逐次確認しないでください。

    ユーザーの目的は、マージ直前まで unattended で完走させることです。

    ただし、この承認は Issue contract や repository policy を無視する権限ではありません。

    Semantic authority

    開始時に必ず live Issue #2434 を再取得してください。

    現在の live Issue 本文を semantic SSOT としてください。

    過去の Issue コメント、旧 contract snapshot、過去の adversarial review、以前の planning output は historical context / evidence として利用できますが、現在の Issue 本文と矛盾する場合は 現在本文を優先してください。

    特に、過去コメントにあった旧設計をそのまま復活させないでください。

    現在の Issue が固定している以下の設計を維持してください。

    • caller-supplied wrapper result を production trust boundary にしない
    • controller-owned actual invocation を trust boundary とする
    • exact AGY_ADVISORY_INVOCATION_REQUEST_V1
    • public executable injection 禁止
    • production child env から ambient AGY_BIN を strip
    • fake executable injection は module-private / test-only seam のみ
    • canonical builder → actual wrapper → exact output readback → projection → shared decision core
    • wrapper output の bounded read と strict duplicate-key rejecting JSON parse
    • producer-owned agy_failure_kind
    • producer-owned agy_invocation_attempted
    • producer-owned canonical_agy_failure_kind(...)
    • controller 側で failure taxonomy mirror を作らない
    • target-first / context-second の唯一の --context-file serialization
    • 32 combined paths / 1 MiB per file / 4 MiB aggregate の既存 boundary
    • build_request.py を変更しない
    • CODEBASE_INVESTIGATION_RESULT_V1 を変更しない
    • root control-plane に AGY post-runtime routing を戻さない
    • legacy flag は指定された pre-controller compatibility ingress のみに限定
    • actual-wrapper smoke は 1本のみ
    • old legacy smoke は削除
    • OAuth / real provider / keyring / credentials mutation をテストへ持ち込まない
    • native fallback は non-mutating のまま
    • new Issue / scope split を作らない

    Issue の Acceptance Criteria、Allowed Paths、Out of Scope、Stop Conditions を literal に確認し、それらを implementation contract としてください。

    Entry procedure

    .claude/skills/impl-review-loop/SKILL.md と、その参照先の current repository version を読んでください。

    独自の簡略化ループを作らず、repository-native impl-review-loop を使用してください。

    開始時には canonical な root-owned synchronous entry transition を実行してください。

    すなわち、同一の継続した root invocation 内で、

    1. capability preflight
    2. live Issue 実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434 fetch
    3. current-run issue-contract-review
    4. live Issue の直後再取得
    5. canonical routing 判定
    6. 許可された場合の Step 1 dispatch

    まで実施してください。

    古い snapshot、過去コメント、以前の authorization packet、artifact、digest だけを Step 1 authorization として使わないでください。

    現在 Issue の label や過去の report を人間の承認要求へ短絡させず、canonical current-run routing を正本にしてください。

    SubAgent requirement

    この作業では SubAgent を実際に使用してください。

    少なくとも repository workflow が定義する、

    • implementation-worker
    • test-runner
    • pr-reviewer

    を canonical な役割で使用してください。

    root/main thread が worker / verifier / reviewer の仕事を肩代わりしないでください。

    各 SubAgent の dispatch では placeholder を残さず、

    • actual Issue number
    • actual Issue URL
    • current Allowed Paths
    • actual PR number
    • current head SHA
    • current fix_delta

    などを具体値へ materialize して渡してください。

    非同期放置禁止

    SubAgent を fire-and-forget にしないでください。

    SubAgent を起動したら、その SubAgent の canonical completion/result が返るまで待ってください。

    完了を待たずに同じ責務を root が並行実行したり、次ステップへ進んだりしないでください。

    複数 SubAgent を並列化できる場合でも、依存関係を壊さない独立作業だけに限定し、spawn した全 SubAgent の完了を回収してから routing 判断してください。

    nested SubAgent delegation が Issue #2434 の Stop Condition に該当する場合は、worker 自身からさらに nested delegation させないでください。必要な top-level SubAgent orchestration は root impl-review-loop が担ってください。

    Implementation loop

    canonical loop を次の通り完走してください。

    Step 1 — Implementation

    implementation-worker に implement-issue を実行させてください。

    Issue #2434 の現在の Allowed Paths を厳守してください。

    まず existing implementation / tests / related assets を読み、Issue contract に対する最小かつ一貫した変更を実装してください。

    不要な harness、sandbox、permission broker、OAuth emulator、credential fixture、第二の smoke、taxonomy mirror、generic framework を増やさないでください。

    変更後は必要な focused verification を実施し、PR がなければ作成してください。

    PR body に Issue の契約・検証結果を反映し、

    Closes #2434

    を含めてください。

    Step 2 — Verification

    test-runner に独立検証させてください。

    Issue #2434 の Verification Commands を literal に確認し、current head に対して実行してください。

    特に AC8 の runtime verification は Issue の指定通り扱ってください。

    • actual wrapper
    • module-private fixed proposal_only driver
    • test-owned AGY_BIN fake
    • canonical builder
    • actual run_gemini_headless.py
    • exact same-invocation result consumption
    • agy_failure_kind
    • agy_invocation_attempted
    • real codebase-investigator
    • native sentinel
    • tracked status before/after
    • no mutation

    を証明してください。

    Issue の規定通り、exit 77 / SKIP を PASS へ昇格させないでください。

    real OAuth、real provider availability、credential/keyring/config mutation は行わないでください。

    Verification Commands 以外にも、変更したコードに対して repository 標準の必要十分な regression gate がある場合は実行してください。

    Step 4 — PR Review

    current-head verification gate が通った後だけ pr-reviewer を起動してください。

    reviewer は current PR head をレビューし、canonical LOOP_VERDICT を返してください。

    review 対象には少なくとも、

    • Issue AC1〜AC11
    • current diff
    • Allowed Paths compliance
    • schema producer / consumer ownership
    • public vs private executable injection boundary
    • malformed / duplicate-key handling
    • attempted/kind/class correlation
    • success sidecar exactness
    • stdout/stderr/exit pairing
    • pre-AGY/non-AGY fail-close
    • advisory operational fallback
    • explicitly_required fail-close
    • legacy adapter exact mappings
    • target/context ordering and limits
    • actual-wrapper smoke quality
    • old smoke retirement
    • unwanted harness expansion
    • build_request.py non-change
    • CODEBASE_INVESTIGATION_RESULT_V1 non-change
    • native fallback non-mutation

    を含めてください。

    Step 5 — Judgment

    review verdict と live GitHub mergeability を repository の route_loop_verdict_v2() で評価してください。

    REQUEST_CHANGES

    REQUEST_CHANGES の場合は停止せず、

    1. blockers を fix_delta に materialize
    2. implementation-worker に修正委譲
    3. SubAgent 完了を待つ
    4. current head で verification
    5. current-head gate
    6. PR re-review

    まで続けてください。

    stale review

    reviewed_head_sha が current head と異なる場合、人間を呼ばず current head で re-review してください。

    BEHIND

    repository-defined routing が route_to_update_branch を返した場合、mechanical update_branch を implementation-worker へ委譲し、完了を待ってから verification と PR review を再実行してください。

    transient / deferred mergeability

    UNKNOWN、required-CI propagation、BLOCKED / UNSTABLE 等について repository workflow が bounded retry / CI evaluator へ委ねるよう定義している場合、すぐ人間へ escalation しないでください。

    current-head factsを再取得して repository-defined routing を続けてください。

    Permission / approval handling

    SubAgent が単に

    human_review_required: true

    を返しただけでは停止しないでください。

    repository の現行 impl-review-loop contract に従い、それは warning/evidence として扱い、正式な hard gate でない限りループを継続してください。

    「慎重のため」「semanticに見える」「artifactがない」「snapshotが古い」「overlapがある」「確認した方が安全」といった理由だけで人間承認を要求しないでください。

    routine な implementation / test / review / PR hygiene / update-branch / CI retry は、このプロンプトによって事前承認されています。

    ツール側で通常操作に approval prompt が発生し、repository policy 上 auto execution が許可される操作である場合は、この owner authorization を根拠に canonical permitted lane を使用してください。

    permission prompt の回避だけを目的に unauthorized alternate path、手動 force operation、別 runtime、別 credential source へ fallback しないでください。

    Genuine stop conditions

    以下の場合のみ停止し、具体的な evidence と必要な owner decision を報告してください。

    1. Issue 実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434 の Allowed Paths 外の semantic code change が本当に必要
    2. Issue 本文の固定 schema / key set / semantic contract 自体を変更する必要がある
    3. 新しい Issue / scope split が必要
    4. Issue が禁止している後続 scope への波及が不可避
    5. Issue の Stop Conditions に該当
    6. secret / credential / token の取得・表示・保存・変更が必要
    7. OAuth / keyring / provider config mutation が必要
    8. real external provider invocation を必須としなければ AC を証明できない
    9. force push、history rewrite、remote destructive operation が必要
    10. unrelated user work を破壊する必要がある
    11. actual Git conflict があり repository runbook でも自動解消不能
    12. current owner の live Issue / PR コメントに明示的な停止指示がある
    13. canonical reviewer が正式な HUMAN_REVIEW_REQUIRED verdict を返し、repository routing が route_human_escalation を要求
    14. repository-defined bounded max-iteration / no-progress hard gate を本当に使い切った
    15. repository-native recovery を実施しても required SubAgent runtime が genuinely 利用不能

    「念のため確認」は停止理由ではありません。

    Explicitly prohibited actions

    以下は実行しないでください。

    • PR の merge
    • gh pr merge
    • auto-merge enable
    • force push
    • destructive history rewrite
    • unrelated branch / worktree の削除
    • unrelated user changes の reset / checkout / stash / clean
    • secret / token / credential の閲覧・出力・保存
    • real OAuth login
    • keyring/config mutation
    • real AGY provider invocation を smoke の代替として使うこと
    • Issue 実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434 の semantic contract を勝手に reframe すること
    • Allowed Paths 外へ「ついでの改善」を広げること
    • new Issue の作成
    • second smoke / generalized test harness の追加
    • build_request.py の変更
    • taxonomy mirror / positive allowlist / regex classifier の追加
    • CODEBASE_INVESTIGATION_RESULT_V1 の変更
    • root control-plane への AGY post-runtime routing 移動
    • native fallback 中の repository / GitHub mutation

    Review-fix policy

    レビューで blocker が見つかった場合、ユーザーへ修正許可を聞かず、自動修正してください。

    修正 → tests → push → current-head verification → re-review を繰り返してください。

    ただし review finding が current Issue contract 自体の変更を要求している場合は、実装で contract を勝手に書き換えて解決せず Genuine stop condition としてください。

    reviewer の stylistic preference や speculative overengineering は、そのまま blocker とせず Issue contract / regression / repository facts に照らして判断してください。

    Completion target

    次の状態まで自律的に進めてください。

    • Issue 実装: AGY advisory調査のfallback判定をdeterministic化し実wrapper smokeを追加する #2434 の AC1〜AC11 が current head で満たされている
    • Allowed Paths compliance が成立
    • required verification が PASS
    • runtime verification applicable AC の evidence が成立
    • current-head PR review が APPROVE
    • reviewer blockers == []
    • current PR head と reviewed head が一致
    • required CI が merge判断可能な状態
    • live mergeability が repository の approved route 条件を満たす
    • PR body が正しく Closes #2434 を持つ
    • unresolved blocking review thread がない
    • impl-review-loop が draft_pr_ready / termination_reason: approved 相当で終了する

    ここまで到達したら 停止してください。マージは実行しないでください。

    Final report

    最後に、簡潔に以下を報告してください。

    途中経過のために人間の返信を待たず、上記の genuine stop condition が発生しない限り、SubAgent の完了を同期的に待ちながらループを継続してください。

    特に重要なのは、「approval-less」を impl-review-loop の安全境界を無効化する意味にしないことです。現在の skill は、単なる SubAgent の自己申告や transient mergeability では止まらず、正式な reviewer verdict・実 conflict・secret gate 等だけを hard stop にする設計なので、その既存機構をそのまま利用する方が今回の目的に合っています。

    また、#2434 は Allowed Paths を10ファイルに限定し、single actual-wrapper smoke と旧 smoke 削除まで明示しています。このため 実装中に「より一般的なハーネスを作ろう」「別 Issue に分けよう」と膨らませないこともプロンプトで強く固定しています。

  6. squne121 commented on Aug 30, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  7. 15 remaining items

  8. squne121 commented on Sep 1, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

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

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions