schema=iop-chronos-final-handoff-audit-v1
current_manifest_row_count=300
current_manifest_artifact_row_count=300
current_manifest_file_count=290
current_manifest_state_count=10
current_manifest_retain_generic_count=135
task03_historical_row_count=303
task03_historical_file_count=293
task03_historical_state_count=10
task03_universe_residuals=0
task03_duplicate_rows=0
manifest_count_mapping_match=1
task13_archive_searches=0
task13_pointer_digest_mismatches=0
task14_removal_status=pass
removed_target_count=12
pre_delete_digest_count=12
post_delete_absence_count=12
bundle_member_path=acceptance-v1/state/state-export-v1.json
bundle_member_exactly_once=1
bundle_archive_paths_safe=1
bundle_member_regular_file=1
real_state_export_location=bundle-member:acceptance-v1/state/state-export-v1.json
real_state_export_digest_match=1
real_state_export_counts_match=1
real_state_export_logical_ids_match=1
state_manifest_records=10
state_supplemental_records=2
state_supplemental_ids=state:cache-root,state:temp-root
state_fixture_records=12
state_coverage_missing=0
state_coverage_unknown=0
state_logical_id_count=12
state_logical_id_sha256=9bce499e286514baeb7ad9bc7c59119a3b5725f69763706dfeba06569d7404b9
state_logical_ids_sha_match=1
state_fixture_categories=8
state_fixture_quarantine=1
state_logical_id_mismatches=0
renamed_source_residuals=0
transfer_remove_residuals=0
retained_path_mismatches=0
unclassified_paths=0
duplicate_paths=0
forbidden_surface_scan=pass
forbidden_chronos_import_residuals=0
forbidden_chronos_workspace_path_residuals=0
forbidden_chronos_env_prefix_residuals=0
forbidden_chronos_camel_residuals=0
forbidden_chronos_snake_residuals=0
forbidden_chronos_kebab_residuals=0
iop_node_owner=model-provider-device
chronos_connection_surfaces=0
cli_agent_terminal_workspace_surfaces=0
chronos_repository_mutations=0
external_mutations=0
canonical_promotion=pending
before_chronos_head=ed45e2e9c55a9e4e214198517175abf5ce8c7d92
before_chronos_status_sha256=4edb879794f484c9737248caf3d1347590a2f17d11cb4bf71704ee5031f6bd23
before_canonical_iop_head=6d6bb3a44d1384e8248d482f57de522dc800aade
before_canonical_iop_status_sha256=023af53e13dc3c6d350092e3b5ada36ad9093cea59c02220dadc3f8e26a08460
before_lock_sha256=34b76d160816aadd7bc19a1f7b5006a45c70fd459f9860df8560f0d9063161f9
command_id=cmd1
command_text=cmd1:bash -euo pipefail -c 'test "$PWD" = /config/workspace/iop-s1; shopt -s nullglob; group=m-iop-agent-chronos-extraction-decoupling; task=14+13_remove_migration_surface; logs=(); for archived in agent-task/archive/*/*/"$group"/"$task"/complete.log; do test -f "$archived"; logs+=("$archived"); done; test "${#logs[@]}" -eq 1; awk '/^## (Summary|요약)$/ {s=1; next} /^## / && s {exit} s && (/final verdict: PASS/ || /final PASS/ || /최종 verdict: PASS/) {p++} END {exit p==1?0:1}' "${logs[0]}"; d=${logs[0]%/complete.log}; test -f "$d/migration-removal-audit.log"'
command_exit_code=cmd1:0
command_stdout_sha256=cmd1:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_stderr_sha256=cmd1:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_id=cmd2
command_text=cmd2:python3 -c 'from pathlib import Path
import hashlib, json

text = Path('HANDOFF.md').read_text()
assert text.startswith('---\n') and '\n---\n' in text
front = text.split('\n---\n', 1)[0].splitlines()[1:]
pairs = [line.split(': ', 1) for line in front]
keys = [key for key, _ in pairs]
assert len(keys) == len(set(keys))
kv = dict(pairs)

