Turn historical AIOS failure modes (dual-plane divergence, fake execution/
PASS-without-evidence, queued-without-claimant, exact-scope mismatch,
hash-only/placeholder artifacts, OpenAPI/backend asymmetry, capability
singular/plural asymmetry, terminal success without commit/readback) into
executable read-only invariants absorbed on the authoritative source line
(beabd05 = V2R2C2 authority main). This is a successor line; it does NOT
revive the old p0-chatgpt-bridge-v2 control-plane-convergence task line.
Adds:
- aios_control_plane_consistency: read-only derived SystemTruth (derive_truth)
+ artifact reality gate + OpenAPI/backend parity + capability alias checks.
- aios_control_plane_snapshot.attach_control_plane_truth: injects derived truth
(state + findings + evidence_flow_confirmed) into the existing explain/status
surface without mutating any persistence plane; base snapshot contract intact.
- config/gitops/system_truth_contract.json: state-ownership + completion/queue
requirements + forbidden equivalences.
- tests: 13 original hardening tests + 5 snapshot-truth integration tests
(18 passed locally).
- ADR + remediation work package docs; fault-injection + audit scripts.
Derivation is read-only; ADMITTED/QUEUED/service-active/drift_status=PASS are
not treated as evidence-complete. Evidence-required transitions and the final
E2E chain (through external projection readback / SCENARIO_ACCEPTED) remain the
release gate and are NOT claimed by this commit.
Signed-off-by: AIOS Governed Continuation <aios-governed-continuation@localhost>
90 lines
2.9 KiB
Python
90 lines
2.9 KiB
Python
from __future__ import annotations
|
|
|
|
from aios_control_plane_consistency import (
|
|
AdmissionSnapshot,
|
|
EvidenceSnapshot,
|
|
GitSnapshot,
|
|
LeaseSnapshot,
|
|
TaskSnapshot,
|
|
WorkerSnapshot,
|
|
)
|
|
from aios_control_plane_snapshot import (
|
|
attach_control_plane_truth,
|
|
build_control_plane_snapshot,
|
|
)
|
|
|
|
NOW = 2_000_000_000
|
|
|
|
|
|
def _base():
|
|
return build_control_plane_snapshot(
|
|
target_version="V2R2C2",
|
|
runtime={"drift_status": "PASS"},
|
|
task={"task_id": "T", "reconciliation_state": "ok"},
|
|
)
|
|
|
|
|
|
def test_snapshot_base_has_no_derived_block_by_default():
|
|
assert "derived" not in _base()
|
|
|
|
|
|
def test_truth_attach_preserves_existing_keys():
|
|
out = attach_control_plane_truth(_base(), now=NOW)
|
|
assert set(_base().keys()) <= set(out.keys())
|
|
assert "derived" in out
|
|
|
|
|
|
def test_admitted_without_taskplane_is_admitted_not_projected():
|
|
out = attach_control_plane_truth(
|
|
_base(),
|
|
admission=AdmissionSnapshot(task_id="T", admission_status="ADMITTED", envelope_id="E"),
|
|
now=NOW,
|
|
)
|
|
truth = out["derived"]["system_truth"]
|
|
assert truth["truth_state"] == "ADMITTED_NOT_PROJECTED"
|
|
assert truth["blocker_count"] == 1
|
|
assert any(f["code"] == "DUAL_PLANE_ADMITTED_TASK_MISSING" for f in truth["findings"])
|
|
# A drift_status=PASS surface must NOT be reported as evidence-complete.
|
|
assert truth["evidence_flow_confirmed"] is False
|
|
|
|
|
|
def test_fake_success_is_terminal_unproven_even_under_drift_pass():
|
|
out = attach_control_plane_truth(
|
|
_base(),
|
|
admission=AdmissionSnapshot(task_id="T"),
|
|
task=TaskSnapshot(task_id="T", status="SUCCEEDED"),
|
|
git=GitSnapshot("agent/x", expected_oid="a" * 40),
|
|
evidence=EvidenceSnapshot(),
|
|
now=NOW,
|
|
)
|
|
truth = out["derived"]["system_truth"]
|
|
assert truth["truth_state"] == "TERMINAL_UNPROVEN"
|
|
assert truth["blocker_count"] == 1
|
|
assert truth["evidence_flow_confirmed"] is False
|
|
|
|
|
|
def test_complete_requires_full_evidence_chain():
|
|
worker = WorkerSnapshot(
|
|
worker_id="w", status="ACTIVE", last_seen_epoch=NOW - 10,
|
|
capabilities=("governed.write.files",),
|
|
)
|
|
task = TaskSnapshot(
|
|
task_id="T", status="SUCCEEDED", claimed_by="w",
|
|
required_capabilities=("governed.write.files",),
|
|
metadata={"external_job_id": "job-a", "target_branch": "agent/x",
|
|
"execution_digest": "d" * 64},
|
|
)
|
|
git = GitSnapshot("agent/x", expected_oid="a" * 40, commit_oid="b" * 40, post_oid="c" * 40)
|
|
evidence = EvidenceSnapshot(runtime_readback={"ok": True})
|
|
out = attach_control_plane_truth(
|
|
_base(),
|
|
admission=AdmissionSnapshot(task_id="T"),
|
|
task=task, workers=[worker],
|
|
lease=LeaseSnapshot("T", "w", NOW + 60, "ACTIVE"),
|
|
git=git, evidence=evidence, now=NOW,
|
|
)
|
|
truth = out["derived"]["system_truth"]
|
|
assert truth["truth_state"] == "COMPLETE"
|
|
assert truth["blocker_count"] == 0
|
|
assert truth["evidence_flow_confirmed"] is True
|