Skip to content

実装: workflow trusted signalsとIssue/PR Task equivalenceをTask Contextへ統合する #2565

Closed
1 of 1 issue completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2562"
goal_ref: "Connect structured workflow facts to Task Context without Issue/PR split-brain; keep post-merge cleanup resumable."
change_kind: workflow
dedupe_key: "task-context-v1:workflow-signals-ref-equivalence"

Parent Issue

#2562

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

  • Implement workflow producers and the controlled signal service.
  • Replace direct caller target identifiers with adapter-supplied session origin and service-side canonical Task resolution.
  • Implement the decided pr_merged_observed producer/commit point and post-merge cleanup lifecycle ordering.
  • Add physical dedupe and producer-side GitHub relation snapshots without network I/O in UserPromptSubmit.

Depends On

Outcome

Only structured workflow facts can change completion state. A canonical Task prevents Issue/PR split-brain; a merged PR remains CLEANUP_PENDING until the eligible cleanup Activity completes.

In Scope

  • Implement one coarse-grained apply_workflow_signal() service operation in scripts/task-context/task_context_service.py. It validates the public envelope and evidence, resolves the origin and canonical Task, performs claim/Task validation and accepted-fact dedupe in the required order, selects the signal's fixed historical Activity semantics, makes a monotonic transition when eligible, appends the event, and enqueues projection in one BEGIN IMMEDIATE transaction. External I/O occurs before that transaction.
  • For implementation_pr_observed, after legal canonical Task resolution, apply_workflow_signal() is the sole owner, in that transaction, of Issue/PR claim validation and attachment, fact dedupe, event append, and projection enqueue. It validates that both claims can legally attach before mutating either claim; a duplicate or conflict leaves no partial claim mutation. open-pr supplies only validated facts and origin.
  • Define the public task-contextctl signal apply v1 payload as exactly four top-level fields: signal_kind, source, source_schema_version, and evidence. All required top-level values except evidence are JSON strings; evidence is a JSON object. Reject caller input containing session_id, task_id, activity_id, or binding_id. The CLI adapter reads CLAUDE_CODE_SESSION_ID and passes it only as internal origin_session_id; hook adapters map hook JSON session_id to that field. A non-Claude invocation with no origin returns deferred/unbound without state mutation. Do not make /clear ID rotation a guarantee of this contract.
  • Use origin only to resolve canonical Task (origin_session_id → open ExecutionRun → Binding → canonical Task), never to choose the current Activity. The service uses fixed historical phase semantics: refinement_approved affects only refine; implementation_pr_observed records implementation evidence/claim only and never terminalizes; pr_merged_observed affects only implementation; cleanup_completed affects only cleanup. Delayed or replayed signals cannot terminalize another phase or regress state.
  • Connect issue-refinement-loop's canonical approved termination/handoff publish to refinement_approved; do not derive completion from raw natural-language text. Connect open-pr (new and EXISTING=true detected PR) to implementation_pr_observed; DRY_RUN=true sends no signal. Adapter outcomes never roll back successful producer work.
  • post-merge-cleanup is the only v1 producer of pr_merged_observed. Its normative order is: (1) obtain and validate a fresh merged-PR snapshot; (2) apply pr_merged_observed; (3) confirm applied, or confirm duplicate_noop only for a valid envelope/evidence bound to the same canonical Task and same business fact; (4) only then select, resume, or start cleanup Activity; (5) dispatch worker/work. deferred, conflict, rejected_envelope, rejected_evidence, late_noop, and any other rejected outcome select/resume/start no Activity and dispatch no work in that invocation.
  • After an accepted merge prerequisite, the post-merge-cleanup main orchestrator is the durable lifecycle owner: in one service transaction it creates, resumes, or selects the sole eligible nonterminal cleanup Activity bound to the same Task, PR, and merge identity, and persists an internal append-only cleanup_started event containing that Activity ID and merge identity. The public v1 envelope and evidence never expose a cleanup Activity handle, and no caller selects one. On final success, cleanup_completed uses its fresh origin to resolve the Task and uses validated evidence to deterministically locate and verify that sole internal Task/PR/merge instance; it cannot create, select, or complete cleanup merely because a PR is merged. Missing instance or Task/PR/merge mismatch is an explicit non-mutating outcome. If cleanup has already begun without an accepted merged fact, a later pr_merged_observed returns non-mutating late_noop/CLEANUP_ALREADY_BEGUN; it is not a success precondition and does not roll back external work. A replay of the same accepted merged fact first takes origin-first same-Task dedupe and then satisfies the cleanup precondition.
  • Before open-pr emits implementation_pr_observed, producers obtain a fresh GitHub PR snapshot and run a total claimless-relation classifier using closingIssuesReferences(first: 2, excludeUserLinked: false, userLinkedOnly: false). Exactly one reference proceeds only when it equals the candidate Issue; only that validated matching relation may reach the service's atomic claim attachment. Zero returns named non-mutating deferred/NO_LINK; exactly one mismatching reference returns conflict/RELATION_ISSUE_MISMATCH; and two-or-more references return conflict/MULTIPLE_CLOSING_ISSUES; each emits no signal and performs no Task Context mutation. Snapshot fetch failure, GraphQL errors, partial or timeout responses, and null or malformed relation connection or nodes normalize to deferred/RELATION_UNAVAILABLE, with no signal, mutation, or claim attachment. first: 2 is a bounded classifier, not a claim of complete enumeration; generic text, branch/worktree references, and Refs #N alone are never equivalence authority.
  • Keep UserPromptSubmit local-only. It performs local claim lookup only; a PR claim miss passes the prompt through without GitHub relation or merged-state lookup and without Task Context mutation.
  • Add nullable events.dedupe_key and the minimal partial UNIQUE index. Dedupe identity is signal_kind plus business fact identity only: refinement=repo+issue+approved_body_sha256; implementation=repo+PR; merged=repo+PR+merge_commit_oid; cleanup=repo+PR+merge_identity. Keep source and source_schema_version as event metadata, not identity. Same fact resolved to another Task is a typed identity conflict; no new ledger/framework.
  • Preserve existing 実装: Native Claude operatorにTask Context hooks・wrong-session guard・statusLine/Herdr projectionを配線する #2564 bind/rebind guards. A different active primary Task is advisory/conflict and never silently retargets claims or directly signals another Task. Multiple closing Issues, multiple implementation PRs for one Issue, and substantive duplicate Tasks are conflicts, not auto-merge candidates.
  • Derive and expose CLEANUP_PENDING for an open Task with an accepted merged implementation and incomplete eligible cleanup; a later ordinary cleanup prompt for the same Issue/PR resumes the existing Task rather than creates another.
  • Retain docs/dev/task-context.md as an implementation design reference and permitted documentation path.

Public v1 Envelope, Evidence, and Origin Contract

The public v1 envelope has exactly these four top-level fields and no others:

Field Required JSON type and allowed value
signal_kind string enum: refinement_approved, implementation_pr_observed, pr_merged_observed, cleanup_completed
source string enum: issue-refinement-loop, open-pr, post-merge-cleanup
source_schema_version exactly the JSON string v1
evidence object, strict per signal below

The v1 kind/source pairs are exact: refinement_approved→issue-refinement-loop; implementation_pr_observed→open-pr; pr_merged_observed→post-merge-cleanup; cleanup_completed→post-merge-cleanup. Future producers or envelope forms require a schema/contract revision. A duplicate-detecting JSON decoder runs before ordinary schema validation. Every envelope-level failure is non-mutating with disposition: rejected_envelope, never conflict; evidence validation uses the separate rejected_evidence disposition. The fixed envelope reason enum is:

Condition rejected_envelope reason
Malformed JSON MALFORMED_JSON
Non-object root NON_OBJECT_ROOT
Duplicate top-level member DUPLICATE_TOP_LEVEL_MEMBER
Missing or unknown top-level field UNKNOWN_TOP_LEVEL_FIELD
Wrong top-level type WRONG_TOP_LEVEL_TYPE
Unknown signal_kind UNKNOWN_SIGNAL_KIND
Unknown source UNKNOWN_SOURCE
Invalid kind/source pair SOURCE_SIGNAL_MISMATCH
source_schema_version other than exact JSON string v1 UNSUPPORTED_SCHEMA_VERSION
Caller supplies session_id, task_id, activity_id, or binding_id FORBIDDEN_CALLER_IDENTITY