expected = '''handoff_version handoff_status source_revision rollback_revision task13_complete_log_path task13_complete_log_sha256 pre_deletion_receipt_path pre_deletion_receipt_sha256 pre_deletion_audit_path pre_deletion_audit_sha256 task13_verifier_path task13_verifier_sha256 original_manifest_artifact_path original_manifest_sha256 original_manifest_row_count original_manifest_file_count original_manifest_state_count original_manifest_retain_generic_count task03_historical_row_count task03_historical_file_count task03_historical_state_count task03_universe_residuals task03_duplicate_rows boundary_delta_artifact_path boundary_delta_sha256 boundary_delta_row_count boundary_addendum_artifact_path boundary_addendum_sha256 boundary_addendum_row_count effective_matrix_artifact_path effective_matrix_sha256 effective_matrix_row_count state_schema_artifact_path state_schema_sha256 state_fixture_artifact_path state_fixture_sha256 bundle_receipt_artifact_path bundle_receipt_sha256 state_original_manifest_logical_id_count state_addendum_logical_id_count state_logical_id_count state_logical_ids_sha state_fixture_record_count state_fixture_category_count state_fixture_quarantine_count real_state_export_location real_state_export_sha256 real_state_export_record_count real_state_export_category_count real_state_export_quarantine_count bundle_location bundle_sha256 task09_complete_log_path task09_complete_log_sha256 task10_complete_log_path task10_complete_log_sha256 import_graph_audit_path import_graph_audit_sha256 import_graph_residuals task14_complete_log_path task14_complete_log_sha256 task14_removal_audit_path task14_removal_audit_sha256 task14_removal_status removed_target_count pre_delete_digest_count post_delete_absence_count final_transfer_remove_residuals final_retained_path_mismatches final_renamed_source_residuals final_unclassified_paths final_duplicate_paths provider_node_regression full_go_regression readability_audit forbidden_surface_scan iop_node_owner chronos_connection_surfaces cli_agent_terminal_workspace_surfaces chronos_repository_mutations external_mutations canonical_promotion downstream_lock staging_lock_identity staging_lock_result canonical_lock_identity canonical_lock_result'''.split()
assert keys == expected

receipt = Path(kv['pre_deletion_receipt_path'])
receipt_front = receipt.read_text().split('\n---\n', 1)[0].splitlines()[1:]
rv = dict(line.split(': ', 1) for line in receipt_front)

br_path = receipt.parent / rv['stable_receipt_path']
br = json.loads(br_path.read_text())
rv['real_state_export_location'] = 'bundle-member:acceptance-v1/state/state-export-v1.json'
rv['real_state_export_sha256'] = br['real_state_export_sha']
rv['real_state_export_record_count'] = str(br['state_record_count'])
rv['real_state_export_category_count'] = str(br['state_category_count'])
rv['real_state_export_quarantine_count'] = str(br['quarantine_record_count'])
rv['bundle_location'] = 'withheld-owner-local'
rv['bundle_sha256'] = br['real_bundle_sha']

