Skip to content

Commit cc7c73f

Browse files
fluffy314cursoragent
authored andcommitted
fix(autoresearch): split contract audit provenance
Retain the contract's original Definition Auditor dependency under a dedicated provenance role so a fresh typed audit can coexist without breaking the certified artifact DAG. Co-authored-by: Cursor <[email protected]>
1 parent 4910a92 commit cc7c73f

2 files changed

Lines changed: 47 additions & 7 deletions

File tree

scripts/agent_gan_repl.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import threading
1717
import time
1818
import uuid
19-
from dataclasses import asdict, dataclass, field
19+
from dataclasses import asdict, dataclass, field, replace
2020
from datetime import datetime
2121
from enum import Enum
2222
from pathlib import Path
@@ -5200,11 +5200,25 @@ def retain_contract_provenance_after_artifact_failure(
52005200
checkpoint: OrchestrationCheckpoint,
52015201
) -> None:
52025202
"""Invalidate executable role artifacts without erasing accepted strategy."""
5203-
checkpoint.validated_artifacts = {
5203+
prior = checkpoint.validated_artifacts
5204+
preserved = {
52045205
role: reference
5205-
for role, reference in checkpoint.validated_artifacts.items()
5206+
for role, reference in prior.items()
52065207
if role in {"strategy_tournament", "research_contract"}
52075208
}
5209+
definition = prior.get("definition_auditor")
5210+
tournament = prior.get("strategy_tournament")
5211+
if (
5212+
definition is not None
5213+
and tournament is not None
5214+
and definition.sha256 in tournament.dependencies
5215+
):
5216+
preserved["contract_definition_auditor"] = replace(
5217+
definition,
5218+
role="contract_definition_auditor",
5219+
strategy_plan_hash=checkpoint.target_strategy_plan_hash,
5220+
)
5221+
checkpoint.validated_artifacts = preserved
52085222

52095223

52105224
def run_certified_decomposition(

tests/inference_engine/bridge/test_agent_gan_repl.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
validate_lean_proof,
1616
)
1717
from autoresearch.prefill.orchestration_state import (
18+
ArtifactRef,
1819
OrchestrationCheckpoint,
1920
ProofState,
2021
load_checkpoint as load_orchestration_checkpoint,
@@ -3640,18 +3641,43 @@ def test_artifact_migration_failure_preserves_contract_provenance():
36403641
research_contract_hash="contract-hash",
36413642
selected_strategy_plan_id="SP-root",
36423643
selected_strategy_plan_hash="plan-hash",
3644+
target_strategy_plan_hash="plan-hash",
36433645
)
3646+
def ref(role, sha, dependencies=()):
3647+
return ArtifactRef(
3648+
role=role,
3649+
sha256=sha,
3650+
schema_version=1,
3651+
dependencies=list(dependencies),
3652+
path=f"/tmp/{sha}.json",
3653+
source_run_id="host:test",
3654+
validated_at=1.0,
3655+
)
36443656
checkpoint.validated_artifacts = {
3645-
"definition_auditor": object(),
3646-
"counterexample_worker": object(),
3647-
"strategy_tournament": object(),
3648-
"research_contract": object(),
3657+
"definition_auditor": ref("definition_auditor", "definition"),
3658+
"counterexample_worker": ref("counterexample_worker", "worker"),
3659+
"strategy_tournament": ref(
3660+
"strategy_tournament",
3661+
"tournament",
3662+
["definition"],
3663+
),
3664+
"research_contract": ref(
3665+
"research_contract",
3666+
"contract",
3667+
["tournament"],
3668+
),
36493669
}
36503670
retain_contract_provenance_after_artifact_failure(checkpoint)
36513671
assert set(checkpoint.validated_artifacts) == {
3672+
"contract_definition_auditor",
36523673
"strategy_tournament",
36533674
"research_contract",
36543675
}
3676+
contract_definition = checkpoint.validated_artifacts[
3677+
"contract_definition_auditor"
3678+
]
3679+
assert contract_definition.sha256 == "definition"
3680+
assert contract_definition.strategy_plan_hash == "plan-hash"
36553681
assert checkpoint.research_contract_id == "RC-root"
36563682
assert checkpoint.research_contract_hash == "contract-hash"
36573683
assert checkpoint.selected_strategy_plan_id == "SP-root"

0 commit comments

Comments
 (0)