[verified] Enforce delegation adoption at runtime consumers

This commit is contained in:
2026-10-11 07:11:40 +00:00
parent 9367d5a3a1
commit 6cb2317667
19 changed files with 1112 additions and 47 deletions
+14
View File
@@ -371,6 +371,20 @@ python3 <harness-root>/harness/lib/workflow_guard.py check-tests --input GUARD_I
File/hash binding PASS는 named symbol·parameter 존재나 실제 collection 실행을 인증하지 않는다. `argv`/`evidence`의 형식과 source scope 결속을 확인해도 명령이 실행됐다는 증명은 아니다. Main이 실제 command/output/exit·환경·collection ID/status·범위의 적절성과 manifest 결속을 기존 provenance 규칙으로 별도 확인한다. 필요한 근거가 부족하면 해당 증빙을 채택하지 않으며 현재 collection을 baseline으로 재명명하지 않는다. 기존 revision evidence 재사용은 원래 source에 먼저 결속한 뒤 source-to-head 영향 평가를 유지한다. 별도 checkout이나 전체 테스트 재실행을 요구하지 않는다. Source-binding 실패를 제품 결함이나 자동 `REQUEST_CHANGES`로 전환하지 않는다.
### Delegation adoption runtime consumption
`harness/lib/delegation_adoption.py`의 `require_adoption(declaration, *, expected_source, expected_stage)`는 실제 소비 함수의 진입 gate다. 독립 CLI의 이전 PASS receipt를 제출하는 대신 매 소비 호출에서 안전하게 context/result 파일과 bundle/Git bytes를 다시 읽고 `verify_evidence`를 실행한다. 선언 누락, 검증 실패, BLOCK, 입력 거부, 빈 delegated obligations, source/stage 불일치는 소비 동작 이전에 차단한다. main이 제공하는 `expected_source`와 `expected_stage`를 worker/context에서 역으로 만들지 않는다.
- 위임 근거를 쓰지 않는 경로도 `{"mode":"none"}`를 명시한다. 이는 main의 비사용 선언이지 자동 인증이 아니다. 위임 근거를 사용하면서 none으로 선언하거나 parse-only 내부 primitive로 판정을 우회하는 것은 금지한다. 기존 계약/source/identity/lease 검증은 생략되지 않는다.
- 위임 근거를 사용하는 선언의 exact fields는 `mode`, `bundle_root`, `context_path`, `result_path`, `git_dir`이며 mode는 `delegated`다. 경로는 canonical absolute safe paths이고 `git_dir`는 경로 또는 null이다. Adoption의 lexical 검사 이후 동일 공통 검증기의 `_json_file`/`_directory_fd`/`_open_rel`이 모든 ancestor와 마지막 component를 descriptor-relative `O_NOFOLLOW`로 읽어 symlink를 거부한다. Git 조회는 한 invocation에서 retained FD를 사용한다. 사전 realpath 비교가 실제 안전 읽기를 대신하지 않으며 이 계약은 임의 동시 mutator 아래 byte-stability나 atomic consume을 보장하지 않는다. PASS receipt나 status 필드를 입력으로 받지 않는다.
- Spec 판정 artifact의 `render_review`는 target.head로 expected Git source를 고정하며 stage는 `spec-review`다. Parse/readback의 내부 canonical re-render는 판정 채택이 아니므로 명시적 none을 사용한다.
- Impl 재작업 delivery artifact의 `rework_comment.py render`/`do_render`는 final_head에 고정한 Git source와 `implementation-delivery` stage를 사용한다. 최초 implementation main의 production 진입점은 `harness/agents/impl/skills/gitea-issue-implementation/scripts/implementation_delivery.py`의 `deliver_implementation(adapter, *, head, declaration)`다. 이 workflow는 canonical `delivery_adoption.deliver`를 실제 호출해 fresh gate → authenticated adapter push → exact remote-head readback → fresh gate → create/reuse PR → exact PR number/head/open readback을 순차 수행한다. Gate failure 또는 remote drift이면 이후 write를 중단하고, 외부 write 실패를 자동 재시도하지 않는다. Adapter의 실제 반환값/예외를 그대로 전달하며 callback 호출만으로 delivered/verified 상태를 만들어 내지 않는다. 실제 transport의 push/PR create 및 remote readback은 main-owned adapter의 책임이며, gate 밖 arbitrary Git/API 호출을 sandbox로 막는다는 의미는 아니다. 재작업 comment renderer만으로 최초 delivery 전체가 보호된다고 주장하지 않는다.
- Review `native_review.publish`는 plan.target.head와 `code-review` stage로 시작 시 확인하고, provider/lease readback 후 `create_review` 직전 다시 확인한다. 실패하면 POST를 하지 않으며 intent가 이미 기록된 경우 기존 at-most-once reconciliation 규칙을 유지한다. Evidence 변경을 이유로 자동 POST 재시도하지 않는다.
- Spec/rework의 render 소비 CLI는 `--no-delegated-evidence` 또는 `--delegation-adoption ABS_DECLARATION_JSON` 중 하나를 명시한다. none은 전자, delegated 선언은 후자다. 문서의 예전 render 명령에도 이 선택을 반드시 추가한다. Native publication은 Python publish API이며 CLI publish 명령을 새로 만들거나 존재한다고 주장하지 않는다. Python consumer는 declaration keyword를 명시한다. 증빙 검증 자체 CLI, parse/readback, 기존 source/tests guard는 별개의 read-only 도구다.
- 소비 role adapters의 source는 exact `git_tree`/`revision`이다. Captured worktree의 base_revision을 최종 head의 증명으로 바꾸지 않는다. Common API의 captured_worktree 지원은 독립 expected source가 동일한 다른 소비자의 사용을 위한 것이며 role final-head binding을 완화하지 않는다.
실행 회귀는 실제 소비 함수에 정상/차단/입력 거부/선언 누락/이전 PASS 이후 변경을 넣어 판정 artifact 생성·delivery output write·publication adapter 호출이 차단되는지 검사한다. 이것은 local synthetic integration이며 live Gitea 게시·push 증거가 아니다. Runtime gate 역시 sandbox 또는 capability enforcement가 아니고, caller의 위임 비사용 선언·context 독립성·자연어 판정 의미·OS 권한을 인증하지 않는다. 최종 검증과 소비 사이에 mutator를 병렬 실행하지 않는 기존 규칙은 유지한다.
### Delegation evidence acceptance preflight
위임 결과를 판정·delivery·publication 증빙으로 채택하기 **이전**에 main이 `harness/lib/delegation_evidence.py`를 실행한다. 기존 source-preservation snapshot/compare-source, test inventory source-binding, `check-tests`는 각각 유지한다. 이 gate는 보호 범위 변경 검출이나 collection completeness 검사를 대신하지 않는다.