mapping = {
    'source_revision': 'source_revision',
    'rollback_revision': 'rollback_revision',
    'original_manifest_sha256': 'manifest_sha256',
    'original_manifest_row_count': 'manifest_row_count',
    'original_manifest_file_count': 'manifest_file_count',
    'original_manifest_state_count': 'manifest_state_count',
    'original_manifest_retain_generic_count': 'manifest_retain_generic_count',
    'task03_historical_row_count': 'task03_historical_row_count',
    'task03_historical_file_count': 'task03_historical_file_count',
    'task03_historical_state_count': 'task03_historical_state_count',
    'task03_universe_residuals': 'task03_universe_residuals',
    'task03_duplicate_rows': 'task03_duplicate_rows',
    'boundary_delta_sha256': 'delta_sha256',
    'boundary_delta_row_count': 'delta_row_count',
    'boundary_addendum_sha256': 'addendum_sha256',
    'boundary_addendum_row_count': 'addendum_row_count',
    'effective_matrix_sha256': 'effective_matrix_sha256',
    'effective_matrix_row_count': 'effective_matrix_row_count',
    'state_schema_sha256': 'state_schema_sha256',
    'state_fixture_sha256': 'state_fixture_sha256',
    'bundle_receipt_sha256': 'stable_receipt_sha256',
    'state_original_manifest_logical_id_count': 'state_original_manifest_logical_id_count',
    'state_addendum_logical_id_count': 'state_addendum_logical_id_count',
    'state_logical_id_count': 'state_logical_id_count',
    'state_logical_ids_sha': 'state_logical_ids_sha256',
    'state_fixture_record_count': 'state_record_count',
    'state_fixture_category_count': 'state_category_count',
    'state_fixture_quarantine_count': 'state_quarantine_count',
    'real_state_export_location': 'real_state_export_location',
    'real_state_export_sha256': 'real_state_export_sha256',
    'real_state_export_record_count': 'real_state_export_record_count',
    'real_state_export_category_count': 'real_state_export_category_count',
    'real_state_export_quarantine_count': 'real_state_export_quarantine_count',
    'bundle_location': 'bundle_location',
    'bundle_sha256': 'bundle_sha256',
    'task09_complete_log_path': 'task09_complete_log_path',
    'task09_complete_log_sha256': 'task09_complete_log_sha256',
    'task10_complete_log_path': 'task10_complete_log_path',
    'task10_complete_log_sha256': 'task10_complete_log_sha256',
    'import_graph_audit_path': 'task10_import_audit_path',
    'import_graph_audit_sha256': 'task10_import_audit_sha256',
    'import_graph_residuals': 'import_graph_residuals',
    'downstream_lock': 'downstream_lock',
    'staging_lock_identity': 'staging_lock_identity',
    'staging_lock_result': 'staging_lock_result',
    'canonical_lock_identity': 'canonical_lock_identity',
    'canonical_lock_result': 'canonical_lock_result',
}
assert all(kv[left] == rv[right] for left, right in mapping.items())

path_digest_fields = {
    'task13_complete_log_path': 'task13_complete_log_sha256',
    'pre_deletion_receipt_path': 'pre_deletion_receipt_sha256',
    'pre_deletion_audit_path': 'pre_deletion_audit_sha256',
    'task13_verifier_path': 'task13_verifier_sha256',
    'original_manifest_artifact_path': 'original_manifest_sha256',
    'boundary_delta_artifact_path': 'boundary_delta_sha256',
    'boundary_addendum_artifact_path': 'boundary_addendum_sha256',
    'effective_matrix_artifact_path': 'effective_matrix_sha256',
    'state_schema_artifact_path': 'state_schema_sha256',
    'state_fixture_artifact_path': 'state_fixture_sha256',
    'bundle_receipt_artifact_path': 'bundle_receipt_sha256',
    'task14_complete_log_path': 'task14_complete_log_sha256',
    'task14_removal_audit_path': 'task14_removal_audit_sha256',
}
for path_key, digest_key in path_digest_fields.items():
    path = Path(kv[path_key])
    assert not path.is_absolute() and '..' not in path.parts and path.is_file()
    assert hashlib.sha256(path.read_bytes()).hexdigest() == kv[digest_key]

tables = {
    'original_manifest_artifact_path': 'original_manifest_row_count',
    'boundary_delta_artifact_path': 'boundary_delta_row_count',
    'boundary_addendum_artifact_path': 'boundary_addendum_row_count',
    'effective_matrix_artifact_path': 'effective_matrix_row_count',
}
for path_key, count_key in tables.items():
    data_rows = sum(1 for _ in Path(kv[path_key]).open()) - 1
    assert data_rows == int(kv[count_key])