evidence has no fields beyond those listed for its signal_kind; duplicate evidence members are detected by that decoder before ordinary schema validation and return non-mutating rejected_evidence with typed reason DUPLICATE_EVIDENCE_MEMBER. Omitted required fields, forbidden/unknown fields, wrong types, or failed canonical-value validation also return disposition: rejected_evidence with a typed reason and perform no state, claim, event, projection, or dedupe mutation.

  • repo is a non-empty canonical GitHub repository ID, exactly lowercase owner/name (no URL, #, whitespace, or .git suffix), obtained from the producer's fresh repository/PR snapshot.
  • issue_number and pr_number are JSON integers greater than zero; they are canonical GitHub Issue and PR numbers, never URLs, node IDs, strings, branch names, or text references.
  • approved_body_sha256 is exactly 64 lowercase hexadecimal characters, the SHA-256 of the UTF-8 persisted approved Issue body used by the canonical termination/handoff publish; no prefix or alternate digest representation is accepted.
  • merge_commit_oid is exactly 40 lowercase hexadecimal characters, the full GitHub merge commit OID from a fresh merged PR snapshot; abbreviated OIDs, refs, and null/unmerged values are invalid.
  • merge_identity is exactly the same validated 40-lowercase-hex merge OID representation as merge_commit_oid, copied from the accepted merged fact for the same canonical repository and PR; composite strings, PR URLs, and independently invented identities are invalid.
signal_kind Required evidence fields Forbidden evidence fields Canonical dedupe key from validated values
refinement_approved repo, issue_number, approved_body_sha256 pr_number, merge_commit_oid, merge_identity task-context-v1:refinement_approved:<repo>:<issue_number>:<approved_body_sha256>
implementation_pr_observed repo, issue_number, pr_number approved_body_sha256, merge_commit_oid, merge_identity task-context-v1:implementation_pr_observed:<repo>:<pr_number>
pr_merged_observed repo, issue_number, pr_number, merge_commit_oid approved_body_sha256, merge_identity task-context-v1:pr_merged_observed:<repo>:<pr_number>:<merge_commit_oid>
cleanup_completed repo, issue_number, pr_number, merge_identity approved_body_sha256, merge_commit_oid task-context-v1:cleanup_completed:<repo>:<pr_number>:<merge_identity>

The service, not callers, derives and persists this key only after envelope and evidence validation. source and source_schema_version remain metadata and never enter the key.

The service applies this total, origin-first ordering in one transaction:

  1. Validate envelope, then validate evidence and derive the business-fact key.
  2. Resolve internal origin_session_id through open ExecutionRun → Binding → canonical Task. An absent, stale, or unbound origin returns deferred/unbound before any accepted-fact duplicate lookup.
  3. Validate claim/Task consistency (or, only for implementation_pr_observed, legal atomic attachment).
  4. Deduplicate an accepted fact only on that canonical Task: same Task and fact returns duplicate_noop; a fact already bound to a different Task returns conflict/FACT_TASK_IDENTITY_CONFLICT.
  5. Only for a new pr_merged_observed, evaluate the cleanup-begun late boundary. Thus a valid same-origin/same-Task accepted duplicate wins before the late boundary, while a new merged fact after cleanup begins returns late_noop/CLEANUP_ALREADY_BEGUN.

All failures before an accepted transition are non-mutating and return their explicit outcome. Cleanup-begun never converts an accepted same-fact duplicate into late_noop.

Signal Selected historical Activity and accepted preconditions Missing / already terminal Wrong Task / out of order
refinement_approved The canonical Task's historical refine Activity only; matching approved termination/handoff evidence is present. Missing: deferred/activity_missing; terminal or same dedupe key: duplicate_noop. Different resolved/claimed Task: conflict/FACT_TASK_IDENTITY_CONFLICT; any phase other than refine: conflict/OUT_OF_ORDER_SIGNAL.
implementation_pr_observed The canonical Task's historical implementation Activity; within apply_workflow_signal()'s single BEGIN IMMEDIATE transaction, after legal canonical Task resolution, validate that the matching Issue and PR claims can both attach, attach both claims, then dedupe and record evidence/claim only. It never terminalizes that Activity. Missing: deferred/activity_missing; an existing same fact: duplicate_noop with no partial claim mutation. Different Task/claim or illegal attachment: conflict/FACT_TASK_IDENTITY_CONFLICT or conflict/OUT_OF_ORDER_SIGNAL, with no partial claim mutation.
pr_merged_observed The canonical Task's matching, nonterminal historical implementation Activity and validated Issue/PR claim; a fresh merged snapshot supplies the OID. Missing Activity or claim: deferred/IMPLEMENTATION_NOT_READY; same accepted fact on the same valid origin/Task: duplicate_noop. Different Task/PR: conflict/FACT_TASK_IDENTITY_CONFLICT; a new fact after cleanup began: late_noop/CLEANUP_ALREADY_BEGUN; any other non-ready phase: conflict/OUT_OF_ORDER_SIGNAL.
cleanup_completed The service resolves the canonical Task from fresh origin, then deterministically looks up and verifies its sole internal eligible selected/resumed nonterminal cleanup Activity for the validated Task/PR/merge identity and a previously accepted matching pr_merged_observed; callers never supply an Activity ID. Precedence is total: no accepted matching merged fact is conflict/OUT_OF_ORDER_SIGNAL; an accepted matching merged fact but no eligible bound internal cleanup Activity is deferred/CLEANUP_NOT_ELIGIBLE; terminal or same dedupe key is duplicate_noop. Resolved Task, PR, or merge identity mismatch is conflict/FACT_TASK_IDENTITY_CONFLICT; no instance/mismatch outcome mutates state.

Producer origin propagation is mandatory and preserves the local-only hot path:

Producer Authoritative origin source and adapter boundary Absent, stale, or different-Task origin
issue-refinement-loop Capture CLAUDE_CODE_SESSION_ID at the canonical approved termination/handoff publish and forward it as internal origin_session_id to its signal adapter. Hook-originated execution maps hook JSON session_id to the same field. Do not issue a signal: return diagnosable deferred/unbound for absent or stale (no open ExecutionRun/Binding) origin, or conflict/FACT_TASK_IDENTITY_CONFLICT for a different Task.
open-pr (new and EXISTING=true) Capture the invoking CLAUDE_CODE_SESSION_ID or hook JSON session_id when the producer starts and pass it, with only the validated canonical Issue/PR fact from its fresh snapshot, as internal origin_session_id to the adapter. open-pr does not individually pre-mutate either claim. Do not issue a signal; return deferred/conflict as above. DRY_RUN=true also emits no signal.
post-merge-cleanup At entry capture the invocation's CLAUDE_CODE_SESSION_ID or hook JSON session_id; after fresh merged-snapshot validation, propagate it unchanged to pr_merged_observed, then only on accepted or valid same-Task duplicate create/resume/select the bound cleanup lifecycle and persist internal cleanup_started, before dispatching work. Final success invokes cleanup_completed without a caller-selected Activity ID. If an entry origin closes while work runs, final completion is origin-first deferred/unbound and producer work is not rolled back. A later ordinary post-merge-cleanup invocation with a fresh origin resolves the existing Task and eligible cleanup instance: an existing final-success cleanup work result may replay cleanup_completed without creating a new cleanup Activity or dispatching worker/work twice; if no such record exists, it stays CLEANUP_PENDING with a diagnosable stop. Do not select/resume/start cleanup or dispatch worker/work on deferred, conflict, rejected, or late outcomes. If the origin is no longer open/bound, return diagnosable deferred/unbound; worker receipt, partial, failed, and human_review_required emit no cleanup signal.

Each producer retains completed producer work and records a diagnosable adapter outcome; deferred, conflict, duplicate_noop, late_noop, rejected envelope/evidence, or other rejected outcomes never roll it back. No producer returns, reconstructs, or substitutes a caller-selected identity. UserPromptSubmit remains local-only: it reads local claims without GitHub lookup, and a PR-claim miss passes through with no Task Context mutation.

Out of Scope

Acceptance Criteria

  • AC1: Only a structured refinement_approved emitted after canonical termination/handoff publish with termination_reason=approved can terminalize the historical refine Activity. It never terminalizes implementation or cleanup; missing/other termination evidence sends no signal.
  • AC2: The public v1 payload has exactly signal_kind, source, source_schema_version, and evidence; the first three are required JSON strings and evidence is an object. A duplicate-detecting JSON decoder runs before ordinary schema validation. Every envelope-level invalid input is non-mutating with exactly disposition: rejected_envelope and one fixed reason: MALFORMED_JSON, NON_OBJECT_ROOT, DUPLICATE_TOP_LEVEL_MEMBER, UNKNOWN_TOP_LEVEL_FIELD, WRONG_TOP_LEVEL_TYPE, UNKNOWN_SIGNAL_KIND, UNKNOWN_SOURCE, SOURCE_SIGNAL_MISMATCH, UNSUPPORTED_SCHEMA_VERSION, or FORBIDDEN_CALLER_IDENTITY as specified by the envelope table. Duplicate evidence members return non-mutating rejected_evidence/DUPLICATE_EVIDENCE_MEMBER; all evidence errors use rejected_evidence, never rejected_envelope. The kind/source pair map and exact string v1 version are enforced. Caller-supplied session_id, task_id, activity_id, or binding_id is rejected without mutation. The CLI maps CLAUDE_CODE_SESSION_ID, and hooks map JSON session_id, to internal origin_session_id; absent/unbound origin returns deferred without mutation. Producer success remains independent of this result.
  • AC3: The service follows total origin-first precedence: envelope/evidence validation and business-fact derivation; open ExecutionRun→Binding→canonical Task resolution; claim/Task consistency; same-Task accepted-fact dedupe; then, only for a new merged fact, cleanup-begun evaluation. Absent/stale/unbound origin is deferred/unbound before lookup; different-Task fact is conflict/FACT_TASK_IDENTITY_CONFLICT; valid same-Task same-fact is duplicate_noop even if cleanup has begun; a new merged fact after cleanup begins is late_noop/CLEANUP_ALREADY_BEGUN. Every earlier failure is non-mutating.
  • AC4: The service resolves canonical Task identity from origin, then applies fixed historical phase semantics: implementation_pr_observed only records claim/evidence; pr_merged_observed terminalizes only implementation; cleanup_completed terminalizes only the bound eligible cleanup Activity. A delayed/replayed signal cannot terminalize a different phase or regress state.
  • AC5: Before open-pr emits implementation_pr_observed for candidate Issue N and PR P, its fresh closingIssuesReferences(first: 2, excludeUserLinked: false, userLinkedOnly: false) classifier proceeds only for exactly one reference equal to N. Zero is named non-mutating deferred/NO_LINK; exactly-one mismatch is conflict/RELATION_ISSUE_MISMATCH; two-or-more is conflict/MULTIPLE_CLOSING_ISSUES; each has no signal or Task Context mutation. Snapshot fetch failure, GraphQL errors, partial or timeout responses, and null or malformed relation connection or nodes normalize to non-mutating deferred/RELATION_UNAVAILABLE, with no signal, mutation, or claim attachment. Only the validated matching fact and internal origin reach apply_workflow_signal(); open-pr never individually pre-mutates either claim. After legal canonical Task resolution, apply_workflow_signal(implementation_pr_observed) is the sole owner, in one BEGIN IMMEDIATE transaction, of validating legal attachment, attaching both Issue N and PR P claims, deduping the fact, recording the event, and enqueuing projection. A duplicate or conflict leaves no partial claim mutation. New and EXISTING=true paths replay the same fact; DRY_RUN=true does not signal; adapter failure does not roll back producer success.
  • AC6: UserPromptSubmit is local-only: claim miss for a PR performs no GitHub lookup and no Task Context mutation, and passes the prompt through. Before implementation_pr_observed, open-pr uses the structured fresh snapshot classifier: only exactly one relation equal to the candidate Issue can signal; zero is deferred/NO_LINK; exactly-one mismatch is conflict/RELATION_ISSUE_MISMATCH; multiple is conflict/MULTIPLE_CLOSING_ISSUES; snapshot fetch failure, GraphQL errors, partial or timeout response, and null or malformed relation connection/nodes are deferred/RELATION_UNAVAILABLE; every non-match/unavailable outcome has no signal, mutation, or claim attachment.
  • AC7: Generic mentions, branch/worktree names, comments, and Refs #N alone never establish Task equivalence. Existing guard behavior prevents a different active primary Task from being silently replaced.
  • AC8: Post-merge cleanup obtains and validates the fresh merged PR snapshot, applies pr_merged_observed, and only after applied or a valid-envelope/evidence same-canonical-Task same-business-fact duplicate_noop creates/resumes/selects the cleanup Activity and dispatches worker/work. Deferred, conflict, rejected envelope/evidence, late-noop, or any invalid outcome does neither. A cleanup Activity begun without accepted merged fact makes a later new merge fact late_noop/CLEANUP_ALREADY_BEGUN, a non-mutating stop with no external-work rollback.
  • AC9: The post-merge-cleanup main orchestrator durably owns cleanup begin after its accepted prerequisite: one service transaction creates/resumes/selects the sole eligible nonterminal cleanup Activity bound to the same Task/PR/merge identity and appends internal cleanup_started(activity_id, merge_identity). The public v1 envelope/evidence carries no cleanup handle. On final success, cleanup_completed resolves Task from fresh origin and deterministically looks up/verifies that sole internal instance from validated Task/PR/merge evidence; no caller-selected Activity ID is accepted. Missing instance or mismatch is an explicit non-mutating outcome. If the original origin closed, completion is origin-first deferred/unbound without rolling back producer work. A later normal post-merge-cleanup invocation with fresh origin resolves/resumes the existing Task and instance; it replays cleanup_completed from an existing final-success cleanup work result without creating an Activity or double-dispatching worker/work. Without that record it remains CLEANUP_PENDING with a diagnosable stop. Worker receipt, partial, failed, or human_review_required cannot complete cleanup.
  • AC10: events.dedupe_key plus a partial UNIQUE index physically prevents duplicate transitions. Identity uses signal kind plus the specified business fact only; source/version are metadata. For implementation_pr_observed, claim validation/attachment, dedupe, event append, and projection enqueue share the sole apply_workflow_signal() BEGIN IMMEDIATE transaction; duplicate or identity conflict leaves no partial claim mutation. Same fact resolved to a different Task is typed identity conflict, and producer success is not rolled back by non-applied outcomes.
  • AC11: Existing presentation regression tests for tests/task-context/test_statusline_render.py and tests/task-context/test_herdr_projection.py pass without changing their presentation contract.
  • AC12: evidence is strict per signal_kind: it validates the specified canonical repository/Issue/PR IDs and approved/merge representations, rejects invalid or forbidden evidence non-mutatively with typed rejected_evidence, and derives exactly the specified validated-values dedupe key.
  • AC13: The service follows the signal-by-state table and fixed historical Activity selection. Missing, terminal, wrong-Task, out-of-order, and late merged states return the named non-mutating disposition. cleanup_completed requires the same Task/PR/merge identity as an accepted merged fact and service-determined eligible internal cleanup Activity, with total precedence: no accepted matching merge is conflict/OUT_OF_ORDER_SIGNAL; only an accepted matching merge with no eligible bound cleanup Activity is deferred/CLEANUP_NOT_ELIGIBLE; Task/PR/merge mismatch is conflict/FACT_TASK_IDENTITY_CONFLICT.
  • AC14: issue-refinement-loop, open-pr, and post-merge-cleanup carry only their authoritative internal origin to the adapter. Absent/stale/different-Task origin emits no signal and is diagnosable as deferred/conflict; producer success is not rolled back and caller-selected identity cannot re-enter the path.

Verification Commands

# AC1
$ uv run --locked pytest tests/task-context/test_signal_refinement_approved.py -q

# AC2
# Includes every fixed rejected_envelope reason (including forbidden caller identity), plus duplicate-evidence-member rejection before ordinary schema validation.
$ uv run --locked pytest tests/task-context/test_signal_envelope_schema.py tests/task-context/test_signal_strict_json_rejection.py -q

# AC3
$ uv run --locked pytest tests/task-context/test_signal_origin_first_precedence.py -q

# AC4
$ uv run --locked pytest tests/task-context/test_signal_phase_monotonicity.py -q

# AC5
$ uv run --locked pytest tests/task-context/test_signal_producer_adapters.py -q

# AC6
# Includes zero/no-link, exactly-one match/mismatch, multiple, and each unavailable normalization: snapshot fetch failure, GraphQL errors, partial/timeout, null/malformed connection, and null/malformed nodes.
$ uv run --locked pytest tests/task-context/test_signal_github_relation_conflict.py -q

# AC7
$ uv run --locked pytest tests/task-context/test_signal_generic_reference_non_equivalence.py -q

# AC8
$ uv run --locked pytest tests/task-context/test_cleanup_pending_resume.py -q

# AC9
$ uv run --locked pytest tests/task-context/test_signal_cleanup_completed_commit_point.py -q

# AC10
$ uv run --locked pytest tests/task-context/test_events_dedupe_unique_constraint.py -q

# AC11
$ uv run --locked pytest tests/task-context/test_statusline_render.py tests/task-context/test_herdr_projection.py -q

# AC12
$ uv run --locked pytest tests/task-context/test_signal_evidence_schema.py -q

# AC13
# Includes deterministic internal cleanup-instance lookup, mismatch/no-instance non-mutation, and cleanup_completed precedence for accepted matching merge and bound cleanup Activity.
$ uv run --locked pytest tests/task-context/test_signal_state_transition_matrix.py -q

# AC14
$ uv run --locked pytest tests/task-context/test_signal_producer_origin_propagation.py -q

Run uv run --locked pytest tests/task-context -q after changed producers. Tests are deterministic service/equivalence/producer-adapter coverage in the existing suite; do not introduce a generic harness. They cover public-envelope rejection including malformed/non-object/duplicate-member JSON, strict evidence, origin-first precedence, phase-specific delayed replay, local-only prompt miss, total bounded relation states, producer commit points, physical dedupe, and resume.

Runtime Verification Applicability

decision: immediate
applicable_acs: [AC8]
execution_environment:
  cli_tools: [python3, uv]
  auth_required: false
  network_required: false
minimal_canary: "Run the existing local Task Context hook/workflow path: observe a merged implementation as CLEANUP_PENDING, then send a normal cleanup prompt and confirm the same Task resumes."
skip_conditions:
  - "No local repository checkout is environment blocked, not SKIP."
fallback_policy:
  fallback_success_is_pass: false
artifact_requirements: ["pytest output", "minimal canary output"]
reason: "Resume crosses the existing hook and workflow integration boundary; other ACs have deterministic tests."

Allowed Paths

  • scripts/task-context/**
  • tests/task-context/**
  • .claude/hooks/task_context/**
  • .claude/skills/issue-refinement-loop/**
  • .claude/skills/open-pr/**
  • .claude/skills/post-merge-cleanup/**
  • .claude/skills/post-merge-cleanup-executor/**
  • docs/dev/task-context.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • A generic framework, security boundary, all-prompt network lookup, or destructive history auto-merge is required.
  • Existing workflow result contracts require a breaking change, or completion would depend on natural-language output rather than a structured fact.
  • Implementing the strict envelope/evidence, origin-propagation, origin-first ordering, or signal-state contract requires a new framework, caller-selected identity, or network I/O on the UserPromptSubmit hot path.

Required Skills

なし

Required Design References

Delivery Rule

  • 1 Issue = 1 PR.
  • Re-read current main producer contracts before implementation.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor
    Image このGitHub Issueの実装内容とは直接関係ないかもしれませんが、タブやステータスラインに現れるタスクの内容について、タスクコンテクストという説明部分をなくして、内容だけにしてほしいです。

    つまり、スクリーンショットでいうと、UnboundやDegradedだけ表示してほしいです。

    ラベルの部分は不要です。

  2. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    結論

    判定は REQUEST_CHANGES。ただし #2565 の基本設計は維持してよいです。
    レビュー時点の main は 9f4430a8d81b51e501eb5838336923d710aeea85 で、#2563/#2564 の Task Context 基盤を前提に #2565 を実装できる状態です。 親 #2562 の既存レビューでも、#2565 trusted signals 自体は境界が明確で、SQLite SSOT・structured workflow signal・Task/Activity/ExecutionRun の方向は維持してよいと評価されています。

    問題はアーキテクチャの大枠ではなく、signal の適用点、idempotency、GitHub fallback、producer の commit point がまだ曖昧なことです。このまま実装すると、Task の誤完了や Issue/PR split-brain、あるいは #2564 で削った hot-path latency の再導入が起こり得ます。

    重要度 | Finding | 推奨 -- | -- | -- BLOCKER | 現行 signal apply が任意 task_id を受け付ける | 旧payloadを廃止し、session-origin型へ置換 BLOCKER | AC10 の durable dedupe がschema上存在しない | DB physical UNIQUE を追加 BLOCKER | claimless PR の GitHub lookup 失敗と「closing Issue 0件」が未区別 | 0 / 1 / multiple / unavailable の4状態化 BLOCKER | workflow signal の「いつ成功とみなすか」が曖昧 | producerごとのcommit pointを固定 HIGH | open-pr の EXISTING=true retry がsync修復できない可能性 | created/既存の両方で同じsignalを再送 HIGH | Task Context sync failure がproducer本体を失敗扱いし得る | workflow成功とTask Context同期を分離 HIGH | 指定コメントのUI要件が現在のAllowed Pathsでは実装不能 | #2565へ小さく取り込み、2 rendererだけ追加

    issue-refinement-loop の approved path は LOOP_HANDOFF_RESULT_V1 と publish_termination_report.py までを含みます。

    特に post-merge-cleanup が重要です。現行contractでは、SubAgentが POST_MERGE_CLEANUP_REPORT_V1 を返した後にmain threadが human_review_required を処理し、follow_up_issue_requests をissue-creatorへ渡す等の処理を行います。 Worker reportにも status: ok|partial|failed や stash_restored があります。

    したがって worker.status == ok && !human_review_required を見た瞬間にTaskをDONEへすると早すぎます。post-merge-cleanup orchestrator の最後の成功branchから signal を出すのが最小かつ正確です。新たなvalidator frameworkは不要です。

    HIGH — open-pr の既存PR pathでもsignalを再送する

    これは recovery 上かなり重要です。

    現行 open-pr は同じheadのopen PRを検出した場合、重複作成せず既存PRを返します。 実装も EXISTING=true, PR_URL, PR_NUMBER を出力します。 出力contractには LINKED_ISSUE と LINK_KIND も既にあります。

    例えば「PR作成は成功 → Task Context DB syncだけ失敗 → open-pr再実行」となった場合、EXISTING=false の新規作成時にしかsignalを出さない実装だと永久に自己修復できません。

    したがって signal 名も implementation_pr_created より implementation_pr_observed の方が正確です。EXISTING=false と EXISTING=true の両方で同じ canonical evidenceを再送し、AC10のdedupeに任せる設計を推奨します。dry_run だけは送信しません。

    加えて、origin Taskが既に別Issueをprimary claimしているのに open-pr linked_issue=N が来た場合は、Nを勝手にそのTaskへ追加せずtyped mismatchにしてください。これはsecurity対策ではなく、単純なTask identity correctnessです。

    HIGH — Task Context sync failureで本体workflowを失敗させない

    ここは今回の「ワークフローを妨げない」という方針から明文化を推奨します。

    PR作成、refinement approval、cleanup完了は、それぞれのworkflow producerがauthorityです。その後のTask Context DB syncが busy / unavailable / conflict になったからといって、既に成功したPR作成やcleanupを「失敗」に巻き戻してはいけません。

    Task Context adapterは、workflow resultとは別に applied / duplicate_noop / deferred / conflict 程度を返せば十分です。非hot-pathのproducer signalなら短いbounded retryをして構いませんが、daemon・message bus・汎用retry coordinatorを新設する必要はありません。

    これは親設計とも合っています。Task Contextはsecurity boundaryではなく、low-frictionなrouting/display layerとして維持する方針です。#2615 の過去レビューでも「checker/harnessに合わせてruntime architectureを歪めない」方向で修正されています。

    指定コメントは #2565 にそのまま取り込むのを推奨

    この要求は妥当です。別Issueを起こすほどではありません。

    コメントは「Task Context という説明ラベルを消し、Unbound / Degraded 等の内容だけ表示したい」と明示しています。 現行mainはstatusLineで実際に [Task Context: degraded (...)]、[Task Context: unbound] を出しています。 Herdr側も task-ctx: unbound で、テストまでその文字列を固定しています。

    外部仕様上も、このprefixに意味はありません。Claude Code statusLineはscript stdoutをそのまま表示する任意presentationです。(Claude) HerdrもTab labelを任意文字列でrenameでき、metadata/tokenはsemantic lifecycleとは分離されたdisplay-only情報です。(Herdr) (Herdr)

    私は次の表示に固定します。

    DB degraded / query failure / session failure -> Degraded
    Taskなし                              -> Unbound
    Taskあり statusLine                    -> 既存の ref/activity/attention/... のみ
    Herdr Taskなし                         -> Unbound
    Herdr Taskあり                         -> #N · <activity> の現行形式

    degraded_reason 自体はquery JSON内には残し、画面からだけ隠すのがよいです。トラブルシュート能力を捨てる必要はありません。

    ただし #2565 の現在の Allowed Paths は scripts/task-context/**, tests/task-context/**, 3 workflow skill配下だけなので、このコメントを今の本文のままでは実装できません。 ここだけscopeを次の2ファイルへ限定して拡張すれば十分です。

    .claude/hooks/task_context/statusline.py
    .claude/hooks/task_context/herdr_projection.py

    Acceptance Criteriaにも、

    AC11: statusLine / Herdr Task presentation は "Task Context" / "task-ctx"
    という説明prefixを表示しない。unboundは "Unbound"、degradedは
    "Degraded" のみを表示し、bound状態では既存のTask内容を直接表示する。
    diagnostic degraded_reason とDB semanticsは変更しない。

    程度を足すのが適切です。

    推奨する #2565 の最終形

    大規模な再設計は不要です。旧 signal apply {task_id,...} の廃止、physical dedupe、GitHub relationの4状態化、producer commit point固定、open-pr replay、UI prefix除去まで本文へ反映すれば、実装へ進めてよい水準になります。

    逆に、HMAC/signature、ACL、daemon、常駐poller、2PC、全promptでのGitHub問い合わせ、新しい汎用workflow harnessは不要です。今回必要なのはsecurity layerではなく、transaction境界・idempotency・外部factの意味論を単純に正しくすることです。

    ## 結論

    判定は REQUEST_CHANGES。ただし #2565 の基本設計は維持してよいです。
    レビュー時点の main は 9f4430a8d81b51e501eb5838336923d710aeea85 で、#2563/#2564 の Task Context 基盤を前提に #2565 を実装できる状態です。 親 #2562 の既存レビューでも、#2565 trusted signals 自体は境界が明確で、SQLite SSOT・structured workflow signal・Task/Activity/ExecutionRun の方向は維持してよいと評価されています。

    問題はアーキテクチャの大枠ではなく、signal の適用点、idempotency、GitHub fallback、producer の commit point がまだ曖昧なことです。このまま実装すると、Task の誤完了や Issue/PR split-brain、あるいは #2564 で削った hot-path latency の再導入が起こり得ます。

    重要度 Finding 推奨
    BLOCKER 現行 signal apply が任意 task_id を受け付ける 旧payloadを廃止し、session-origin型へ置換
    BLOCKER AC10 の durable dedupe がschema上存在しない DB physical UNIQUE を追加
    BLOCKER claimless PR の GitHub lookup 失敗と「closing Issue 0件」が未区別 0 / 1 / multiple / unavailable の4状態化
    BLOCKER workflow signal の「いつ成功とみなすか」が曖昧 producerごとのcommit pointを固定
    HIGH open-pr の EXISTING=true retry がsync修復できない可能性 created/既存の両方で同じsignalを再送
    HIGH Task Context sync failure がproducer本体を失敗扱いし得る workflow成功とTask Context同期を分離
    HIGH 指定コメントのUI要件が現在のAllowed Pathsでは実装不能 #2565へ小さく取り込み、2 rendererだけ追加

    BLOCKER — signal apply は「拡張」ではなく置換すべき

    #2565 は明確に、signal の対象を CLAUDE_CODE_SESSION_ID → open ExecutionRun → Binding → Activity から逆引きし、caller に任意 task_id を選ばせない契約です。

    ところが現在の task_contextctl signal apply は、

    task_id + repo + ref_kind + ref_number

    を必須入力にし、その task_id へ直接 claim_task_ref() しています。これは #2565 AC2 と真正面から衝突します。

    ここは後方互換を持たせない方がよいです。#2563 自身が operation envelope だけをfreezeし、signal apply の operation-specific payload は #2565 のような後続consumerで決める、と明示しています。 現時点でも production workflow は signal apply に未接続で、参照先はCLI・docs・testsが中心です。

    したがって新payloadは概念的に、

    signal_kind
    source
    source_schema_version
    evidence
    

    だけにし、task_id / activity_id / binding_id は入力禁止にするのを推奨します。Claude Code は現在、Bash subprocess に CLAUDE_CODE_SESSION_ID を提供し、hook の session_id と対応させています。既存ExecutionRun/Bindingをorigin authorityにする設計は成立します。(Claude)

    さらに apply_workflow_signal() のような粗粒度 service operation 一個にまとめ、origin resolve → state validation → dedupe → Activity/Task transition → event → projection enqueue を1回の BEGIN IMMEDIATE で処理すべきです。現在の service layer も #2615 の修正後は、この単一transactionパターンと「外部I/Oはservice transaction外」を明示しています。

    BLOCKER — AC10 の idempotency をDBで保証できる形にする

    #2565 は stable evidence identity / dedupe key と AC10 を要求しています。 しかし現行 events は id, task_id, activity_id, binding_id, execution_run_id, event_type, metadata_json, occurred_at だけで、dedupe key の物理的 uniqueness がありません。

    個人開発という前提なら新しいledgerを増やすより、events に nullable dedupe_key をadditive追加し、WHERE dedupe_key IS NOT NULL の UNIQUE indexを張る程度で十分です。eventsをstate replay sourceにする必要はありません。

    dedupe key はcallerの自由文字列を信用せず、service側で canonical evidence から導出するのがよいです。例えば refinement は repo + issue + final body_sha256、open-pr は repo + PR number、merge は repo + PR number + merge commit OID、cleanup は repo + PR + merge identity です。issue-refinement-loop は既に body_sha256 を持つ structured handoff contractを持っています。

    これなら concurrent duplicate も「先にSELECTしたから大丈夫」ではなくSQLite自身で防げます。

    BLOCKER — claimless PR lookup は4状態に固定する

    #2565 の「PR claimが無ければ GitHub relation を調べ、closing Issue がちょうど1つならそのIssue Taskへ吸収」は正しい方向です。問題はGitHub query失敗時の意味が定義されていないことです。

    GitHub GraphQL には正規の PullRequest.closingIssuesReferences があるため、PR本文を独自regexで Closes #123 検出する必要はありません。また excludeUserLinked のdefaultは false なので、Development sidebarから手動設定したclosing relationも含められます。([GitHub Docs]2) GitHub自身も、closing relationにはkeyword linkと手動linkの両方が存在し、default branchへのmergeでlinked Issueをcloseするものとして扱っています。([GitHub Docs]3)

    ここは closingIssuesReferences(first: 2) 程度の1 round-tripで十分です。推奨する意味論は、0件ならPR-primary作成可、1件ならIssue-primaryへ吸収、2件以上ならtyped conflict、timeout/auth/network failureなら unavailable としてpromptはPASSするがTaskを新規作成しない、です。

    特に unavailable を「0件」にfall backしてはいけません。そうすると一時的GitHub障害だけでPR-primary Taskができ、後でIssue Taskとのsplit-brainになります。

    #2564/PR #2615 では UserPromptSubmit hot pathを1秒に抑えるための修正まで行っています。現行コードも HOT_PATH_TIMEOUT_SECONDS = 1.0 を固定し、project hook側も2秒の上限です。 以前のレビューでも毎promptの不要な外部/subprocess処理は明確に問題視されています。

    したがって、GitHub lookupは「PR + local claim miss」の時だけ。まずは既存1秒budget内で bounded query、間に合わなければ state mutationせずPASS、が最も低摩擦です。実runtimeで成功率が低ければ、その時だけclaimless-PR専用budgetを少し広げればよく、全promptのtimeoutを伸ばす必要はありません。

    BLOCKER — signalごとの commit point を固定する

    「structured resultなら何でも即signal」にすると早すぎます。次の境界を固定するのがよいです。

    Signal Task Contextへ適用してよいcommit point
    refinement_approved final approved resultに加え、canonical termination/handoff publishが成功した後
    implementation_pr_observed PR create または既存PR検出後、canonical PR numberをreadbackできた時
    pr_merged_observed GitHub authorityで merged/mergedAt を確認した時
    cleanup_completed cleanup worker reportではなく、main orchestratorの全routing処理が正常終了した最後

    issue-refinement-loop の approved path は LOOP_HANDOFF_RESULT_V1 と publish_termination_report.py までを含みます。

    特に post-merge-cleanup が重要です。現行contractでは、SubAgentが POST_MERGE_CLEANUP_REPORT_V1 を返した後にmain threadが human_review_required を処理し、follow_up_issue_requests をissue-creatorへ渡す等の処理を行います。 Worker reportにも status: ok|partial|failed や stash_restored があります。

    したがって worker.status == ok && !human_review_required を見た瞬間にTaskをDONEへすると早すぎます。post-merge-cleanup orchestrator の最後の成功branchから signal を出すのが最小かつ正確です。新たなvalidator frameworkは不要です。

    HIGH — open-pr の既存PR pathでもsignalを再送する

    これは recovery 上かなり重要です。

    現行 open-pr は同じheadのopen PRを検出した場合、重複作成せず既存PRを返します。 実装も EXISTING=true, PR_URL, PR_NUMBER を出力します。 出力contractには LINKED_ISSUE と LINK_KIND も既にあります。

    例えば「PR作成は成功 → Task Context DB syncだけ失敗 → open-pr再実行」となった場合、EXISTING=false の新規作成時にしかsignalを出さない実装だと永久に自己修復できません。

    したがって signal 名も implementation_pr_created より implementation_pr_observed の方が正確です。EXISTING=false と EXISTING=true の両方で同じ canonical evidenceを再送し、AC10のdedupeに任せる設計を推奨します。dry_run だけは送信しません。

    加えて、origin Taskが既に別Issueをprimary claimしているのに open-pr linked_issue=N が来た場合は、Nを勝手にそのTaskへ追加せずtyped mismatchにしてください。これはsecurity対策ではなく、単純なTask identity correctnessです。

    HIGH — Task Context sync failureで本体workflowを失敗させない

    ここは今回の「ワークフローを妨げない」という方針から明文化を推奨します。

    PR作成、refinement approval、cleanup完了は、それぞれのworkflow producerがauthorityです。その後のTask Context DB syncが busy / unavailable / conflict になったからといって、既に成功したPR作成やcleanupを「失敗」に巻き戻してはいけません。

    Task Context adapterは、workflow resultとは別に applied / duplicate_noop / deferred / conflict 程度を返せば十分です。非hot-pathのproducer signalなら短いbounded retryをして構いませんが、daemon・message bus・汎用retry coordinatorを新設する必要はありません。

    これは親設計とも合っています。Task Contextはsecurity boundaryではなく、low-frictionなrouting/display layerとして維持する方針です。#2615 の過去レビューでも「checker/harnessに合わせてruntime architectureを歪めない」方向で修正されています。

    指定コメントは #2565 にそのまま取り込むのを推奨

    この要求は妥当です。別Issueを起こすほどではありません。

    コメントは「Task Context という説明ラベルを消し、Unbound / Degraded 等の内容だけ表示したい」と明示しています。 現行mainはstatusLineで実際に [Task Context: degraded (...)]、[Task Context: unbound] を出しています。 Herdr側も task-ctx: unbound で、テストまでその文字列を固定しています。

    外部仕様上も、このprefixに意味はありません。Claude Code statusLineはscript stdoutをそのまま表示する任意presentationです。(Claude) HerdrもTab labelを任意文字列でrenameでき、metadata/tokenはsemantic lifecycleとは分離されたdisplay-only情報です。([Herdr]5) ([Herdr]6)

    私は次の表示に固定します。

    DB degraded / query failure / session failure -> Degraded
    Taskなし                              -> Unbound
    Taskあり statusLine                    -> 既存の ref/activity/attention/... のみ
    Herdr Taskなし                         -> Unbound
    Herdr Taskあり                         -> #N · <activity> の現行形式
    

    degraded_reason 自体はquery JSON内には残し、画面からだけ隠すのがよいです。トラブルシュート能力を捨てる必要はありません。

    ただし #2565 の現在の Allowed Paths は scripts/task-context/**, tests/task-context/**, 3 workflow skill配下だけなので、このコメントを今の本文のままでは実装できません。 ここだけscopeを次の2ファイルへ限定して拡張すれば十分です。

    .claude/hooks/task_context/statusline.py
    .claude/hooks/task_context/herdr_projection.py
    

    Acceptance Criteriaにも、

    AC11: statusLine / Herdr Task presentation は "Task Context" / "task-ctx"
    という説明prefixを表示しない。unboundは "Unbound"、degradedは
    "Degraded" のみを表示し、bound状態では既存のTask内容を直接表示する。
    diagnostic degraded_reason とDB semanticsは変更しない。
    

    程度を足すのが適切です。

    推奨する #2565 の最終形

    大規模な再設計は不要です。旧 signal apply {task_id,...} の廃止、physical dedupe、GitHub relationの4状態化、producer commit point固定、open-pr replay、UI prefix除去まで本文へ反映すれば、実装へ進めてよい水準になります。

    逆に、HMAC/signature、ACL、daemon、常駐poller、2PC、全promptでのGitHub問い合わせ、新しい汎用workflow harnessは不要です。今回必要なのはsecurity layerではなく、transaction境界・idempotency・外部factの意味論を単純に正しくすることです。

  3. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    推奨は、comment 5616199676 を operator_asserted_human_context として canonical refinement loop に投入し、本文契約を更新して再レビューまで完走させることです。単なる再レビューではなく、anchor が列挙した BLOCKER/HIGH を Issue 本文へ反映する段階です。実際、現在も signal apply は task_id 等を直接受け取る実装のままで、events に durable dedupe key もありません。

    また、UI要件も未反映です。現行 statusLine は [Task Context: ...]、Herdr は task-ctx: unbound をまだ出力しているため、anchor が要求する2 renderer の Allowed Paths 追加と AC11 は有効な refinement delta です。

    注意点として、レビューコメントは main=9f4430... を前提にしていますが、現在の main HEAD は f36f41a7ae20b81e380807a4ce9c4d9b1e95d652 です。したがって、anchor の結論を盲目的に転記するのではなく、current main に対して再fact-checkしてから反映させます。 .claude/skills/issue-refinement-loop 自体は iteration approval をデフォルト不要としており、human-context lane、contract update、必要時の issue-editor handoff が既に定義されています。

    その前提で、auto mode の Claude Code には以下を渡すのがよいです。

    Issue #2565 に対して .claude/skills/issue-refinement-loop を canonical procedure どおり実行し、以下の anchor comment を direct interactive human instruction として扱ってください。

    Target Issue:
    #2565

    Human-context anchor:
    #2565 (comment)

    このメッセージ自体が operator による明示的な実行指示です。
    anchor は agent_report や unlabeled context として扱わず、operator_asserted_human_context として canonical with_human_context lane に投入してください。

    Objective

    anchor comment の REQUEST_CHANGES を #2565 の Issue contract へ正しく反映し、.claude/skills/issue-refinement-loop を human approval なしで bounded に完走させてください。

    目的は Issue 本文の refinement です。
    この作業では #2565 の実装PR作成やコード実装そのものには進まず、Issue contract が current main に対して implementation-ready / approve 相当になるところまでを対象としてください。

    Current-state rule

    anchor comment のレビュー時点では main SHA が 9f4430a8d81b51e501eb5838336923d710aeea85 でしたが、そのSHAを現在状態として固定しないでください。

    開始時に必ず current main HEAD、Issue #2565 本文、anchor snapshot、関連する #2562/#2563/#2564、必要な repository assets を fresh readback してください。

    current main に後続変更が入っている場合は、その実状態を authority として anchor findings を fact-checkしてください。
    anchor の記述を事実確認なしに機械転記しないでください。

    Human approval policy

    既に Claude Code は auto mode で起動しています。

    • refinement iteration 間の人間承認を求めない。
    • needs-fix は skill の bounded loop policy に従って自動継続する。
    • 「この変更を適用してよいですか」「次のiterationへ進めてよいですか」のような確認で停止しない。
    • このプロンプトに明記した設計判断や anchor comment の明示的 finding を、再度 human judgment に戻さない。
    • ただし skill 自身の genuine fail-closed condition、解消不能な新規 semantic ambiguity、environment/integrity failure、max-iteration exhaustion は捏造して突破せず canonical termination policy に従う。

    Claude Code permission mode自体や repository guardrail を変更する必要はありません。

    Canonical human-context flow

    .claude/skills/issue-refinement-loop/SKILL.md と command registry の current-main 定義をSSOTとして使用してください。

    anchor comment は canonical preflight.run.with_human_context profile で処理してください。

    trusted contract patch plan が得られた場合は canonical contract_update.run.with_human_context phaseへ進めてください。

    NEXT_ACTION: issue_editor_required が返った場合:

    • 同じ contract_update.run.with_human_context を no-progress retryしない。
    • anchor comment の再投稿を要求しない。
    • 人間に ANCHOR_SCOPE_REFRAME_V1 等の手書きpayloadを要求しない。
    • canonical issue-editor / edit-issue controlled transaction routeへhandoffする。
    • issue-editor の作業完了を必ず待つ。
    • mutation後、body/title readback、fresh preflight、fresh review、fresh readinessを最後まで実行する。

    SubAgent execution requirement

    必要な SubAgent を実際に使用してください。

    planner / skill contract が要求する場合は、少なくとも以下を適切にdispatchしてください。

    • codebase-investigator
    • web-researcher
    • issue-editor

    repository fact と外部仕様 fact の両方のinvestigationが必要なら、独立な read-only investigation は並列実行して構いません。

    重要:
    起動した全SubAgentの完了を必ず待ってください。

    fire-and-forgetは禁止です。
    SubAgentをspawnしたまま次工程へ進まないでください。

    Step 1 / Step 1b のSubAgentを起動した場合は、全結果をjoinしてからStep 2へ進んでください。
    issue-editorを起動した場合も、そのstructured resultとartifact/readbackを受け取るまでreviewを再開しないでください。

    SubAgentへ control-plane ownership や canonical final routing authority を移譲しないでください。

    Anchor findings to resolve

    anchor comment の各findingを current main に対してfact-checkした上で、依然有効ならIssue contractへ反映してください。

    少なくとも次を解消対象としてください。

    1. signal apply origin authority

    旧式の

    task_id + repo + ref_kind + ref_number

    をcallerが指定するsignal contractを維持しない。

    workflow signalは概念上、

    • signal_kind
    • source
    • source_schema_version
    • canonical evidence

    を入力とし、target Task/Activityは

    CLAUDE_CODE_SESSION_ID
    → open ExecutionRun
    → current Binding
    → current Activity / Task

    からservice側で解決する契約にする。

    caller inputとして任意の task_id / activity_id / binding_id を許可しない。

    origin resolve、state validation、dedupe、transition、event append、projection enqueue等、同一workflow signalに属するDB mutationは可能な限り1つの粗粒度service operation / BEGIN IMMEDIATE transactionで所有する。

    external I/Oはtransaction外に保つ。

    2. Durable idempotency

    AC10をapplication-side precheckだけにしない。

    canonical evidence由来のdedupe identityをDB physical constraintで保証する。

    新しい大規模ledgerを作る必要はなく、現在のschemaとの整合を確認した上で events 等の既存適切なsurfaceへの nullable dedupe key + partial UNIQUE index のような最小設計を優先する。

    dedupe keyはcaller自由入力をauthorityにせず、service側でcanonical evidenceから導出する。

    concurrent duplicate deliveryもDB constraintでno-op / typed duplicateとして処理できる契約にする。

    3. Claimless PR GitHub relation

    PR claim miss時のGitHub relation解決は以下を明示的に区別する。

    • zero closing Issues
    • exactly one closing Issue
    • multiple closing Issues
    • unavailable / lookup failure

    unavailable を zero と同一視してPR-primary Taskを作成しない。

    GitHub lookupは全promptのhot pathへ追加しない。
    PR promptかつlocal claim miss等、本当に必要なslow pathに限定する。

    temporary lookup failure時はTask split-brainを作るよりstate mutationを見送り、通常workflowを妨げない bounded behaviorを優先する。

    4. Producer commit points

    workflow producerごとのTask Context signal commit pointをIssue本文へ明示する。

    最低限:

    refinement_approved

    • final approved resultだけではなく、canonical termination/handoff publish完了後。

    implementation_pr_observed

    • PR新規作成または既存PR検出後、canonical PR numberをreadbackできた時。

    pr_merged_observed

    • GitHub authoritative merged factを確認した時。

    cleanup_completed

    • post-merge-cleanup worker report受信時ではなく、main orchestratorがhuman requirement/follow-up routing等を全て正常完了した最後のsuccess branch。

    worker reportだけでTask全体をDONEにしない。

    5. open-pr replay / recovery

    signal名は、current contractsとfact-checkして問題なければ implementation_pr_created より implementation_pr_observed を優先する。

    EXISTING=false の新規作成時だけでなく EXISTING=true の既存PR検出時にも同じcanonical evidenceを再送可能にする。

    Task Context syncのみ失敗した後の open-pr retryでself-healできるようにする。

    dry-runではsignalを送らない。

    origin Taskが別Issueをprimary claim済みなのに異なるlinked Issueが来る場合はsilent attachせずtyped identity conflict/mismatchにする。

    6. Workflow success と Task Context sync failure の分離

    workflow producer自身の成功をTask Context adapter failureで巻き戻さない。

    PR作成、refinement approval、cleanup等がauthority上成功済みなら、その後のTask Context syncが

    • busy
    • temporarily unavailable
    • duplicate
    • conflict

    等になってもproducer自身を「失敗したこと」にしない。

    adapter側は applied / duplicate_noop / deferred / conflict 等の独立した同期結果として扱う。

    非hot-pathなら短いbounded retryは可。
    daemon、message bus、常駐poller、汎用retry coordinatorは追加しない。

    7. UI presentation requirement

    comment #5615995722 のユーザー要望も #2565 に小さく取り込む。

    Allowed Pathsへ必要最小限として、current mainで実在を再確認した上で以下2 rendererを追加する。

    .claude/hooks/task_context/statusline.py
    .claude/hooks/task_context/herdr_projection.py

    presentation semanticsは次を目標とする。

    • DB/query/session degraded → Degraded
    • Taskなし → Unbound
    • bound statusLine → Task Context prefixなしで既存のref/activity/attention/worktree/branch/runtime-health等の内容を直接表示
    • Herdr unbound → Unbound
    • Herdr bound →既存 #N · <activity> 系表示を維持

    degraded_reason 等のdiagnostic情報はquery JSON / internal diagnosticsには残し、presentationからだけ隠す。

    Acceptance CriteriaへAC11相当を追加し、

    • "Task Context" prefixを表示しない
    • "task-ctx" prefixを表示しない
    • unboundは Unbound
    • degradedは Degraded
    • bound状態ではTask内容を直接表示
    • diagnostic semantics / DB semanticsは変更しない

    ことを明示する。

    関連testsは既存 tests/task-context/** scope内で表現可能か確認し、VCにも反映する。

    Keep the architecture small

    今回のrefinementを理由として以下を追加しない。

    • HMAC/signature layer
    • ACL framework
    • daemon
    • persistent poller
    • message bus
    • 2PC
    • generic workflow harness
    • 全prompt GitHub lookup
    • Task Contextをsecurity boundary化する設計

    個人趣味開発として、correctness・recovery・idempotency・使いやすさを優先し、checker/harness/securityのためにruntime workflowを重くしない。

    Review loop

    Issue本文を書き換えたら必ずfresh evidenceで再レビューする。

    canonical Step 2 routing authorityを再実装しない。
    root-owned review pipelineのresultをそのままconsumeする。

    semantic design reviewがapplicableなら実施し、その結果もcanonical join/routingに従う。

    needs-fix の間はmax_iterations内で自動修正を継続する。

    最終的には少なくとも以下を確認する。

    Final response

    完了時は簡潔に以下を報告してください。

    1. 最終 verdict / next action
    2. Issue本文へ反映した主要delta
    3. 実行したSubAgentと、それぞれcompletion join済みであること
    4. final Issue body SHAまたは同等のreadback identity
    5. 実行したverification / review結果
    6. unresolved blockerの有無
    7. implementationへ進める状態かどうか

    人間承認待ちで終了しないでください。

    この形なら、特に UIのAllowed Paths拡張を「別Issueにするか?」と再質問される余地と、anchorをagent-generated report扱いされてscope mutation authorityを失う余地を先に潰せます。anchor 自体も「基本設計維持・7項目を修正・過剰なsecurity/harnessは不要」という結論なので、この refinement は方針選択ではなく契約の具体化として進めるのが適切です。

  4. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    実施内容

    1. Step 0f preflight(preflight.run.with_human_context): 初回は issue_kind: implementation の必須4セクション(Parent Goal Ref / Current Validated Scope / Remaining Parent Gaps / Required Skills)欠落で STATUS: blocked を検出(structural_repair_action disposition: human_review_required、自動derivation不可)。
    2. codebase-investigator / web-researcher を並列起動し、anchor findingsを現在mainに対してfact-check(task_contextctl.py signal_applyが任意task_idを受理、eventsテーブルにdedupe UNIQUE制約なし、open-pr/post-merge-cleanup-executorの既存出力契約、Claude Code statusLine仕様等を実コード・公式ドキュメントで検証)。
    3. issue-editor へ3回のcontrolled transactionを委譲し、Issue本文を段階的に更新(body_sha256: 93552aa4... → 33a13fc2... → 81b3cf84... → cf3b2341...)。
    4. canonical Step 2 deterministic review(run_root_review_pipeline.py produce)は最終的に VERDICT: approve / canonical_step2_route: step_2_5。
    5. Step 2.5 semantic design review(issue-design-reviewer, model: opus、cross-contract change検出により昇格)を3回実施。1回目でBLOCKER×1・HIGH×1を検出・修正。2回目でBLOCKER×1(CLAUDE_CODE_SESSION_ID環境変数の実在性)・HIGH×2を検出し、web-researcherでClaude Code公式GitHub issue(#27299, #47018)を確認した上で該当環境変数が未実装であることを確認・修正。3回目でBLOCKERは解消されたが新規HIGH×2(session-origin逆引きとclaim起点target解決の順序矛盾/docs/dev/task-context.mdがAllowed Paths外)を検出。

    停止理由

    semantic_rewrite_constraints.max_rewrite_attempts: 2 に対し、semantic design review由来の rewrite を既に2回実施済み(3回目のreviewでも新規HIGHが残った)。3回目のHIGH指摘のうち1件(session-origin逆引きの解決順序と、claim経由のTask解決との整合)は genuine な owner 判断(claim解決時にsessionをTask/Activityへbindする設計にするか、claim-resolved targetをsession-originと同格の別経路として明示的に許可するか)を要するため、これ以上の自動rewriteで捏造的に「解決済み」と扱わずcanonical termination policyに従い停止する。

    Blockers(3回目semantic reviewの未解決所見)

    • HIGH(owner判断要): session-origin逆引き(AC2)と claim起点target解決(AC4/AC7/AC8、特にpr_merged_observed)の順序契約が未定義。unbound Tab起点のPRプロンプトでcatch-upが到達不能になりうる。
    • HIGH(editorial、次回rewriteで解消可能): docs/dev/task-context.md(DB invariant/UNIQUE index表・payload open原則の正本)がAllowed Paths / Required Design References に未追加。
    • MEDIUM×4(owner判断混在): result kind/typed codeの対応未整理、dedupe keyのscope未定義、AC5の4状態判別機構未指定、AC1のnegative case未網羅。
    • LOW×1: AC11のpresentation状態列挙がstatusline.pyの[Task Context: no session]分岐を網羅していない。

    実行したSubAgent(すべてjoin済み)

    • codebase-investigator(task-context契約のfact-check)— join済み
    • web-researcher(Claude Code statusLine仕様、Herdr CLI仕様、CLAUDE_CODE_SESSION_ID実在性)— 2回起動、いずれもjoin済み
    • issue-editor(本文更新)— 3回起動、いずれもjoin済み・body_sha256で成功確認済み
    • issue-design-reviewer(Step 2.5 semantic design review, model: opus)— 3回起動、いずれもjoin済み

    次のアクション

    Issue本文(現在の body_sha256: cf3b2341e17b60ac1b1b9656592e55bfdd9d6f858a12636e6f9d8992f7d3636e)は anchor comment のBLOCKER/HIGH 7件をすべて反映済みで、deterministic checkerはapproveです。残る争点は上記HIGH「session-origin逆引きとclaim起点target解決の順序」に関するアーキテクチャ判断のみです。owner判断が得られ次第、issue-refinement-loopを再実行してください。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
  5. squne121 commented on Sep 10, 2026

    @squne121
    OwnerAuthor

    推奨は 「claim-resolved target を signal apply の第二 authority にしない」 です。代わりに、claim / GitHub relation を pre-bind routing に使い、既存 #2564 のルールに従って current session を canonical Task/Activity へ bind/rebind した後、signal apply は session-origin だけで target を解決する構造に固定するのがよいです。

    理由は、現行 UserPromptSubmit がすでに「unbound なら target へ autobind」「terminal Activity なら bind/rebind」「ACTIVEな別primary targetなら block」という順序を持っているためです。さらに bind_target_to_binding() は Task解決、Activity確保、ExecutionRun attach、event、projection を単一 BEGIN IMMEDIATE で扱う既存の原子的境界があります。ここに PR claim / closing-Issue relation の pre-resolution を足す方が、signal apply に session と claim の二重authorityを持たせるより小さく、一貫しています。

    また、main は escalation 時点と同じ f36f41a7... で、停止コメントが指摘した HIGH はまだそのまま解決対象です。 前回は semantic rewrite 上限に達したため止まっただけなので、新規セッションでは今回の owner decision を新しい human context として投入し、counterを手動リセット・迂回せず canonical route で再開させるべきです。停止コメントに残った docs/dev/task-context.md、MEDIUM/LOW も同じ refinement で畳み込ませます。

    前回プロンプトでも SubAgent は fire-and-forget 禁止、全結果を join 後に次工程へ進む契約でした。今回もそれを明示的に維持します。

    以下を、新規に起動した auto mode の対話的 Claude Code にそのまま渡すのを推奨します。

    Issue #2565 の issue-refinement-loop を、新しい owner decision を与えた continuation として再開してください。

    対象:

    このセッションは新規セッションです。前セッションの会話状態、scratchpad、SubAgent結果、artifactを暗黙に引き継がないでください。

    この作業では #2565 のコード実装・実装PR作成には進まないでください。
    目的は、Issue contractをcurrent mainに対して再精緻化し、deterministic review / applicable semantic design review / readiness を通して implementation-ready / approve 相当にするところまでです。

    既に Claude Code は auto mode で起動しています。
    refinement iteration間の人間承認は不要です。
    Claude Codeのpermission modeやrepository guardrailを変更する必要はありません。

    最初にfresh readbackすること

    開始時に必ず以下をfresh readbackしてください。

    前回review時のmainは f36f41a7ae20b81e380807a4ce9c4d9b1e95d652、Issue body SHAは
    cf3b2341e17b60ac1b1b9656592e55bfdd9d6f858a12636e6f9d8992f7d3636e
    でしたが、これらを現在状態として固定しないでください。

    current main / current Issue body が変化していれば、fresh readbackした実状態をauthorityにしてください。

    前回のsemantic review artifactをそのまま再利用してapprove扱いにせず、必要なreview evidenceはfreshに生成してください。

    今回のOwner Decision

    前回human escalationで未決定だった、

    「claim解決時にsessionをTask/Activityへbindするか」
    vs
    「claim-resolved targetをsession-originと同格のsignal target authorityにするか」

    について、owner decisionを以下で固定します。

    採用: resolve/bind-before-signal、signal target authorityはsession-originのみ

    claim-resolved targetを signal apply の第二target authorityにはしないでください。

    claim / Issue-PR relation / GitHub relation は、
    signal targetを直接指定するauthorityではなく、current sessionをcanonical Task/Activityへ合法的にbind/rebindするための pre-bind routing evidence
    として扱ってください。

    概念上の順序を以下に固定します。

    1. prompt / workflow context から対象Issue/PRを識別する。
    2. local task_ref_claims を最初にresolveする。
    3. PR claim missの場合のみ、#2565で許可したbounded slow pathとしてGitHub relationを解決する。
    4. relation結果からcanonical Taskを確定する。
    5. #2564の既存UserPromptSubmit guard / rebind semanticsに従い、current Binding / ExecutionRun / Activityをそのcanonical Taskへbind/rebindする。
    6. bind/rebindがcommitした後、workflow producerのstructured factを確認する。
    7. signal apply は session_id → open ExecutionRun → current Binding → current Activity/Task の単一経路のみでtargetを解決する。
    8. signal適用・dedupe・transition・event append・projection enqueueをcanonical service transactionで処理する。

    claimによって別Taskが見つかっても、ACTIVEなcurrent primary Taskを無条件に乗り換えてはいけません。

    既存 #2564 の、

    • unbound → autobind可能
    • terminal/rebindable → normal promptからlegal bind/rebind可能
    • ACTIVEな異なるprimary target → block
    • /task → explicit human escape hatch

    というguard semanticsを維持してください。

    つまり、claim-resolved Taskを使ってsignal applyからwrong-session guardを迂回する設計は禁止です。

    Claimless PR resolution

    PR promptでlocal PR claimがない場合のみbounded GitHub slow pathを使用してください。

    current-mainの実装・GitHub取得契約をfact-checkした上で、少なくとも以下を区別してください。

    • zero closing Issues
    • exactly one closing Issue
    • multiple closing Issues
    • unavailable / lookup failure

    unavailableをzero扱いしないでください。

    exactly one closing Issueの場合は、そのIssueのcanonical Taskをresolve/createした上で、Issue claimとPR claimを同一Taskへatomicに所属させ、そのTaskへcurrent Binding / ExecutionRun / Activityをbindしてください。

    その際、

    • GitHub external I/O
    • SQLite write transaction
    • binding/ref claim mutation

    の境界を混ぜないでください。

    GitHub relationはtransaction外で取得し、fresh resultを入力として単一の粗粒度DB mutationを行ってください。
    transaction取得後にGitHub network I/Oを実行しないでください。

    relation取得後からtransaction開始までに競合が起き得るため、transaction内ではlocal claimを再検証し、raceで別Taskがclaimを獲得済みならその事実をauthorityとしてtyped conflictまたは既存canonical Taskへの安全な収束を行ってください。

    新しい2PC、daemon、message bus、persistent poller、汎用retry coordinatorは導入しないでください。

    pr_merged_observed の順序

    pr_merged_observedについても同じauthority ruleを適用してください。

    PR promptに対するcanonical Task解決と合法なbind/rebindをsignal applyより先に完了させてください。

    GitHubのmerged factはstrong external factとして扱いますが、それ自体で任意Taskをsignal targetにしてはいけません。

    概念上:

    canonical PR/Task relation resolve
    → legal session bind/rebind
    → authoritative merged fact confirmation
    → pr_merged_observed signal apply via current session-origin

    としてください。

    relationとmerged stateを同じfresh PR snapshotで安全に取得できる既存surfaceがあるなら、そのsnapshotを再利用して構いません。ただしDB transaction中のexternal I/Oは禁止です。

    bindingが成立しない、current ACTIVE Taskとのidentity guardに抵触する、または必要なrelation evidenceがunavailableなら、他Taskへ直接signalを当てず、canonical typed outcomeへ流してください。

    Task Context syncがdeferred/conflictになっても、すでに成功しているproducer本体のworkflow resultを巻き戻してはいけません。

    Durable dedupeに関するowner direction

    dedupe identityはcanonical workflow factのidentityを表し、sessionや解決後Taskのidentityには依存させない方針にしてください。

    概念上、

    • signal_kind
    • source
    • source_schema_version
    • producer固有のstable canonical evidence identity

    からservice側でdedupe identityを導出してください。

    session_id / task_id / activity_id / binding_id をdedupe identityへ混ぜて、同じexternal factが複数Taskへ二重適用できる形にしないでください。

    同一dedupe identityのreplayが、

    • 同じcanonical Taskへ解決される → duplicate_noop
    • 別Taskへ解決される → identity conflict

    となる契約を優先してください。

    実際のkey構造、schema、partial UNIQUE indexの配置は、current docs/dev/task-context.md / schema / migration conventionsをfact-checkして最小設計を選んでください。

    新しい大規模ledgerは作らないでください。

    残存semantic findingsも同時に解消すること

    前回のHIGH/Medium/Lowを今回のowner decisionに従ってまとめて解消してください。

    特に:

    • docs/dev/task-context.md を Allowed Paths と Required Design References に追加する。

      • schema/invariant/payload contract変更に伴って更新が必要なら本Issueの正規scopeとして扱う。
    • result kindとreason/error discriminatorの対応を閉じる。

      • applied / duplicate_noop / deferred / conflict はdispositionとして扱い、
        transient/unbound/identity contradiction等のreasonとは混同しない。
      • exactなcode名はtask_context_errors.py等のcurrent-main conventionをfact-checkして最小集合にする。
      • repoに根拠のないcode名を大量に新設しない。
    • legacy direct-target payloadの扱いと、missing/unbound sessionの扱いを同じreasonへ潰さない。

    • dedupe keyのscopeをIssue contract上で明文化する。

    • claimless PR relationの4状態判別機構を具体化する。

      • current repositoryで使われているclosingIssuesReferences等のstructured GitHub evidenceを優先し、文字列heuristicに落とさない。
    • AC1に termination_reason != approved またはcanonical termination/handoff publish未完了ならrefinement_approvedを送らないnegative caseを追加する。

    • statusLineのno session presentationは、人間向け表示ではUnboundへ統合する方向を採用する。

      • internal diagnostic reasonは保持する。
    • AC/VCとAllowed Pathsを相互整合させる。

    これらのeditorial / taxonomy / testability上の選択は、current-main conventionsと上記owner directionから合理的に一意化できる限り、人間へ再質問せず自律的に解消してください。

    SubAgent必須運用

    SubAgentを使用してください。

    最低限、必要に応じて以下を使ってください。

    codebase-investigator

    current mainに対して以下をfact-checkさせてください。

    • on_user_prompt_submit
    • bind_target_to_binding
    • absorb_ref_into_task
    • task_ref_claims
    • ExecutionRun / Binding / Activityの現在のrebind semantics
    • signal apply / CLI envelope
    • result/error taxonomy
    • DB schema/migration/index conventions
    • docs/dev/task-context.md
    • open-pr
    • issue-refinement-loop
    • post-merge-cleanup
    • PR relation取得の既存repository assets

    特に、
    「claim/GitHub relation resolve → legal binding → session-origin signal」
    を入れる最小のcontract seamを調査させてください。

    web-researcher

    外部仕様がmaterialな箇所だけ使用してください。

    例:

    • GitHub closing Issue structured relationの実際の仕様
    • Claude Codeのsession identity/runtime contract

    既に確認済みの事実を無意味に再検索する必要はありませんが、current Issueへ外部仕様を断定して書く場合は必要な範囲をfresh確認してください。

    issue-editor

    Issue本文mutationはcanonical controlled transaction routeで行わせてください。

    main orchestrator自身がad-hocにIssue本文を書き換えてcontrol-plane ownershipを迂回しないでください。

    issue-design-reviewer

    deterministic review後、Step 2.5がapplicableならfresh pinned bodyでsemantic reviewしてください。

    cross-contract変更が大きければcurrent skill policyに従って適切なmodel overrideを使用してください。

    Completion join barrier — 必須

    起動した全SubAgentの作業完了を必ず待ってください。

    fire-and-forgetは禁止です。

    独立read-only investigationは並列起動して構いませんが、

    • codebase-investigator
    • web-researcher

    を起動した場合、両方の結果をjoinしてからcontract patch planを確定してください。

    issue-editorを起動した場合、そのstructured resultとIssue body readbackを受け取るまでfresh reviewへ進まないでください。

    issue-design-reviewerを起動した場合、その出力を実際に受領してcompletion joinした後にのみsemantic transport / join / routingを続行してください。

    SubAgentへcanonical routing authority、control-plane ownership、最終termination判断を移譲しないでください。
    main/root Claude Codeが最後までorchestratorです。

    nested delegationがcurrent agent contractで禁止されている場合は、その禁止を守ってください。

    Canonical issue-refinement-loop

    .claude/skills/issue-refinement-loop/SKILL.md とcurrent command registryをSSOTとして実行してください。

    今回のpromptは、前回human escalationを解決する明示的なowner decisionです。

    original anchor #5616199676 と前回termination #5616778522をhistorical evidenceとして読み、このpromptのowner decisionをcurrent human contextとして扱ってください。

    current skillがinteractive owner decisionのmaterializationを要求する場合は、そのcanonical routeを使用してください。

    以下は禁止です。

    • 私にanchor commentの再投稿を要求する
    • 私に手書きの独自schema/payloadを要求する
    • semantic rewrite counterを手動改変する
    • max_rewrite_attempts guardをバイパスする
    • stale semantic artifactをapprove evidenceとして再利用する
    • canonical Step 2 routingを独自実装する

    これは新しいowner-directed continuationなので、rewrite attempt lifecycleはcurrent canonical routerの判断に従ってください。

    前回上限に到達したcounterを手作業でリセットして成功を偽装してはいけません。

    Review loop

    Issue本文mutation後は毎回:

    fresh body/title readback
    → guard / preflight
    → canonical deterministic Step 2 review
    → applicableならfresh Step 2.5 semantic review
    → readiness
    → canonical next-action routing

    まで行ってください。

    needs-fixであり、current canonical budget内で修正可能なら人間承認なしで自動修正を継続してください。

    今回owner decisionで解消済みの
    「session-origin vs claim-resolved target authority」
    について再びowner判断を要求しないでください。

    新しいgenuine blockerが発生しない限り、HIGH/MEDIUM/LOWのeditorial/design completeness findingsはcurrent code/docsとこのdirectiveを使って自律的に収束させてください。

    完了条件

    少なくとも以下を確認してください。

    • signal target authorityがsession-origin 1本に固定された
    • claim/GitHub relationはpre-bind routing evidenceとしてのみ使用される
    • unbound/rebindable PR/cleanup promptからcanonical Taskへ到達可能
    • ACTIVEな別Taskへのsilent rebindは再導入されていない
    • pr_merged_observedのresolve/bind/signal順序が明文化された
    • claimless PRの0 / 1 / multiple / unavailableが明確
    • GitHub external I/OがSQLite write transaction外
    • durable dedupe scopeが明確
    • same evidenceが別Taskへ二重適用されない
    • producer成功とTask Context sync failureが分離されている
    • docs/dev/task-context.mdがAllowed Paths / Required Design Referencesに入った
    • result kind / reason taxonomyが閉じている
    • AC1 negative caseが入った
    • no-session presentationが明確
    • AC/VC/Allowed Paths/Stop Conditionsが相互整合
    • current mainに対するdeterministic reviewがapprove
    • applicable semantic reviewにopen BLOCKER/HIGHがない
    • contract readinessがgo

    implementation-readyになったら、そこで停止してください。
    コード実装・実装PR作成には進まないでください。

    最終報告

    完了時は簡潔に以下を報告してください。

    1. final verdict / next action
    2. 採用したtarget-resolution/binding ordering
    3. Issue本文へ反映した主要delta
    4. 実行した全SubAgentと、それぞれcompletion join済みであること
    5. final Issue body SHAまたは同等のreadback identity
    6. deterministic review / semantic review / readiness結果
    7. unresolved BLOCKER/HIGHの有無
    8. Issue #2565がimplementation-readyになったか

    人間承認待ちを通常の終了条件にしないでください。
    今回明示したowner decisionの範囲では、自律的にapprove / implementation-readyまで収束させてください。

    このプロンプトでは、前回の未決HIGHだけでなく、次のsemantic reviewで再度止まりやすい dedupe scope・result taxonomy・4状態判別・AC1 negative・no-session表示にも方向性を与えています。これにより、新規セッションを単なる「rewrite上限のやり直し」にせず、残った設計不確定性を一度で閉じる狙いです。

  6. squne121 commented on Sep 17, 2026

    @squne121
    OwnerAuthor

    結論

    REQUEST_CHANGES 相当です。 ただし、#2565 の中心思想――structured workflow fact を trusted signal とし、SQLite を SSOT にして Issue/PR split-brain を防ぐ――は維持してよいです。

    前回コメントで挙がった task_id 直指定、physical dedupe、GitHub relation の4状態、producer commit point、EXISTING=true replay、producer fail-open は現行本文へかなり取り込まれています。 一方、2026-09-17 時点の main は fa54f0b0... まで進んでおり、Issue 自体の最終更新は9月15日なので、その後の関連実装も含めて再評価すると、新たに2件の blocker と数件の設計上の高優先修正があります。

    重要度 | Finding | 推奨 -- | -- | -- BLOCKER | Claude Code session ID の前提が現在は誤り | CLAUDE_CODE_SESSION_ID を自動利用し、caller 明示 session_id を廃止 BLOCKER | delayed/replay signal が「現在の Activity」に誤適用され得る | session は Task 解決だけに使い、signal ごとに phase/activity semantics を固定 HIGH | dedupe identity に source_schema_version / source を混ぜている | business fact identity のみにする HIGH | PR prompt で GitHub network lookup を行う設計 | UserPromptSubmit を local-only に保ち、workflow producer 側へ寄せる HIGH | Issue 本文内に既に解決済み/矛盾した scope が残る | 実装前に contract cleanup MEDIUM | GitHub GraphQL relation の新しい引数意味論を暗黙値に依存 | excludeUserLinked を明示 MEDIUM | AC/test surface が広がり過ぎる余地 | generic harness を増やさず既存 pytest + 最小 canary に限定

    BLOCKER — session_id の前提が古くなっている

    現行 #2565 は、Claude Code が subprocess に session ID を環境変数として公開しないため、

    signal_kind / source / source_schema_version / session_id / evidence

    を caller が明示的に渡す、と定義しています。

    これは現在の Claude Code 仕様と一致しません。公式ドキュメントでは CLAUDE_CODE_SESSION_ID が Bash/PowerShell tool subprocess に自動設定され、hook に渡される session_id と一致し、/clear 時にも更新されることが明記されています。Week 19 の公式更新にも同じ変更が記載されています。(Claude) Hooks 側も全 hook 共通入力として session_id を受け取ります。(Claude)

    つまり、以前の GitHub issue #27299/#47018 は当時は正しかったが、後の Claude Code 更新で解消済みです。興味深いことに、#2565 の以前のレビューコメント自身は既に CLAUDE_CODE_SESSION_ID が利用可能だと正しく記載していました。現行 Issue 本文でそこだけ古い前提に戻っています。

    ここはワークフローを軽くできます。task-contextctl signal apply の public payload は、

    signal_kind
    source
    source_schema_version
    evidence

    だけで十分です。CLI adapter が CLAUDE_CODE_SESSION_ID を読み、内部 service call の origin_session_id に変換する。hook 経路なら hook JSON の session_id を使う。環境変数が無い非 Claude 実行だけ deferred/unbound にすればよいです。

    現在の signal apply が task_id + repo + ref_kind + ref_number を直接要求しているのは、Issue が置換予定としている通りです。 任意 task_id を禁止する目的は維持しつつ、session ID を人間/LLMに運ばせる余計な配線は削除できます。

    BLOCKER — replay と「current Activity」方式が両立していない

    こちらの方がデータ整合性上は深刻です。

    #2565 は、Task Context sync が失敗しても producer 本体は成功させ、後から EXISTING=true 等で同じ signal を replay して self-heal する設計です。同時に、signal target は、

    session_id → ExecutionRun → Binding → current Activity/Task

    だけから決める、としています。

    この2つを組み合わせると、signal 発生時と replay 時で Activity が変わっているケースが未定義です。

    例えば refinement 自体は正常終了したが Task Context sync が busy で失敗。そのまま利用者は implementation に進む。その後 replay された refinement_approved が current Activity=impl を解決した場合、service が「current Activity を terminalize」という実装なら、実装 Activity を誤って完了させる余地があります。

    Task Context は意図的に producer を止めないため、これは異常系ではなく設計上想定すべき正常な遅延 deliveryです。

    session-origin は Task identity の決定までにした方が安全です。その後は signal ごとの意味論を service が持つべきです。例えば refinement_approved は refine Activity 以外を絶対に terminalize しない、pr_merged_observed は implementation phase にだけ作用し、既に cleanup へ進んでいれば state regression せず late/no-op とする、cleanup_completed は cleanup Activity にのみ作用する、という単調な state transition にします。

    既存 schema は Task 当たり ACTIVE Activity を1件に物理制約しており、履歴 Activity も保持するので、この実装のために新しい framework は不要です。

    HIGH — dedupe key に transport version を入れない方がよい

    現行 AC10 は dedupe identity に、

    signal_kind + source + source_schema_version + canonical evidence

    を含めます。

    これは idempotency の意味として不安定です。

    implementation_pr_observed(repo=X, PR=123) が v1 producer で一度適用された後、単なる schema evolution で producer v2 が同じ PR を再送すると、現実世界では同じ factなのに別 dedupe keyになります。source の rename/producer 移管でも同じです。

    dedupe identity は business fact に固定する方がよいです。

    implementation_pr_observed = repo + PR number、pr_merged_observed = repo + PR + merge commit OID、refinement_approved = repo + issue + approved body hash、cleanup_completed = repo + PR + merge identity。

    source と source_schema_version は event metadata に残せば、診断性を失いません。

    events.dedupe_key + partial UNIQUE 自体は適切です。SQLite は partial UNIQUE index を正式にサポートするため、大きな ledger を追加する必要はありません。(SQLite) 現行 events にその列がまだ無いことも current main で確認できます。

    HIGH — GitHub lookup を UserPromptSubmit から外したい

    #2565 は PR prompt の local claim miss 時に closingIssuesReferences を問い合わせ、claim hit + implementation nonterminal 時には merged state まで確認する設計です。

    structured relation を使うこと自体は正しいです。GitHub は PullRequest.closingIssuesReferences を正式提供しています。(GitHub Docs)

    ただし、UserPromptSubmit に network I/O を戻す必要はありません。

    PR #2615/#2632 は Task Context を低摩擦化するため hook 処理をかなり慎重に設計しており、#2632 では timeout budget を増やさず、Task Context の mismatch/sync failure で workflow を止めない方向へ明確に修正されています。 SQLite 側の BEGIN IMMEDIATE についても、writer 競合時には SQLITE_BUSY が起こり得るので、外部I/Oを transaction 外へ出す現行方針は正しいです。(SQLite)

    個人開発で操作感を優先するなら、通常 hook は local DB lookupだけにするのがよいです。claimless PR は Task Context mutationせず prompt をそのまま通し、open-pr、post-merge-cleanup、必要なら review workflow が GitHub snapshot を既に取得する時に relation/merged fact を解決して signal する。

    特に pr_merged_observed は post-merge-cleanup preflight と非常に相性がよいです。一般的なPR promptを見るたびにGitHubへ行く実益は小さいです。

    HIGH — Issue 本文の contract を一度掃除すべき

    反復 refinement の跡が残っています。

    本文上部では pr_merged_observed の trigger/producer/commit point が「未確定」と残っていますが、その後の In Scope では claim hit → bind → GitHub merged確認 → signal apply と commit pointまで既に詳細に固定されています。

    さらに In Scope にはまだ statusline.py / herdr_projection.py の prefix 除去が書かれています。 しかし AC11 は「presentation owner は #2634 で、#2565 は独自に変更しない」と明記しています。 そして実際、PR #2640 は既に merge 済みです。 current main の statusline.py も Unbound / Degraded、prefixなし、activity bare label に更新済みです。

    自律エージェントに実装させる前提では、こうした矛盾はかなり危険です。presentation bullet を In Scope から削除し、AC11 の regression gate だけ残すのがよいです。Remaining Parent Gaps の pr_merged_observed 未確定 も「実装未完了」に修正すべきです。

    GitHub relation は1点だけ明文化を追加

    GitHub GraphQL は2026年8月に closingIssuesReferences へ excludeUserLinked / userLinkedOnly を追加しており、現在の default は excludeUserLinked=false、つまり manually linked Issue も含む契約です。(GitHub Docs)

    これは今回の用途なら妥当だと思います。GitHub 自身も手動linkとclosing keywordを Issue/PR link として扱い、default branch merge時の自動closeに利用します。(GitHub Docs) ただし暗黙 default に任せず、

    closingIssuesReferences(first: 2, excludeUserLinked: false)

    と仕様に書いておく方が再現可能です。first:2 なら 0 / 1 / multiple 判定にも十分です。

    推奨する #2565 の修正方向

    大規模再設計は不要です。実装前に (1) stale な session ID 前提を更新、(2) signal の Task authority と Activity transition authorityを分離、(3) dedupeをbusiness identity化、(4) GitHub network I/Oを通常 prompt hookからworkflow producer側へ移動、(5) #2634済みpresentation scopeと古い記述を削除、の5点を本文へ反映するのがよいです。

    そのうえで apply_workflow_signal() を1つの粗粒度 service operation とし、origin resolve → phase validation → dedupe → mutation → event append → projection enqueue を単一 BEGIN IMMEDIATE に収める設計なら十分です。HMAC、ACL、daemon、message bus、2PC、汎用 retry coordinator は不要です。テストも新しい巨大 harness は作らず、既存 tests/task-context に signal service / equivalence / producer adapter の決定論的テストを追加し、実 runtime は既存経路を使う最小 canary に留めるのが、このリポジトリの用途に合っています。

    ## 結論

    REQUEST_CHANGES 相当です。 ただし、#2565 の中心思想――structured workflow fact を trusted signal とし、SQLite を SSOT にして Issue/PR split-brain を防ぐ――は維持してよいです。

    前回コメントで挙がった task_id 直指定、physical dedupe、GitHub relation の4状態、producer commit point、EXISTING=true replay、producer fail-open は現行本文へかなり取り込まれています。 一方、2026-09-17 時点の main は fa54f0b0... まで進んでおり、Issue 自体の最終更新は9月15日なので、その後の関連実装も含めて再評価すると、新たに2件の blocker と数件の設計上の高優先修正があります。

    重要度 Finding 推奨
    BLOCKER Claude Code session ID の前提が現在は誤り CLAUDE_CODE_SESSION_ID を自動利用し、caller 明示 session_id を廃止
    BLOCKER delayed/replay signal が「現在の Activity」に誤適用され得る session は Task 解決だけに使い、signal ごとに phase/activity semantics を固定
    HIGH dedupe identity に source_schema_version / source を混ぜている business fact identity のみにする
    HIGH PR prompt で GitHub network lookup を行う設計 UserPromptSubmit を local-only に保ち、workflow producer 側へ寄せる
    HIGH Issue 本文内に既に解決済み/矛盾した scope が残る 実装前に contract cleanup
    MEDIUM GitHub GraphQL relation の新しい引数意味論を暗黙値に依存 excludeUserLinked を明示
    MEDIUM AC/test surface が広がり過ぎる余地 generic harness を増やさず既存 pytest + 最小 canary に限定

    BLOCKER — session_id の前提が古くなっている

    現行 #2565 は、Claude Code が subprocess に session ID を環境変数として公開しないため、

    signal_kind / source / source_schema_version / session_id / evidence

    を caller が明示的に渡す、と定義しています。

    これは現在の Claude Code 仕様と一致しません。公式ドキュメントでは CLAUDE_CODE_SESSION_ID が Bash/PowerShell tool subprocess に自動設定され、hook に渡される session_id と一致し、/clear 時にも更新されることが明記されています。Week 19 の公式更新にも同じ変更が記載されています。(Claude) Hooks 側も全 hook 共通入力として session_id を受け取ります。(Claude)

    つまり、以前の GitHub issue #27299/#47018 は当時は正しかったが、後の Claude Code 更新で解消済みです。興味深いことに、#2565 の以前のレビューコメント自身は既に CLAUDE_CODE_SESSION_ID が利用可能だと正しく記載していました。現行 Issue 本文でそこだけ古い前提に戻っています。

    ここはワークフローを軽くできます。task-contextctl signal apply の public payload は、

    signal_kind
    source
    source_schema_version
    evidence
    

    だけで十分です。CLI adapter が CLAUDE_CODE_SESSION_ID を読み、内部 service call の origin_session_id に変換する。hook 経路なら hook JSON の session_id を使う。環境変数が無い非 Claude 実行だけ deferred/unbound にすればよいです。

    現在の signal apply が task_id + repo + ref_kind + ref_number を直接要求しているのは、Issue が置換予定としている通りです。 任意 task_id を禁止する目的は維持しつつ、session ID を人間/LLMに運ばせる余計な配線は削除できます。

    BLOCKER — replay と「current Activity」方式が両立していない

    こちらの方がデータ整合性上は深刻です。

    #2565 は、Task Context sync が失敗しても producer 本体は成功させ、後から EXISTING=true 等で同じ signal を replay して self-heal する設計です。同時に、signal target は、

    session_id → ExecutionRun → Binding → current Activity/Task

    だけから決める、としています。

    この2つを組み合わせると、signal 発生時と replay 時で Activity が変わっているケースが未定義です。

    例えば refinement 自体は正常終了したが Task Context sync が busy で失敗。そのまま利用者は implementation に進む。その後 replay された refinement_approved が current Activity=impl を解決した場合、service が「current Activity を terminalize」という実装なら、実装 Activity を誤って完了させる余地があります。

    Task Context は意図的に producer を止めないため、これは異常系ではなく設計上想定すべき正常な遅延 deliveryです。

    session-origin は Task identity の決定までにした方が安全です。その後は signal ごとの意味論を service が持つべきです。例えば refinement_approved は refine Activity 以外を絶対に terminalize しない、pr_merged_observed は implementation phase にだけ作用し、既に cleanup へ進んでいれば state regression せず late/no-op とする、cleanup_completed は cleanup Activity にのみ作用する、という単調な state transition にします。

    既存 schema は Task 当たり ACTIVE Activity を1件に物理制約しており、履歴 Activity も保持するので、この実装のために新しい framework は不要です。

    HIGH — dedupe key に transport version を入れない方がよい

    現行 AC10 は dedupe identity に、

    signal_kind + source + source_schema_version + canonical evidence

    を含めます。

    これは idempotency の意味として不安定です。

    implementation_pr_observed(repo=X, PR=123) が v1 producer で一度適用された後、単なる schema evolution で producer v2 が同じ PR を再送すると、現実世界では同じ factなのに別 dedupe keyになります。source の rename/producer 移管でも同じです。

    dedupe identity は business fact に固定する方がよいです。

    implementation_pr_observed = repo + PR number、pr_merged_observed = repo + PR + merge commit OID、refinement_approved = repo + issue + approved body hash、cleanup_completed = repo + PR + merge identity。

    source と source_schema_version は event metadata に残せば、診断性を失いません。

    events.dedupe_key + partial UNIQUE 自体は適切です。SQLite は partial UNIQUE index を正式にサポートするため、大きな ledger を追加する必要はありません。(SQLite) 現行 events にその列がまだ無いことも current main で確認できます。

    HIGH — GitHub lookup を UserPromptSubmit から外したい

    #2565 は PR prompt の local claim miss 時に closingIssuesReferences を問い合わせ、claim hit + implementation nonterminal 時には merged state まで確認する設計です。

    structured relation を使うこと自体は正しいです。GitHub は PullRequest.closingIssuesReferences を正式提供しています。([GitHub Docs]4)

    ただし、UserPromptSubmit に network I/O を戻す必要はありません。

    PR #2615/#2632 は Task Context を低摩擦化するため hook 処理をかなり慎重に設計しており、#2632 では timeout budget を増やさず、Task Context の mismatch/sync failure で workflow を止めない方向へ明確に修正されています。 SQLite 側の BEGIN IMMEDIATE についても、writer 競合時には SQLITE_BUSY が起こり得るので、外部I/Oを transaction 外へ出す現行方針は正しいです。([SQLite]5)

    個人開発で操作感を優先するなら、通常 hook は local DB lookupだけにするのがよいです。claimless PR は Task Context mutationせず prompt をそのまま通し、open-pr、post-merge-cleanup、必要なら review workflow が GitHub snapshot を既に取得する時に relation/merged fact を解決して signal する。

    特に pr_merged_observed は post-merge-cleanup preflight と非常に相性がよいです。一般的なPR promptを見るたびにGitHubへ行く実益は小さいです。

    HIGH — Issue 本文の contract を一度掃除すべき

    反復 refinement の跡が残っています。

    本文上部では pr_merged_observed の trigger/producer/commit point が「未確定」と残っていますが、その後の In Scope では claim hit → bind → GitHub merged確認 → signal apply と commit pointまで既に詳細に固定されています。

    さらに In Scope にはまだ statusline.py / herdr_projection.py の prefix 除去が書かれています。 しかし AC11 は「presentation owner は #2634 で、#2565 は独自に変更しない」と明記しています。 そして実際、PR #2640 は既に merge 済みです。 current main の statusline.py も Unbound / Degraded、prefixなし、activity bare label に更新済みです。

    自律エージェントに実装させる前提では、こうした矛盾はかなり危険です。presentation bullet を In Scope から削除し、AC11 の regression gate だけ残すのがよいです。Remaining Parent Gaps の pr_merged_observed 未確定 も「実装未完了」に修正すべきです。

    GitHub relation は1点だけ明文化を追加

    GitHub GraphQL は2026年8月に closingIssuesReferences へ excludeUserLinked / userLinkedOnly を追加しており、現在の default は excludeUserLinked=false、つまり manually linked Issue も含む契約です。([GitHub Docs]4)

    これは今回の用途なら妥当だと思います。GitHub 自身も手動linkとclosing keywordを Issue/PR link として扱い、default branch merge時の自動closeに利用します。([GitHub Docs]6) ただし暗黙 default に任せず、

    closingIssuesReferences(first: 2, excludeUserLinked: false)

    と仕様に書いておく方が再現可能です。first:2 なら 0 / 1 / multiple 判定にも十分です。

    推奨する #2565 の修正方向

    大規模再設計は不要です。実装前に (1) stale な session ID 前提を更新、(2) signal の Task authority と Activity transition authorityを分離、(3) dedupeをbusiness identity化、(4) GitHub network I/Oを通常 prompt hookからworkflow producer側へ移動、(5) #2634済みpresentation scopeと古い記述を削除、の5点を本文へ反映するのがよいです。

    そのうえで apply_workflow_signal() を1つの粗粒度 service operation とし、origin resolve → phase validation → dedupe → mutation → event append → projection enqueue を単一 BEGIN IMMEDIATE に収める設計なら十分です。HMAC、ACL、daemon、message bus、2PC、汎用 retry coordinator は不要です。テストも新しい巨大 harness は作らず、既存 tests/task-context に signal service / equivalence / producer adapter の決定論的テストを追加し、実 runtime は既存経路を使う最小 canary に留めるのが、このリポジトリの用途に合っています。

  7. squne121 commented on Sep 17, 2026

    @squne121
    OwnerAuthor

    確認した限り、今回は 対象コメントを with_human_context の trusted anchor として扱い、issue-refinement-loop をそのまま自動継続させるのが適切です。

    理由は3点です。現行 skill はループ途中の承認を既定で要求せず、needs-fix は max_iterations まで自動継続します。また、explicit trusted human directive が section-bound patch で表現できない場合も、現在は issue_editor_required → controlled full rewrite にルーティングでき、人間に構造化 directive を書き直させる必要がありません。

    対象コメントの指摘も現時点で妥当です。Claude Code 公式ドキュメントは現在 CLAUDE_CODE_SESSION_ID が Bash/PowerShell・hook subprocess に自動設定され、hook の session_id と一致すると明記しています。 ([Claude]1) また GitHub の closingIssuesReferences は excludeUserLinked=false が現在のデフォルトなので、Issue contract で明示値に固定するという指摘にも根拠があります。 ([GitHub Docs]2) SQLite の partial UNIQUE index も公式サポートされています。 ([SQLite]3)

    対象コメントで優先すべき修正は、①caller明示 session_id の廃止、②Task identity authority と Activity transition authority の分離、③business factベースのdedupe、④UserPromptSubmitをlocal-onlyに維持、⑤#2634で解決済みpresentation scopeの除去、の5点です。

    以下を、すでに auto mode で起動している対話的 Claude-GPT にそのまま投入するのを推奨します。

    squne121/loop-protocol の Issue #2565 に対して、リポジトリ内の canonical agent skill

    .claude/skills/issue-refinement-loop/SKILL.md

    を使用し、以下の OWNER コメントを direct human context / trusted anchor として issue refinement を実行してください。

    この Claude-GPT セッションは既に auto mode で起動しています。
    この作業中にループ継続、Issue本文更新、deterministic repair、structural repair、issue-editor rewrite 等について私へ承認確認を求めないでください。

    ただし Claude Code 自体の permission mode や --dangerously-skip-permissions 等を変更する必要はありません。リポジトリの issue-refinement-loop が定義する approval-free loop policy と canonical control-plane をそのまま使用してください。

    作業目的

    anchor comment の REQUEST_CHANGES を #2565 の Issue contract に反映し、current main と現在の外部仕様に整合した、実装可能かつ矛盾のない Issue 本文まで refinement してください。

    大規模な再設計や新しい governance/security framework は導入せず、この個人趣味開発リポジトリでは correctness・有用性・低摩擦なワークフローを優先してください。

    Anchor comment の主要要求

    anchor comment を単なる参考情報ではなく、今回 operator が明示的に選択した human review directive として扱ってください。

    最低限、以下を disposition してください。

    1. Claude Code session ID の古い前提を削除する。

      • caller が session_id を明示的に運ぶ設計を廃止する。
      • Claude Code tool subprocess / hook subprocess では現在利用可能な CLAUDE_CODE_SESSION_ID を使用する。
      • CLI adapter が環境変数を内部 origin_session_id に変換する。
      • hook 経路は hook JSON の session_id を使用する。
      • 非 Claude 実行等で session origin が得られない場合のみ deferred / unbound 等の非破壊 outcome とする。
      • 任意 task_id を caller が指定できないという既存方針は維持する。
    2. Task identity authority と Activity transition authority を分離する。

      • session origin は canonical Task identity の解決に使用する。

      • signal を「現在の Activity」へ無条件適用してはならない。

      • delayed/replayed signal が別phaseの Activityを誤terminalizeしないよう、signal kindごとに対象 phase/activity semantics をservice側で固定する。

      • 例:

        • refinement_approved → refine semanticsのみ
        • pr_merged_observed → implementation semanticsのみ。すでに後続phaseなら regression させず late/no-op
        • cleanup_completed → cleanup semanticsのみ
      • transition は単調であり、replayによるstate regressionを許さない。

    3. dedupe identity を transport metadata ではなく business fact identity にする。

      • source / source_schema_version はevent metadataとして保持してよいが、同じ現実世界のfactを別factにするdedupe identityへ含めない。
      • anchor comment が提示した各signalのcanonical business identityを出発点に current schema と整合させる。
      • durable dedupe は既存 events 等への最小のDB physical UNIQUE/partial UNIQUEで実現し、別ledgerや汎用idempotency frameworkを追加しない。
    4. UserPromptSubmit hot path を local-only に維持する。

      • 通常promptごとにGitHub network lookupを追加しない。
      • local claim missはpromptを妨げずに通す。
      • GitHub relation / merged-state lookupは open-pr、post-merge-cleanup、その他すでにGitHub snapshotを必要とするworkflow producer側へ寄せる。
      • Task Context同期失敗によってproducer本体の成功を巻き戻さない。
    5. Issue contract の stale / contradictory scope を掃除する。

    6. GitHub relation query の意味論を明示する。

      • closingIssuesReferences(first: 2, excludeUserLinked: false) 相当をcontract上明示することを検討する。
      • 0 / exactly-one / multiple / unavailable を区別する。
      • implicit default に依存しない。
    7. テストを必要以上に大型化しない。

      • generic harness、daemon、message bus、2PC、汎用retry coordinator、追加security layer等は作らない。
      • 既存 tests/task-context を中心に deterministic service/equivalence/producer adapter tests を使う。
      • runtime verification が必要なら既存runtime経路を使用した最小canaryにする。

    Canonical workflow

    最初に current main、Issue #2565 本文、全関連コメント、anchor comment、関連Issue/PR、現在の skill/references/scripts を取得してください。

    current main HEADを必ず確認し、anchor comment 作成時の fa54f0b0... からさらに進んでいる場合は最新状態をauthorityとして再評価してください。

    Step 0 / preflight

    anchor URL は operator がこのプロンプトで明示的に選択した direct human context です。

    canonical main root / default branch から with_human_context profile を使ってください。

    概念上のcanonical entryは以下です。実際には current command registry / SKILL.md をSSOTとして、手書きで古いargvを再実装しないでください。

    uv run --locked python3 scripts/agent-guards/skill_runtime_exec.py \
      --command-id preflight.run.with_human_context \
      --issue-number 2565 \
      --repo squne121/loop-protocol \
      --anchor-comment-url https://github.com/squne121/loop-protocol/issues/2565#issuecomment-5712121831

    STATUS / NEXT_ACTION / MUST_READ / COMMANDS_JSON / BLOCKERS / ARTIFACT / repair disposition をmachine-readable authorityとしてconsumeしてください。proseでplanner判断を再実装しないでください。

    SubAgent investigation

    必ずSubAgentを使用してください。

    少なくとも以下の独立した調査を行ってください。

    codebase-investigator

    current main を対象に read-only で以下を検証させてください。

    特に anchor comment の5つの主要修正が current main に照らしてまだ必要か、すでに別PRで解決済みかを区別してください。

    web-researcher

    primary/official sourcesを優先し、最低限以下をfreshに検証させてください。

    • Claude Code CLAUDE_CODE_SESSION_ID

      • subprocessへの公開範囲
      • hook session_id との関係
      • /clear 時の挙動
    • Claude Code hooksのsession input semantics

    • GitHub GraphQL PullRequest.closingIssuesReferences

      • excludeUserLinked
      • userLinkedOnly
      • 現在のdefault
    • SQLite partial UNIQUE index

    • 必要なら BEGIN IMMEDIATE / writer contention の公式semantics

    ブログ・二次資料ではなく公式docsを第一根拠にしてください。

    SubAgent synchronization requirement

    SubAgentを起動しただけで次へ進んではいけません。

    codebase-investigator と web-researcher の両方について、

    • execution が終了している
    • output/artifact がmaterializeされている
    • main/root thread が結果を取得している

    ことを確認するまで Step 2 review や Issue mutationへ進まないでください。

    並列起動は構いませんが、必ず全SubAgentの完了を待ってからjoinしてください。

    SubAgentが失敗した場合も即座に人間へ質問せず、skillの既存retry/fallback/routing contractに従ってbounded recoveryを行ってください。

    Trusted contract update

    preflight.run.with_human_context が trusted contract patch plan を生成した場合は、main/root control-planeだけが canonical mutation lane を実行してください。

    uv run --locked python3 scripts/agent-guards/skill_runtime_exec.py \
      --command-id contract_update.run.with_human_context \
      --issue-number 2565 \
      --repo squne121/loop-protocol \
      --anchor-comment-url https://github.com/squne121/loop-protocol/issues/2565#issuecomment-5712121831

    SubAgentやisolation worktreeからこのcommandを直接実行しないでください。

    NEXT_ACTION routing

    以下は自動実行してください。途中で私へ承認を求めないでください。

    • apply_deterministic_repair

      • canonical repair_action.apply
    • apply_deterministic_structural_repair

      • canonical structural_repair_action.apply
    • issue_editor_required

      • 同じ anchor comment URL を reviewer_feedback_url として再利用し、canonical issue-editor / edit-issue controlled transaction routeでfull rewrite
      • contract_update.run.with_human_context をno-progress retryしない
      • anchor commentを再投稿しない
    • needs-fix / request_changes

      • max iterations内なら自動で次iterationへ進む

    artifact pathは current SKILL.md のpath/provenance規則に従って扱い、absolute pathを誤ってconsumerに渡さないでください。

    Review loop

    各mutation後は必ず persisted Issue body/title をread backしてください。

    fresh body revisionに対して、

    1. fresh preflight
    2. fresh investigation evidence join
    3. canonical root-owned Step 2 review pipeline
    4. readiness
    5. 必要ならrewrite
    6. final readback
    7. final review gate

    を現在の skill contract に従って実行してください。

    old review artifactやmutation前bodyに対するapprove判定を再利用しないでください。

    needs-fix が返った場合は max_iterations まで自動継続してください。
    iterationごとに私へ「続けますか?」と質問しないでください。

    Human judgment の扱い

    このプロンプトと指定anchor commentそのものが、今回の既知のREQUEST_CHANGESに対する operator-selected human context です。

    したがって、

    • anchorに明示されている設計選択
    • current repo evidenceから一意に決まる修正
    • deterministic repair
    • safe structural repair
    • trusted human directive に基づく issue-editor full rewrite

    について、人間判断が必要だとして再質問しないでください。

    一方で、anchor・Issue・current repo・公式仕様のいずれにも答えがなく、repoのcanonical routerが真に human_judgment_required をterminal authorityとして返す未指定の新しいproduct/design choiceについては、勝手な擬似承認を生成しないでください。

    その場合も質問待ち状態にはせず、canonical termination reportまで実行し、

    • unresolved choice
    • alternatives
    • repo evidence
    • なぜanchorでは解決不能か

    を具体的に残して終了してください。

    品質方針

    このリポジトリは個人趣味開発です。

    優先順位は以下です。

    1. 実際のworkflow correctness
    2. Issue contractの一貫性と実装可能性
    3. agentが誤解しにくい明確さ
    4. operator latency / frictionの低さ
    5. 必要十分な回帰テスト

    security hardening、policy framework、generic harnessを目的化しないでください。

    特に以下を避けてください。

    • 新しいdaemon
    • message bus
    • 2PC
    • generic retry coordinator
    • HMAC/ACL layer
    • hot-path network lookup
    • schemaを増やすためだけのschema
    • checkerを満足させるためにruntime architectureを歪める変更
    • #2634ですでにowner/implemented済みのpresentation scopeの再取り込み

    完了条件

    Issue #2565 が fresh review で approve / proceed 相当になるまで refinementしてください。

    最低限、最終Issue本文で以下が明白であることを確認してください。

    • session origin contract
    • signalごとのTask resolutionとActivity transition semantics
    • delayed/replay semantics
    • monotonic transition / late-noop behavior
    • business fact dedupe identity
    • producerごとのcommit point
    • producer successとTask Context sync failureの分離
    • local-only UserPromptSubmit方針
    • GitHub relation 0/1/multiple/unavailable semantics
    • excludeUserLinked の明示
    • 実装: Herdr Tab label を短縮し statusLine の情報密度を増やす #2634 presentation ownershipとの境界
    • Allowed Paths
    • AC
    • Verification Commands
    • Runtime Verification Applicability
    • Stop Conditions

    最終的に fresh persisted bodyに対するreview/readiness evidenceを確認してからterminationを行ってください。

    この依頼は Issue refinementまで を対象とします。
    approved後に implementation code変更、implementation worktreeでの実装、PR作成、mergeは開始しないでください。

    現行skillが LOOP_HANDOFF_RESULT_V1 等のapproved termination artifactを要求する場合、それらのrefinement側handoff artifact/termination reportまでは生成して構いませんが、impl-review-loop の実作業には進まないでください。

    最終報告

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

    • final verdict
    • iterations
    • 使用したSubAgentと各結果
    • anchor comment各findingのdisposition
    • Issue本文に加えた主要変更
    • tests/readiness/review evidence
    • unresolved blockerの有無
    • final Issue body SHA
    • implementation handoff readiness

    作業途中の承認確認は不要です。可能な処理はすべて現在のturn/session内で完了してください。

    一点だけ意図的に強くしたのは、session → current Activity をsignal targetにしないことです。replayを正式に許す以上、ここは単なる改善ではなく整合性条件です。また CLAUDE_CODE_SESSION_ID は現在公式に存在するため、古いcaller明示session配線を残す理由はありません。 ([Claude]1)

    この版は Issue refinement完了で止め、実装には進まない設定です。

  8. squne121 commented on Sep 17, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    Completed

    The trusted-anchor rewrite removed caller-supplied session identity, fixed signal-specific phase semantics, made dedupe business-fact based, kept UserPromptSubmit local-only, made GraphQL relation arguments explicit, and removed #2634/#2640 presentation implementation scope. Two bounded semantic rewrites additionally specified versioned evidence, phase/state selection, producer origin propagation, and single-transaction ownership of implementation_pr_observed Issue/PR claim attachment.

    Remaining findings

    1. High — post-merge cleanup must specify the ordering: obtain/validate fresh merged snapshot → receive accepted pr_merged_observed → only then select/resume/start cleanup Activity or dispatch cleanup. If cleanup has already begun without that accepted fact, the required non-mutating/stop outcome is not yet fixed.
    2. Medium — top-level source grammar/canonical identifiers and source_schema_version: "v1" rejection behavior are not fully specified.
    3. Medium, unresolved choice — stale/unbound-origin replay precedence conflicts with the broad duplicate-noop wording. Alternatives:
      • validate payload/evidence → resolve a valid bound origin → fact lookup/dedupe; stale/unbound returns deferred, or
      • permit a same-Task duplicate lookup before origin resolution; then it may return duplicate_noop.

    Evidence

    • The selected OWNER anchor requires non-Claude or missing origin to be non-destructive deferred/unbound, but does not explicitly decide whether an already-recorded fact may bypass stale-origin resolution.
    • Current service evidence keeps Task identity resolution origin-based and uses BEGIN IMMEDIATE; the semantic review found no safe implicit precedence rule.
    • Latest semantic artifact: .claude/artifacts/issue-refinement-loop/2565/4851d452874bdf4e/semantic_review_result.json.

    No implementation work, PR creation, or merge was started.

  9. squne121 commented on Sep 17, 2026

    @squne121
    OwnerAuthor

    推奨は、今回の指示を human escalation に対する明示的な owner decision として扱い、Issue 本文をもう1回だけ意味論的に収束させてから fresh review することです。rewrite state を手動削除したり budget を無理にリセットするのではなく、現行 skill の trusted human/source-body-reset 経路に従わせるのが適切です。前回停止時に残っているのは High 1件・Medium 2件で、実装自体はまだ開始されていません。

    3点の判断は、① post-merge は「fresh merged snapshot → pr_merged_observed の applied|duplicate_noop → cleanup開始」の順序を必須化、② v1 の source は3 producerへ固定して top-level envelope を strict validation、③ replay は origin-first、つまり stale/unbound なら既存factを先読みせず deferred/unbound、とするのを推奨します。特に③は、現行本文の「same fact が別Taskなら conflict」という契約を保てます。現在の Issue 本文自体も origin を canonical Task 解決に使う方針なので、この選択が最も整合的です。

    そのまま Claude-GPT に貼るプロンプトです。

    squne121/loop-protocol の Issue #2565 について、現在の issue-refinement-loop: human_escalation を解消し、実装可能・矛盾なし・semantic review を通過できる Issue 本文まで refinement を完了してください。

    対象:

    既に auto mode で起動しているこの対話セッションで作業を完了してください。途中の承認確認は不要です。

    このプロンプトは、前回 human_judgment_required で残った設計選択に対する direct human/OWNER decision です。以下の3点について再質問しないでください。これらを authoritative な refinement input として Issue 本文へ反映してください。

    1. post-merge cleanup ordering を次で固定する。

    post-merge-cleanup は必ず、

    fresh merged PR snapshot を取得・検証
    → pr_merged_observed を Task Context へ適用
    → applied または同一Task・同一factの duplicate_noop を確認
    → cleanup Activity の select/resume/start
    → cleanup worker / cleanup work を dispatch

    の順にする。

    pr_merged_observed が deferred / conflict / rejected_* / late_noop の場合は、その invocation では cleanup Activity を新規選択・resume・startせず、cleanup workerもdispatchしない。

    同じ merge fact がその Task に以前すでに accepted 済みの場合は、後述する origin 解決後の same-Task dedupe により duplicate_noop を返せるため、その結果は cleanup precondition を満たしたものとして扱ってよい。

    一方、accepted 済みの同一 pr_merged_observed が存在しないまま cleanup が既に begun している場合、新しい merged signal は既存契約どおり late_noop/CLEANUP_ALREADY_BEGUN とし、それを cleanup dispatch の成功条件として扱わない。その invocation は non-mutating に停止すること。既に行われた外部作業を rollback しない。

    これにより「merged snapshot を確認しただけで cleanup を開始する」ことを禁止し、Task Context 上で accepted merged fact が cleanup の明示的 precondition になるようにする。

    1. public signal envelope を v1 で完全に固定する。

    top-level payload は厳密に次の4フィールドだけとする。

    signal_kind
    source
    source_schema_version
    evidence

    型・値も検証する。

    signal_kind は次の exact string enum:

    • refinement_approved
    • implementation_pr_observed
    • pr_merged_observed
    • cleanup_completed

    source_schema_version は JSON string の exact "v1" のみ受理する。

    v1 の canonical source は現在の実 producer に限定して:

    • issue-refinement-loop
    • open-pr
    • post-merge-cleanup

    とする。

    signal/source の対応も明示する:

    • refinement_approved → issue-refinement-loop
    • implementation_pr_observed → open-pr
    • pr_merged_observed → post-merge-cleanup
    • cleanup_completed → post-merge-cleanup

    将来別 workflow を producer に追加する場合は、暗黙に arbitrary string を許可せず contract/schema revision で追加する。現在本文に「review workflow が merged signal producer になり得る」と読める曖昧な記述があるなら、v1 producer authority と矛盾しないよう整理する。

    required field 欠落、unknown top-level field、wrong type、unknown signal_kind、unknown/mismatched source、source_schema_version != "v1" はすべて non-mutating rejection とする。既存 disposition 命名規則との整合を確認した上で、top-level envelope error と evidence error を型付きで区別できる最小の契約にする。新しい validation framework は作らない。

    1. stale/unbound replay と duplicate の precedence は origin-first に固定する。

    処理順序を明文化する。

    まず envelope と evidence を完全に validate して canonical business-fact dedupe key を導出する。

    その後、internal origin_session_id を
    open ExecutionRun → Binding → canonical Task
    へ解決する。

    origin が absent / stale / unbound なら、その時点で deferred/unbound とし、既存 fact の duplicate lookup を先に行って duplicate_noop へ短絡しない。

    origin が canonical Task へ正常に解決した後に、claim/Task consistency を検証する。

    その後、同じ canonical Task に対する accepted business fact の dedupe を判定する。同一factが既にそのTaskへ記録済みなら duplicate_noop。

    既存factが別Taskに属するなら、これまでの契約どおり conflict/FACT_TASK_IDENTITY_CONFLICT。

    つまり duplicate_noop は「valid envelope/evidence + valid bound origin + same canonical Task」が成立した後にだけ返せる。

    この ordering により stale/unbound origin を fact lookup で迂回せず、caller-selected identity を再導入せず、cross-Task replay を duplicate として隠さない。


    実行方法

    最初に current Issue body、OWNER anchor、human escalation comment、現在の .claude/skills/issue-refinement-loop と関連 reference/script を読み直してください。過去 artifact の結論だけを信用せず、現在の main と persisted Issue body を fresh に確認してください。

    SubAgent を必ず使用してください。

    まず read-only の codebase-investigator を起動し、上記3決定が現在の Task Context service、signal API、open-pr、post-merge-cleanup、schema/tests と実装可能に整合するか調査させてください。

    並行して設計レビュー用 SubAgent を起動し、上記3決定を前提として、現在の Issue 本文に残る矛盾・未定義 precedence・producer boundary・transaction boundary を探索させてください。

    両SubAgentの作業完了を必ず待ち、hand-back をすべて取得するまで Issue mutation に進まないでください。
    一方だけ完了した状態で先へ進まないこと。
    SubAgent を起動したまま最終回答へ進まないこと。

    その結果を統合した後、必要なら issue-editor SubAgent に、現在の Issue bodyを基準に最小限の semantic full rewrite を作らせてください。その SubAgent の完了も待ってください。

    mutation は current issue-refinement-loop の canonical trusted-human/control-plane 手順に従ってください。以前の rewrite budget が persisted していても、router state/artifactを手動削除・改竄したり attempt counter を直接resetしてはいけません。このプロンプトによる human decision と source body change を、現行 skill が提供する正規の trusted update / source-body-reset semantics で扱ってください。

    SKILL.md が指定する canonical executor / planner / review routing を迂回する ad-hoc mutation は避けてください。

    Issue本文へ反映後、fresh persisted bodyをread-backし、SHAを取り直してください。

    その fresh body に対して deterministic/root review と semantic review を再実行してください。

    semantic review が needs-fix を返した場合でも、上記3点について人間へ再質問しないでください。anchor、今回のhuman decision、current repo evidenceから一意に修正できるものは自律的に修正し、許される範囲で refinement loop を継続してください。

    特に以下を semantic review で再確認してください。

    post-merge preflight が accepted merged fact より前に cleanup Activity/worker を開始できないこと。

    same accepted merged fact の再実行は、valid origin が同じTaskへ解決した後なら duplicate_noop になり、cleanup再開を不必要に妨げないこと。

    accepted merged fact が無いまま cleanup が既に開始済みなら late_noop を成功扱いせず、その invocation が non-mutating stop になること。

    stale/unbound origin が fact existence によって duplicate_noop へ化けないこと。

    different-Task origin/replay が duplicate lookup に隠されず FACT_TASK_IDENTITY_CONFLICT になること。

    top-level schema が source_schema_version: "v1"、canonical source、signal/source pairing、unknown field/type rejectionまで明示されていること。

    既存の business-fact dedupe、single BEGIN IMMEDIATE transaction ownership、producer success と Task Context sync outcome の分離、UserPromptSubmit local-only、GitHub relation 0/1/multiple/unavailable、excludeUserLinked: false、presentation scope 除外を regression させないこと。

    大規模な redesign、新しい ledger、generic retry coordinator、daemon/message bus、security/governance framework は追加しないでください。個人趣味開発として correctness、有用性、低operator frictionを優先してください。

    終了条件

    この作業は Issue refinement の完了まで です。

    実装コード変更、implementation PR 作成、merge、post-merge cleanup の実行には進まないでください。

    最終報告では、使用した全SubAgentと各hand-back結果、前回残った3 finding の disposition、Issue本文への主要変更、deterministic review結果、semantic review結果、fresh final Issue body SHA、unresolved blocker の有無、implementation handoff readiness を明示してください。

    deterministic review と semantic review の両方が implementation handoff を妨げない状態まで収束した場合は、その旨を明記して終了してください。

    このプロンプトでは、前回の「semantic rewrite budget exhausted」を単純に無視させず、今回の人間判断で source contract が変わったことを正規経路で扱うようにしています。現行 router も human による source body change を reset condition として扱う設計です。

  10. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-09-18T13:04:04Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/2565
      body_sha256: "sha256:1c5b1afc014f97f8325dff2ab5f84174f91a8b83bf481d2a155083b54a8cf2a0"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:1c5b1afc014f97f8325dff2ab5f84174f91a8b83bf481d2a155083b54a8cf2a0","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_jpi18qap.md"}}
        vc_preflight:
          decision: pass
          classifications: '[{"ac":"AC1","line":2,"raw_command":"uv run --locked pytest tests/task-context/test_signal_refinement_approved.py -q","command_hash":"sha256:14d1d63d45597dd43d764f3f2d2021f4dfcfa9089046a6c1df8d1ab914eeea9a","execution_key_hash":"sha256:796370a95d87aa2598b534a99db0dee3b2ca53ffb8f7344183a727ccbc1a5d38","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":1749,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:568f93084ede606ad93f5f798d2ff1e0975626b44d46b078d9a724f282250296"}},{"ac":"AC2","line":6,"raw_command":"uv run --locked pytest tests/task-context/test_signal_envelope_schema.py tests/task-context/test_signal_strict_json_rejection.py -q","command_hash":"sha256:0f67fe3b0781297c7ddcb3672221eec783e47c67ee01da32e3181739f16d101b","execution_key_hash":"sha256:a26f8bedddf4027077ff537b1801c02608ec4f206ab6e627ffa610339dd77fd4","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":1764,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:5f46bc2abd7c18660f0ca9d29032c9c44db35b1366d1efd2567e717ea8e026e0"}},{"ac":"AC3","line":9,"raw_command":"uv run --locked pytest tests/task-context/test_signal_origin_first_precedence.py -q","command_hash":"sha256:78835269ee194549cdbd1e2034cbfd5c99243ae71fa9311467ec2ca4c7aa7a18","execution_key_hash":"sha256:8a7e56a02c347a31c93424888951c68de104724ac6bda80a9d3419f0d5441a96","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":2425,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:684a76f35f8b458a46c13a77e8db47b6580decdaeb93c670700ac18235e0bf0b"}},{"ac":"AC4","line":12,"raw_command":"uv run --locked pytest tests/task-context/test_signal_phase_monotonicity.py -q","command_hash":"sha256:4af8f21ada41bdb14a4703de414b424db9a3205762b5fc71719d9565c0d1cc33","execution_key_hash":"sha256:1799e92d7acce8f915da33fcbb8044212acacfa0b186902051b789ab46896968","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":1730,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:42bfa6d4cfa3ddece2a779c629cfb0541d716f112e12909b149f8aac60267e08"}},{"ac":"AC5","line":15,"raw_command":"uv run --locked pytest tests/task-context/test_signal_producer_adapters.py -q","command_hash":"sha256:d00df00b5210204a50592628e6d6bc14672c8c7fd0f4d81d253e7245c03b2a1a","execution_key_hash":"sha256:b9d09ce5e707bb9adddefbc385b8afc395b087004920f0a5166d10c4ed80f54e","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":1417,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:b787d2e6fb240de4f6fc364b8ed116d8cdd12470baf5e0c79a2b92aefc3433f5"}},{"ac":"AC6","line":19,"raw_command":"uv run --locked pytest tests/task-context/test_signal_github_relation_conflict.py -q","command_hash":"sha256:ab4d3441f480ffc4cc23c1d66e6d98f3c1eef5109bd76a23952fd06007d821c1","execution_key_hash":"sha256:3194f6943588ed8e44d89e004ce7058d5259159b13b5f228e54e7af0c5a39d88","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":1325,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:e98fc3bffdee56cbb1550a051ced0d83ab9f7fa60b3ef1d21ed3d266c8281600"}},{"ac":"AC7","line":22,"raw_command":"uv run --locked pytest tests/task-context/test_signal_generic_reference_non_equivalence.py -q","command_hash":"sha256:cd571988e5dd8e3b7400450c82a031d0c335f0931db1b3d5adc3133dd0e57f60","execution_key_hash":"sha256:dea39bc32c2f90b2933cbf606d0b2fd04f41ef93c637da37f9d5608d95bc138e","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":1097,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:d97ec97249aae53b05441c6b764eafb89774ad88cf42dc960319fba2dafc5317"}},{"ac":"AC8","line":25,"raw_command":"uv run --locked pytest tests/task-context/test_cleanup_pending_resume.py -q","command_hash":"sha256:30b8cec3f12ab2bc181b642b6fe38c6929056a0d272660f7ea9c9a0b25d9cf94","execution_key_hash":"sha256:245571b9cb4161b60b57d2b16e7af1357d8ceab4e5347ec0b1234004261a4f1f","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":992,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:4032fdf4a6517052b0592c17756b7e4251adc00ab4add59bd19a4822b804f785"}},{"ac":"AC9","line":28,"raw_command":"uv run --locked pytest tests/task-context/test_signal_cleanup_completed_commit_point.py -q","command_hash":"sha256:7ff106ecc0ea5e96b1eb0e66c6b34ba8faa13d34c885433716b25c5b2990e8d8","execution_key_hash":"sha256:adfb7f9abadb9e279bed105af1b24172a63d37c9998a44bf49157a5ef8627987","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":488,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:c737bab414e56a2ec8917af46c578b37eab35bbd24b6cf6b04bf106b791d4b34"}},{"ac":"AC10","line":31,"raw_command":"uv run --locked pytest tests/task-context/test_events_dedupe_unique_constraint.py -q","command_hash":"sha256:00bbee4d0a32fd8484fb460dc0545f36a6492f996c7837c0a865e4e9e01b322e","execution_key_hash":"sha256:615221815c5e9e9d9af3ecfaa5c883f00447c4fd4cabfd8fcf67c58980f8796a","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":451,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:8d8101d7c661786e189d1375f77ab281a680ba34163a6a31aedf908ab24537c4"}},{"ac":"AC11","line":34,"raw_command":"uv run --locked pytest tests/task-context/test_statusline_render.py tests/task-context/test_herdr_projection.py -q","command_hash":"sha256:b6762d5d0f66750086cb5a25b0fb35487a71e9edd50bf1c62a6708eb590b2331","execution_key_hash":"sha256:4ae2e8a0fac17c5cfd9d5b0dfcedc382a74c5e9284506eb7fccbbeec25c21c4c","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":1,"duration_ms":911,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:5c950d2e29ebceff9d8035c3a517faba7a1099f20b2491b7a9ded6f3eafe6fbc"}},{"ac":"AC12","line":37,"raw_command":"uv run --locked pytest tests/task-context/test_signal_evidence_schema.py -q","command_hash":"sha256:bd1c6084f00910cc55a2ecd7c5a1c56aaca3d45d70c93c45667f7ae0975466d4","execution_key_hash":"sha256:467ee3d98896b41ec1b36b7479a79be23e76da114ee1910e3f3c548f3f5ae969","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":537,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:810398c316acd0ee23b041da10bba7aaf3b1cb01f965e38c4b18e4ca5413583b"}},{"ac":"AC13","line":41,"raw_command":"uv run --locked pytest tests/task-context/test_signal_state_transition_matrix.py -q","command_hash":"sha256:ce429a95bad7650d883a137cc0848eb9ec1bd073661c92502436810ba063e516","execution_key_hash":"sha256:ab28ff7c9da27a69883ab7a0a32a1ee55ba79a9f0cc8641773116df10c650653","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":516,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:d2c72aa898e84e1545afbb3f429dbab55b41ad08e0e672a16141d9137c53bb7e"}},{"ac":"AC14","line":44,"raw_command":"uv run --locked pytest tests/task-context/test_signal_producer_origin_propagation.py -q","command_hash":"sha256:69136d90c1aed5bbef4c460ca37d5f08d9d63fa1bab234658006e35eb0cb9e8c","execution_key_hash":"sha256:8b032df107464f70e7e374d37ae4ca2542893f2436a6e3fbd2deacaa633e9fed","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":670,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"timeout_provenance":{"timeout_seconds":150,"cleanup_tail_seconds":15,"source":"static_fallback","estimator_version":"v2","estimator_input_digest":"sha256:1f787fab41f600dced7a62737a4c92ff87eef1e45a8a5cd450a0e7b2c600822b"}}]'
          classifications_transport: {"schema":"vc_preflight_classifications_transport/v1","classification_count":14,"original_payload_sha256":"sha256:074954e5cedacffdfa77c0d1862dc207ca2fb2587304b5dfe3ef91307a4df345","compact":true,"truncated":true}
        declared_path_overlap: '{"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"00260fa87baf50a0a118401effcc39663e259a07","draft_policy":"include_drafts","prs":[{"number":2657,"title":"feat: test-runner に Issue #2656 限定の canonical delegation route runtime probe narrow exception を追加する","base_ref_name":"main","head_ref_name":"worktree-issue-2656-claude-gpt-subagent-canonical-delegation","head_ref_oid":"7acb134aa154be47c0cf0fa535bd86ea312c22b3","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2657","changed_files_count_graphql":1}],"fetched_count":1,"totalCount":1,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:c7cfececefe5d0ce45a8efbb8615faa260a771d15b7aeb8abe9b160b8838c526","errors":[]},"inventory_digest_extended":"sha256:f3fac679bee0baaa00f53d2a0f1f40b0a3be5920ba12907a0e04c866a4a7ebd8","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}'
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: '{"issue_number":2565,"contract_source_kind":"issue_comment","contract_source_id":"5730388999","contract_body_sha256":"sha256:1c5b1afc014f97f8325dff2ab5f84174f91a8b83bf481d2a155083b54a8cf2a0","allowed_paths_normalized_sha256":"96cb83c6f60d97ce351eeea7dc734a8d9f23669c5cc687f6740dc5e396613d65","base_ref":"main","base_sha_at_snapshot":"00260fa87baf50a0a118401effcc39663e259a07"}'
  11. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    Issue #2565 の refinement を完了しました。

    • deterministic root review: verdict: approve(canonical_step2_route: step_2_5)
    • semantic design review: assessment: clear、findings なし
    • dependency materialization gate: proceed(no_hard_dependencies_confirmed_this_cycle)
    • fresh contract snapshot: CONTRACT_REVIEW_RESULT_V1 status: go
    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/2565#issuecomment-5730388999
        generated_at: "2026-09-18T13:04:03Z"
        body_sha256: "sha256:1c5b1afc014f97f8325dff2ab5f84174f91a8b83bf481d2a155083b54a8cf2a0"
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "no label mutation performed by this loop run"
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-09-18T13:07:48Z"
      checked_body_sha256: "sha256:1c5b1afc014f97f8325dff2ab5f84174f91a8b83bf481d2a155083b54a8cf2a0"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []

    次工程: 依頼により impl-review-loop、実装、PR 作成、merge、post-merge cleanup は開始せず、この承認状態で停止します。

  12. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    GitHub の現在状態まで確認しました。#2565 はすでに refinement 済みで、最新の終了報告 comment 5730439626 は status: impl_ready / routing_action: run_impl_review_loop、fresh contract snapshot は comment 5730388999 の status: go、Issue body SHA は sha256:1c5b1afc014f97f8325dff2ab5f84174f91a8b83bf481d2a155083b54a8cf2a0 です。#2563/#2564 は closed、presentation 担当の #2634 / PR #2640 も merge 済みです。

    一方、現在の main では task_contextctl.py signal apply がまだ caller 指定の task_id/repo/ref_kind/ref_number を受ける旧実装で、apply_workflow_signal()、events.dedupe_key、implementation_pr_observed、pr_merged_observed、cleanup_started、CLEANUP_PENDING は未実装です。したがって already_satisfied より、通常の実装ルートへ進む可能性が高いです。

    推奨は、過去の go snapshot を単独の開始権限にはせず、現行 impl-review-loop が要求する Root-Owned Synchronous Entry Transition を fresh に実行したうえで、その同一 invocation から Step 1 を起動することです。また、open-pr の publish: yes 承認については今回の指示を明示的な事前承認として扱わせます。ループ上限は現行 skill の既定 max_iterations=3 を維持し、勝手に無限ループ化しない方がよいです。

    以下を、すでに auto mode で起動している対話的 Claude-GPT にそのまま渡す想定です。

    あなたは現在、squne121/loop-protocol の repository context で auto mode により起動済みの対話的 Claude-GPT です。

    対象は GitHub Issue #2565:

    #2565

    です。

    この Issue を、repository の現在の canonical skill

    .claude/skills/impl-review-loop/SKILL.md

    および同 skill が参照する steps/**、implement-issue、open-pr、pr-review-judge 等の current HEAD 上の契約に従い、実装 → 検証 → PR作成 → CI確認 → PRレビュー → REQUEST_CHANGES 修正ループ → merge直前の承認済み状態まで自律的に進めてください。

    この作業について、通常の実装・テスト・commit・push・PR作成・レビュー対応・update-branch・再検証の各段階で人間へ承認を求めないでください。

    今回のこのユーザー指示自体を、Issue #2565 専用の open-pr における publish: yes の明示的な事前承認として扱って構いません。PR publish のためだけに人間へ再確認しないでください。

    ただし、PR の merge、auto-merge の有効化、および #2565 自身の PR に対する post-merge-cleanup の実行は行わないでください。 最終到達点は merge 直前です。

    現在確認済みの intake evidence

    以下は開始時点の参考 evidence です。ただし、artifact/snapshot を authority として盲目的に使わず、必ず live state を再取得してください。

    これらは telemetry/reference です。live Issue、live main、linked worktree、実 diff、実テスト、CI、PR review を正本として扱ってください。

    最初に必ず行うこと

    impl-review-loop の Root-Owned Synchronous Entry Transition を省略しないでください。

    同一の root/main invocation の一続きの処理として、

    capability preflight → live Issue #2565 fetch → current-run の canonical issue-contract-review / root_entry_router.py 経由の root transition → 直後の live Issue 再取得 → routing decision → 許可された場合のみその同じ invocation から Step 1 implementation-worker dispatch

    まで実行してください。

    以前の status: go comment や body SHA を、Step 1 起動の再利用可能な authorization token として扱わないでください。

    current live contract が refinement を再要求していない限り、過去の refinement をやり直すこと自体を目的にしないでください。

    SubAgent の使用は必須

    impl-review-loop の control-plane/data-plane 分離を守り、root thread が実装やレビューを横取りしないでください。

    Step 1 は implementation-worker SubAgent、Step 2 は test-runner SubAgent、Step 4 は pr-reviewer SubAgentへ canonical skill の materialized input を渡して委譲してください。current skill が別の専用 worker を要求する箇所も、その契約に従ってください。

    各 SubAgent について Common Completion Protocol を厳守してください。

    spawn_agent 後は canonical task_name を保存してください。wait_agent の timeout、途中 update、mailbox activity は完了とはみなしません。SubAgent の final result を実際に取得し、その後 list_agents で同じ canonical task が terminal completed になったことを確認してください。errored、interrupted、shutdown、not_found は成功扱いしないでください。

    final result と terminal completed の両方を確認するまでは、次 Step や最終 routing に進まないでください。

    複数の required SubAgent を起動する場面がある場合は、必要な全 SubAgent が terminal になるまで待ち、全 hand-back を取得してから統合判断してください。一体だけ終わった状態で先へ進まないでください。

    作業終了時に、起動した required SubAgent を残したまま終了しないでください。

    SubAgent 側で nested delegation が禁止されている場合は、その禁止を破らないでください。

    #2565 の実装方針

    live repository を調査したうえで最小差分を設計してください。現時点では少なくとも以下の current-main gap が存在するため、まず事実確認してください。

    task_contextctl.py signal apply は旧 task_id/repo/ref_kind/ref_number caller-selected payload のままです。

    apply_workflow_signal() は未実装です。

    events.dedupe_key とその physical partial UNIQUE constraint は未実装です。

    implementation_pr_observed、pr_merged_observed、cleanup_completed の workflow signal producer wiring は未実装です。

    cleanup_started / CLEANUP_PENDING lifecycle も未実装です。

    実装順序としては、依存関係が許す限り次を優先してください。

    1. Task Context の additive schema migration、physical dedupe、service-layer apply_workflow_signal()、origin-first resolution、fixed historical Activity semantics。
    2. task-contextctl signal apply を strict v1 public envelope へ置換し、caller-selected identity を排除。
    3. issue-refinement-loop / open-pr producer adapter の structured signal wiring。
    4. open-pr の fresh GitHub PR relation classifier と NEW / EXISTING=true replay semantics。
    5. post-merge-cleanup の merge prerequisite、durable cleanup Activity lifecycle、cleanup_started / cleanup_completed wiring。
    6. UserPromptSubmit が local-only のままであることを固定する regression。
    7. docs と deterministic tests。
    8. Issue の AC/VC 全件、全 Task Context suite、runtime canary。

    この順序は implementation hint であり、current repository architecture を読んだ結果より小さく安全な依存順があるなら、その根拠を記録して調整して構いません。

    絶対に保持する #2565 の semantic contract

    public v1 envelope の top-level field は正確に

    signal_kind
    source
    source_schema_version
    evidence

    の4つだけです。

    caller から session_id、task_id、activity_id、binding_id を受け入れてはいけません。

    source_schema_version は exact JSON string "v1"。

    kind/source pair は Issue 本文どおり固定してください。

    origin は CLI なら CLAUDE_CODE_SESSION_ID、hook なら hook JSON session_id を internal origin_session_id に変換するだけとし、public envelope へ露出させないでください。

    canonical Task resolution は

    origin_session_id → open ExecutionRun → Binding → canonical Task

    です。origin を current Activity 選択に使用しないでください。

    service transaction の precedence は Issue 本文どおり、

    envelope/evidence validation
    → business fact key derivation
    → origin resolution
    → claim/Task consistency
    → same-Task accepted-fact dedupe
    → 新規 merged fact の場合のみ cleanup-begun boundary

    です。

    stale/unbound origin が、既存 fact の存在だけで duplicate_noop になってはいけません。

    different-Task replay が duplicate lookup に隠されてはいけません。

    same Task / same accepted fact は duplicate_noop。

    same business fact が別 Task に束縛済みなら conflict/FACT_TASK_IDENTITY_CONFLICT。

    新規 merge fact が cleanup 開始後なら late_noop/CLEANUP_ALREADY_BEGUN。

    implementation_pr_observed は implementation Activity を terminalize しません。

    pr_merged_observed のみが historical implementation Activity を適切な prerequisite 下で terminalize します。

    cleanup_completed は service が特定した eligible internal cleanup Activity だけを完了させます。

    apply_workflow_signal() の accepted mutation は一つの BEGIN IMMEDIATE transaction 内で claim validation/attachment、dedupe、state transition、event append、projection enqueue を一貫して行ってください。外部 I/O を transaction 内に持ち込まないでください。

    open-pr relation classifier

    implementation_pr_observed を送る前に fresh GitHub PR snapshot を取得し、Issue本文に指定された

    closingIssuesReferences(first: 2, excludeUserLinked: false, userLinkedOnly: false)

    の bounded classifier を使用してください。

    exactly one reference かつ candidate Issue と一致した場合だけ signal へ進んでください。

    zero → deferred/NO_LINK

    exactly one mismatch → conflict/RELATION_ISSUE_MISMATCH

    two-or-more → conflict/MULTIPLE_CLOSING_ISSUES

    snapshot fetch failure / GraphQL error / partial / timeout / null / malformed connection or nodes → deferred/RELATION_UNAVAILABLE

    です。

    これらの non-proceed outcome では Task Context mutation や claim attachmentを行わないでください。

    generic PR body text、branch/worktree name、コメント、Refs #N だけを equivalence authority にしてはいけません。

    新規 PR と EXISTING=true の両方から同じ implementation_pr_observed fact を replay 可能にしてください。

    DRY_RUN=true では signal を送らないでください。

    Task Context adapter の deferred/conflict 等によって、既に成功した PR creation 等の producer 本体を rollback/failure 化しないでください。

    UserPromptSubmit hot path

    UserPromptSubmit は local-only のまま維持してください。

    PR claim miss を理由に GitHub relation lookup を追加しないでください。

    claim miss では Task Context mutation を行わず prompt を通過させてください。

    全prompt network lookup、daemon、poller、message bus、generic retry coordinator、2PC、新しい generic workflow framework を導入しないでください。

    post-merge-cleanup コードの実装と、今回の PR 自身の実運用を区別すること

    Issue #2565 の scope には post-merge-cleanup / post-merge-cleanup-executor の実装変更とテストが含まれています。そのコード実装・unit/integration test は必ず行ってください。

    ただし、今回作成する #2565 implementation PR 自身は merge しません。

    したがって、この PR を対象に実際の post-merge cleanup worker を起動したり worktree/branch cleanup を実行したりしないでください。

    merged-PR lifecycle は fixture / deterministic test / Issue本文で要求される local runtime canary の範囲で検証してください。

    presentation scope

    #2634 / PR #2640 が statusLine / Herdr presentation を既に所有・実装しています。

    #2565 では presentation contract を再設計しないでください。

    Issue AC11 の既存 presentation regression test を通すことに限定してください。

    Allowed Paths

    live Issue #2565 の Allowed Paths を再取得してそれを authority にしてください。

    開始時点で確認されている範囲は以下です。

    scripts/task-context/**
    tests/task-context/**
    .claude/hooks/task_context/**
    .claude/skills/issue-refinement-loop/**
    .claude/skills/open-pr/**
    .claude/skills/post-merge-cleanup/**
    .claude/skills/post-merge-cleanup-executor/**
    docs/dev/task-context.md

    live Issue が更新されていない限り、この範囲外へ変更を広げないでください。

    Verification

    Issue #2565 の live Verification Commands をそのまま authoritative command set として取得し、AC1〜AC14 を current PR head で実行してください。

    少なくとも現在の contract では以下の test 群を要求しています。

    test_signal_refinement_approved.py
    test_signal_envelope_schema.py
    test_signal_strict_json_rejection.py
    test_signal_origin_first_precedence.py
    test_signal_phase_monotonicity.py
    test_signal_producer_adapters.py
    test_signal_github_relation_conflict.py
    test_signal_generic_reference_non_equivalence.py
    test_cleanup_pending_resume.py
    test_signal_cleanup_completed_commit_point.py
    test_events_dedupe_unique_constraint.py
    test_statusline_render.py
    test_herdr_projection.py
    test_signal_evidence_schema.py
    test_signal_state_transition_matrix.py
    test_signal_producer_origin_propagation.py

    さらに current head で

    uv run --locked pytest tests/task-context -q

    を実行してください。

    runtime verification applicability は live Issue を正本にしてください。開始時点の契約では AC8 が immediate で、minimal canary は「merged implementation を CLEANUP_PENDING として観測し、その後 normal cleanup prompt で同じ Task が resume されること」を既存 local Task Context hook/workflow path で確認するものです。

    fallback を PASS と読み替えないでください。

    impl-review-loop の継続方針

    current skill の既定 max_iterations を使用してください。開始時点では 3 です。人間承認を避けるために上限を勝手に無効化・増加させないでください。

    REQUEST_CHANGES が返った場合は、blockers と test failures を canonical fix_delta に変換し、次 iteration の implementation-worker へ渡して修正してください。人間に「直してよいか」を聞かないでください。

    PR head が stale なら current head で再検証・再レビューしてください。

    BEHIND の場合は current skill の route_to_update_branch に従って implementation-worker に update-branch を委譲し、その後 Step 2 → Step 4 → Step 5 を再実行してください。

    required CI は current head に束縛して待機してください。

    Step 2 の current-head binding tuple が stale なら Step 4 を起動せず Step 2 を再実行してください。

    Step 1〜4 SubAgent の単なる human_review_required: true self-report が current skill 上 warning-only なら、それだけを理由に停止せず canonical routing を継続してください。

    reviewer の verdict: APPROVE だけで終了しないでください。live PR state を fresh に読み、current route_loop_verdict_v2() の判定に従ってください。

    人間へ停止してよい条件

    通常の実装判断や reviewer fix は人間へ戻さないでください。

    ただし canonical hard stop は維持してください。特に以下の場合は停止して、推測・回避・force 操作をしないでください。

    live Issue の Stop Conditions に実際に抵触した場合。

    Allowed Paths 外の変更が不可避になった場合。

    Issue が固定した public schema / type / key semantics 自体を変えなければ実装不能と判明した場合。

    actual Git conflict (mergeable == CONFLICTING または merge_state_status == DIRTY) が canonical routing 後も解消できない場合。

    secret / credential の開示、権限昇格、保護領域へのアクセスが必要な場合。

    force push、history rewrite、hard reset、未公開 commit の破棄、git worktree remove --force 等の破壊的操作が必要な場合。

    新規 Issue に scope を分割しなければ進められない場合。

    nested SubAgent delegation が必要だが contract で禁止されている場合。

    max_iterations に達した場合。

    canonical reviewer が HUMAN_REVIEW_REQUIRED と判定した場合。

    AUTONOMY_POLICY validator が approved termination を拒否した場合。

    live Issue/PR 上に明示的な人間の停止指示が現れた場合。

    これらでは必要な fresh evidence を収集し、何が自動解決不能かを具体的に報告して停止してください。

    破壊的操作の禁止

    auto mode であっても次は自動実行しないでください。

    PR merge
    auto-merge enable
    force push
    destructive reset/history rewrite
    未公開 local commit の破棄
    人間確認を要求する one-shot destructive cleanup contract の consume
    secret/credential の取得・表示・変更
    Issue scope 外の大量変更

    通常の専用 worktree 作成、branch 作成、Allowed Paths 内編集、test、commit、通常 push、Draft PR 作成、PR body 更新、review comment、CI待機、非破壊的 update-branch は、このタスクの範囲では再承認不要です。

    終了条件

    理想的な終了は current impl-review-loop の approved route です。

    以下を fresh current-head evidence で確認してください。

    Issue contract の AC/VC を満たす。

    Allowed Paths gate が通る。

    required tests / runtime verification が要求どおり pass。

    required CI が current head で pass。

    pr-reviewer が current head に対して APPROVE。

    reviewer blockers が空。

    live mergeability が current canonical skill の approved 条件を満たす。開始時点の skill では MERGEABLE かつ CLEAN または HAS_HOOKS。

    AUTONOMY_POLICY_V1 termination validator が pass。

    その状態になったら IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready / termination_reason: approved を canonical procedure に従って生成・投稿し、mergeせずに停止してください。

    already_satisfied が fresh evidence で本当に成立する場合は current skill の structured recommendation route に従い、空PRを作らないでください。

    最終報告

    終了時には最低限、以下を報告してください。

    Issue #2565 の最終 live body SHA。

    使用した全 SubAgent の canonical task name、役割、terminal state、主要 hand-back。

    iteration 数と各 iteration の route。

    作成または再利用した PR 番号・URL。

    最終 PR head SHA。

    changed files と Allowed Paths compliance。

    AC1〜AC14 verification の結果。

    full tests/task-context suite 結果。

    runtime canary 結果。

    required CI の current-head 結果。

    pr-reviewer の最終 verdict / reviewed_head_sha / blockers / warnings。

    live mergeable / merge_state_status。

    AUTONOMY_POLICY validator 結果。

    未解決 warning。

    required SubAgent が残っていないこと。

    最後に明確に、

    MERGE NOT EXECUTED

    と記載してください。

    今から current repository state を fresh に読み直し、canonical impl-review-loop の Root-Owned Synchronous Entry Transition から開始してください。

    この形なら、「承認不要」を open-pr の publish gate にまで明示的に伝えつつ、impl-review-loop 自体の hard safety boundary は壊さない構成になります。特に SubAgent は「起動した」だけで先へ進まず、final result取得 + list_agents の completed 確認まで待つよう強めています。

  13. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  14. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  15. 4 remaining items

  16. squne121 commented on Sep 18, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  17. squne121 commented on Sep 19, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-19T10:59:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2661"
      head_sha: "f318b2fb79d5583b866994c583f7edbff0e8a691"
      issue_number: 2565
      termination_reason: approved
      merge_ready: true
      iteration: 2
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
  18. squne121 commented on Sep 19, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  19. squne121 commented on Sep 19, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  20. squne121 commented on Sep 19, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  21. squne121 commented on Sep 20, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-09-20T08:20:00Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      pr_url: "https://github.com/squne121/loop-protocol/pull/2661"
      head_sha: "0d0a7abd95ce2101fb51fb7c54641e959ed57561"
      issue_number: 2565
      termination_reason: approved
      merge_ready: true
      iteration: 2
    
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations:
        - dedupe_key: "task-context-v1:implementation-pr-observed-cross-task-dedupe-edge-case"
          source_url: "https://github.com/squne121/loop-protocol/pull/2661#issuecomment-5748250792"
          source_note_id: "pr-reviewer-iteration1-warnings"
          summary: "apply_workflow_signal()のimplementation_pr_observed分岐で、accepted_implementationが現在resolveされたTaskと異なるTaskに属し、かつ現Taskのimplementation Activityが別マージにより既にterminalな場合、cross-Task dedupeよりも前にduplicate_noop/activity_terminalへ短絡しうる残存エッジケース。Finding 2により狭められたが解消はされていない。pre-existing、narrow、OWNERのFinding 2スコープ外。テスト証跡なし。"
  22. squne121 commented on Sep 20, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-09-20T09:05:00Z)

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues:
        - request_dedupe_key: "task-context-v1:implementation-pr-observed-cross-task-dedupe-edge-case"
          status: created
          issue:
            number: 2685
            url: "https://github.com/squne121/loop-protocol/issues/2685"
          reason: null
    
      note_only_observations: []
  23. squne121 commented on Sep 30, 2026

    @squne121
    OwnerAuthor

    contract cascade の明確化(#2827 / PR #2847)

    OWNER decision(https://github.com/squne121/loop-protocol/issues/2827#issuecomment-5920334091)に基づく明確化のみを記録する。この Issue の normative contract(local-only / PR claim-miss safety)は変更しない。

    本文を更新しない理由: この Issue は履歴用の CLOSED Issue であり、本文の controlled update は古い本文が RUNTIMEASSERT001(runtime_assertion_bindings 未宣言)の readiness で needs_fix になるため mutation 前に停止した(編集前の本文でも同一の結果)。実証のない binding を履歴 Issue へ追加することは行わず、明確化を本 comment として記録する。この gate の assertion 単位 applicability は #2852 で扱う。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions