[verified] Bind test inventories to exact Git sources
This commit is contained in:
@@ -343,6 +343,34 @@ python3 <harness-root>/harness/lib/workflow_guard.py check-contracts --input JSO
|
||||
|
||||
Input schema와 엄격한 type/key 규칙은 `harness/lib/workflow_guard.py`의 API 계약을 따른다. `paths-json`은 중복 없는 기존 repository-relative protected 파일 array다. `check-tests`는 `baseline_ids/current_ids`, `baseline_status/current_status`, source·collection argv·inventory digest·evidence를 가진 `baseline_collection/current_collection`, `authorized_changes`, `changed_tests`, `findings`를 연결한다. `check-contracts`는 `baseline/current/mappings`와 `stages/precedence`를 연결한다. 파일별 의미를 임의 추론하지 말고 helper의 실제 schema와 기록을 검증한다. 이 문서의 정적 contract test 통과는 agent가 실행 중 절차를 준수했다는 증명이 아니다.
|
||||
|
||||
### Test inventory Git source-binding preflight
|
||||
|
||||
Test inventory를 생성·전달하거나 채택하는 impl/spec/review main은 `check-tests` 이전에 `harness/lib/test_inventory_binding.py`로 collection의 Git source binding을 확인한다. 구조 guard는 그대로 유지한다. Expected revision과 stage는 inventory 자체에서 복사하지 않고 workflow가 독립적으로 고정한 baseline/current source와 collection 단계에서 가져온다. 사용이 이미 승인된 bare mirror 또는 `.git` directory만 사용하며 helper가 cache admission·lock·authenticated Git provenance를 대신하지 않는다.
|
||||
|
||||
Helper는 Linux의 신뢰된 `/usr/bin/git`와 `/proc/self/fd/`를 사용한다. PATH에서 Git을 탐색하지 않으며, admitted Git directory FD를 검증 전체와 모든 Git child에서 유지해 경로 치환이 읽기 대상을 바꾸지 않게 한다. 이 실행 환경이 없으면 fallback이나 repair 없이 차단한다.
|
||||
|
||||
```sh
|
||||
python3 <harness-root>/harness/lib/test_inventory_binding.py \
|
||||
--git-dir ABS_GIT_DIRECTORY --input BINDING_INPUT \
|
||||
--expected-revision FULL_SOURCE_SHA --expected-stage COLLECTION_STAGE
|
||||
python3 <harness-root>/harness/lib/workflow_guard.py check-tests --input GUARD_INPUT
|
||||
```
|
||||
|
||||
**Input 계약:** 기존 inventory/manifest/collection 기록의 검증된 필드를 다음 bounded JSON input으로 연결한다. 이 adapter input은 제품의 새 문서·증빙 commit 의무나 기존 v2 evidence-manifest schema 변경이 아니다. 정본 verification run 또는 허용된 reviewer workflow artifact에 보존한다. Main은 binding input의 `ids`와 `source_revision`이 뒤의 `check-tests` baseline/current collection에 exact-match하는지도 확인한다. 입력 값의 자동 추정·재수집·권한 repair는 하지 않는다.
|
||||
|
||||
- Exact top-level keys: `schema`, `source_revision`, `stage`, `ids`, `file_sha256`, `collection`.
|
||||
- `schema`: exact `gitea-agent.test-inventory-binding/v1`.
|
||||
- `source_revision`: lowercase 40자리 commit SHA. `stage`: 기존 collection 단계의 nonempty string. Baseline/current 명칭을 새로 강제하지 않고 independently expected stage와 대조한다.
|
||||
- `ids`: 중복 없는 `repository-relative-path::symbol` test ID array. Parameterized ID의 suffix는 보존한다. 실제 empty collection이면 빈 array를 허용하며 완전성은 main이 확인한다.
|
||||
- `file_sha256`: 모든 ID에서 첫 `::` 앞의 파일 경로를 추출한 exact unique path set에 대응하는 lowercase SHA-256 map. 없는 파일·추가 파일·Git symlink/gitlink/tree를 일반 test blob으로 채택하지 않는다.
|
||||
- `collection`: exact keys `source_revision`, `stage`, `argv`, `scope_paths`, `scope_sha256`, `evidence`. Revision·stage는 top-level 및 independently expected source와 일치해야 한다. `argv`는 실제 collection 기록의 nonempty string array, `evidence`는 nonempty 실행 근거 참조다.
|
||||
- `scope_paths`: 안전한 unique repository-relative path array이며 모든 test ID 파일을 포함한다. Collector 설정·fixture·dependency 등 실제 수집에 영향을 주는 입력도 main이 기록의 출처와 함께 검토한다.
|
||||
- `scope_sha256`: exact commit의 각 scope regular blob에 대해 `SHA256(raw_bytes)`를 계산한 `{path: digest}` map을 `json.dumps(map, sort_keys=True, separators=(',', ':'), ensure_ascii=True)`의 UTF-8 bytes로 직렬화한 SHA-256이다. Git object ID와 파일 SHA-256을 혼동하지 않는다.
|
||||
|
||||
**판정 및 한계:** CLI exit 0은 source binding PASS, 1은 revision/stage/file/hash/scope의 불일치 BLOCK, 2는 malformed input·안전하지 않은 경로 등 입력 거부다. Helper는 bounded JSON과 고정된 error/reason code만 반환하고 입력 본문·Git stderr·credential을 출력하지 않는다. Duplicate/unknown JSON keys, unsafe path, malformed SHA와 비정규 input은 거부한다. Git tree/blob만 읽고 checkout·fetch·test 실행·file/ref write를 하지 않는다. Dirty worktree 대신 pinned commit의 blob을 비교한다.
|
||||
|
||||
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`로 전환하지 않는다.
|
||||
|
||||
#### Nested input contracts
|
||||
|
||||
All object keys below are required and exact; unknown/missing keys, duplicate JSON keys, duplicate list identities, incorrect scalar types and non-regular/unbounded JSON inputs block. Empty strings are allowed only where explicitly stated. References are nonempty strings identifying existing verification command/result or approval records, not their secret contents. Full source revision is lowercase 40-hex; byte/scope digests are lowercase 64-hex. Integer fields reject booleans. CLI exit codes are 0 for structural PASS, 1 for detected violations/drift, 2 for rejected input; APIs raise `GuardError` for rejected input or return a status/violations result.
|
||||
|
||||
Reference in New Issue
Block a user