print('handoff_receipt_mapping=PASS current_manifest_rows=300 historical_rows=303')'
command_exit_code=cmd2:0
command_stdout_sha256=cmd2:3688218c765b059d7cd71dabf548b46f4764a5583991c6f0c23bfbf9b8cb0990
command_stderr_sha256=cmd2:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_id=cmd3
command_text=cmd3:bash -euo pipefail -c 'python3 -c 'from pathlib import Path; import subprocess,sys; kv=dict(line.split(": ",1) for line in Path("HANDOFF.md").read_text().split("\n---\n",1)[0].splitlines()[1:]); subprocess.run([sys.executable,kv["task13_verifier_path"],"--workspace",".","check-archived"],check=True)' && python3 -c 'from pathlib import Path; kv=dict(line.split(": ",1) for line in Path("HANDOFF.md").read_text().split("\n---\n",1)[0].splitlines()[1:]); lines=Path(kv["task14_removal_audit_path"]).read_text().splitlines(); targets=["cmd/iop-chronos-transfer/main.go","cmd/iop-chronos-transfer/main_test.go","scripts/verify-iop-agent-chronos-boundary.py","scripts/verify_iop_agent_chronos_boundary_test.py","scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv","scripts/fixtures/iop-agent-chronos-transfer-state-v1.schema.json","scripts/fixtures/iop-agent-chronos-transfer-state-v1.json","scripts/fixtures/iop-agent-chronos-transfer-bundle-receipt-v1.json","scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.tsv","scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.sha256","scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.tsv","scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.sha256"]; assert all(sum(1 for line in lines if line.startswith("pre_delete_path="+target+"\tsha256=") and len(line.rsplit("=",1)[1])==64)==1 for target in targets); assert all(lines.count("post_delete_absent="+target)==1 for target in targets); assert lines.count("pre_delete_digest_count=12")==1 and lines.count("post_delete_absence_count=12")==1 and lines.count("task14_removal_status=pass")==1; print("task14_pre_post_receipt=PASS")''
command_exit_code=cmd3:0
command_stdout_sha256=cmd3:6b6cc84a3748c511b6a14a4ccff24c4316cc8baada9fb8ad723e7dc883ce204c
command_stderr_sha256=cmd3:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_id=cmd4
command_text=cmd4:bash -euo pipefail -c 'paths=(apps/agent packages/go/agentruntime packages/go/agentprovider packages/go/provider/cli proto/iop/agent.proto agent-contract/inner/iop-agent-cli-runtime.md cmd/iop-chronos-transfer scripts/verify-iop-agent-chronos-boundary.py scripts/verify_iop_agent_chronos_boundary_test.py scripts/fixtures/iop-agent-chronos-ownership-manifest.tsv scripts/fixtures/iop-agent-chronos-transfer-state-v1.schema.json scripts/fixtures/iop-agent-chronos-transfer-state-v1.json scripts/fixtures/iop-agent-chronos-transfer-bundle-receipt-v1.json scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.tsv scripts/fixtures/iop-agent-chronos-boundary-disposition-delta-v1.sha256 scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.tsv scripts/fixtures/iop-agent-chronos-boundary-surface-addendum-v1.sha256); for p in "${paths[@]}"; do test ! -e "$p"; done; roots=(apps packages cmd configs proto agent-contract agent-spec); for r in "${roots[@]}"; do test -d "$r"; done; set +e; out=$(rg --sort path -n --glob "!apps/client/lib/gen/**" --glob "!proto/gen/**" "verify-iop-agent-chronos-boundary\.py|verify_iop_agent_chronos_boundary_test\.py|git\.toki-labs\.com/toki/chronos|/config/workspace/chronos|CHRONOS_|[Cc]hronos(Target|Registry|Bridge|Server|Node|Control|Connector|Gateway)|chronos_(target|registry|bridge|server|node|control|connector|gateway)|chronos-(target|registry|bridge|server|node|control|connector|gateway)|agent_bridge|CLIAdapterConfig|CLIProfileConfig|AgentUsageStatus|persistent_(terminal|process)|codex-app-server|opencode-sse|quota[-_]?probe" "${roots[@]}" 2>&1); rc=$?; set -e; test "$rc" -eq 1 || { printf "%s\n" "$out" >&2; exit 1; }'
command_exit_code=cmd4:0
command_stdout_sha256=cmd4:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_stderr_sha256=cmd4:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_id=cmd5
command_text=cmd5:bash -c 'go test -count=1 ./apps/node/... && go test -count=1 ./... && make readability-audit'
command_exit_code=cmd5:0
command_stdout_sha256=cmd5:deb933920fdf04efc45f48707a6c6c4fb6e01c2096d14679dfbf86c552f3d0e8
command_stderr_sha256=cmd5:cc53ac06e247e23a66b4fe0f0379f382c53ace2c61e8b6ab3a6bd74d67006ab1
command_id=cmd6
command_text=cmd6:python3 -c 'from pathlib import Path
import hashlib

text = Path('HANDOFF.md').read_text()
assert text.startswith('---\n') and '\n---\n' in text
lines = text.split('\n---\n', 1)[0].splitlines()[1:]
kv = dict(line.split(': ', 1) for line in lines)
exact = {
    "handoff_version": "1",
    "handoff_status": "final",
    "source_revision": "3155be0e275437a8eedc1aa93497955a7d30465b",
    "rollback_revision": "3155be0e275437a8eedc1aa93497955a7d30465b",
    "original_manifest_row_count": "300",
    "original_manifest_file_count": "290",
    "original_manifest_state_count": "10",
    "original_manifest_retain_generic_count": "135",
    "task03_historical_row_count": "303",
    "task03_historical_file_count": "293",
    "task03_historical_state_count": "10",
    "task03_universe_residuals": "0",
    "task03_duplicate_rows": "0",
    "task14_removal_status": "pass",
    "real_state_export_location": "bundle-member:acceptance-v1/state/state-export-v1.json",
    "removed_target_count": "12",
    "pre_delete_digest_count": "12",
    "post_delete_absence_count": "12",
    "final_transfer_remove_residuals": "0",
    "final_retained_path_mismatches": "0",
    "final_renamed_source_residuals": "0",
    "final_unclassified_paths": "0",
    "final_duplicate_paths": "0",
    "provider_node_regression": "pass",
    "full_go_regression": "pass",
    "readability_audit": "pass",
    "forbidden_surface_scan": "pass",
    "iop_node_owner": "model-provider-device",
    "chronos_connection_surfaces": "0",
    "cli_agent_terminal_workspace_surfaces": "0",
    "chronos_repository_mutations": "0",
    "external_mutations": "0",
    "downstream_lock": "chronos:chronos-architecture-ownership-boundary",
    "staging_lock_result": "none",
    "canonical_lock_result": "rely-on:chronos:chronos-architecture-ownership-boundary",
    "canonical_promotion": "pending"
}
assert all(kv.get(k) == v and sum(1 for x in lines if x.startswith(k + ": ")) == 1 for k, v in exact.items())
assert all((lambda p, k: not p.is_absolute() and ".." not in p.parts and p.is_file() and hashlib.sha256(p.read_bytes()).hexdigest() == kv[k + "_sha256"])(Path(kv[k + "_path"]), k) for k in ("task14_complete_log", "task14_removal_audit"))'
command_exit_code=cmd6:0
command_stdout_sha256=cmd6:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_stderr_sha256=cmd6:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_id=cmd7
command_text=cmd7:bash -euo pipefail -c 'staging=$(agent-ops/bin/roadmap-dependency-checker.sh --find-milestone "iop-s1:agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-chronos-extraction-decoupling.md" both /config/workspace/.agent-roadmap-sync/locks.yaml); canonical=$(agent-ops/bin/roadmap-dependency-checker.sh --find-milestone "iop:agent-roadmap/phase/automation-runtime-bridge/milestones/iop-agent-chronos-extraction-decoupling.md" both /config/workspace/.agent-roadmap-sync/locks.yaml); test "$staging" = none; test "$canonical" = rely-on:chronos:chronos-architecture-ownership-boundary'
command_exit_code=cmd7:0
command_stdout_sha256=cmd7:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
command_stderr_sha256=cmd7:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
after_chronos_head=ed45e2e9c55a9e4e214198517175abf5ce8c7d92
after_chronos_status_sha256=4edb879794f484c9737248caf3d1347590a2f17d11cb4bf71704ee5031f6bd23
after_canonical_iop_head=6d6bb3a44d1384e8248d482f57de522dc800aade
after_canonical_iop_status_sha256=023af53e13dc3c6d350092e3b5ada36ad9093cea59c02220dadc3f8e26a08460
after_lock_sha256=34b76d160816aadd7bc19a1f7b5006a45c70fd459f9860df8560f0d9063161f9
