mirror of
https://github.com/instructkr/claw-code.git
synced 2026-05-19 05:51:26 +08:00
omx(team): auto-checkpoint worker-3 [6]
This commit is contained in:
81
rust/crates/runtime/tests/fixtures/g004_contract_bundle.valid.json
vendored
Normal file
81
rust/crates/runtime/tests/fixtures/g004_contract_bundle.valid.json
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
"schemaVersion": "g004.contract.bundle.v1",
|
||||
"laneEvents": [
|
||||
{
|
||||
"event": "lane.started",
|
||||
"status": "running",
|
||||
"emittedAt": "2026-05-14T00:00:00Z",
|
||||
"metadata": {
|
||||
"seq": 1,
|
||||
"provenance": "live_lane",
|
||||
"emitterIdentity": "worker-1",
|
||||
"environmentLabel": "team-g004"
|
||||
}
|
||||
},
|
||||
{
|
||||
"event": "lane.finished",
|
||||
"status": "completed",
|
||||
"emittedAt": "2026-05-14T00:00:10Z",
|
||||
"metadata": {
|
||||
"seq": 2,
|
||||
"provenance": "live_lane",
|
||||
"emitterIdentity": "worker-1",
|
||||
"environmentLabel": "team-g004",
|
||||
"eventFingerprint": "terminal-fp-001"
|
||||
}
|
||||
}
|
||||
],
|
||||
"reports": [
|
||||
{
|
||||
"schemaVersion": "g004.report.v1",
|
||||
"reportId": "report-g004-fixture",
|
||||
"identity": { "contentHash": "sha256:report-content" },
|
||||
"projection": { "provenance": "runtime.event_projection.v1" },
|
||||
"redaction": { "provenance": "runtime.redaction_policy.v1" },
|
||||
"consumerCapabilities": ["facts", "field_deltas", "redaction_provenance"],
|
||||
"findings": [
|
||||
{
|
||||
"kind": "fact",
|
||||
"confidence": "high",
|
||||
"statement": "lane event reached terminal state"
|
||||
},
|
||||
{
|
||||
"kind": "hypothesis",
|
||||
"confidence": "medium",
|
||||
"statement": "consumer can reconcile the terminal fingerprint"
|
||||
},
|
||||
{
|
||||
"kind": "negative_evidence",
|
||||
"confidence": "high",
|
||||
"statement": "no duplicate terminal event appears in this fixture"
|
||||
}
|
||||
],
|
||||
"fieldDeltas": [
|
||||
{
|
||||
"field": "/laneEvents/1/status",
|
||||
"previousHash": "sha256:running",
|
||||
"currentHash": "sha256:completed",
|
||||
"attribution": "worker-1 terminal reconciliation"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"approvalTokens": [
|
||||
{
|
||||
"tokenId": "approval-token-fixture",
|
||||
"owner": "leader-fixed",
|
||||
"scope": "g004.contract.bundle.fixture",
|
||||
"issuedAt": "2026-05-14T00:00:01Z",
|
||||
"oneTimeUse": true,
|
||||
"replayPreventionNonce": "nonce-fixture-001",
|
||||
"delegationChain": [
|
||||
{
|
||||
"from": "leader-fixed",
|
||||
"to": "worker-3",
|
||||
"action": "validate-g004-contract-fixture",
|
||||
"at": "2026-05-14T00:00:02Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
79
rust/crates/runtime/tests/g004_conformance.rs
Normal file
79
rust/crates/runtime/tests/g004_conformance.rs
Normal file
@@ -0,0 +1,79 @@
|
||||
use runtime::g004_conformance::{
|
||||
is_g004_contract_bundle_valid, validate_g004_contract_bundle,
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
fn valid_bundle() -> Value {
|
||||
serde_json::from_str(include_str!("fixtures/g004_contract_bundle.valid.json"))
|
||||
.expect("valid fixture JSON should parse")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn valid_g004_contract_bundle_fixture_passes_conformance() {
|
||||
let fixture = valid_bundle();
|
||||
|
||||
let errors = validate_g004_contract_bundle(&fixture);
|
||||
|
||||
assert!(errors.is_empty(), "unexpected conformance errors: {errors:?}");
|
||||
assert!(is_g004_contract_bundle_valid(&fixture));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn g004_conformance_reports_machine_readable_paths_for_contract_gaps() {
|
||||
let invalid = json!({
|
||||
"schemaVersion": "g004.contract.bundle.v1",
|
||||
"laneEvents": [
|
||||
{
|
||||
"event": "lane.finished",
|
||||
"status": "completed",
|
||||
"emittedAt": "2026-05-14T00:00:10Z",
|
||||
"metadata": {
|
||||
"seq": 1,
|
||||
"provenance": "live_lane",
|
||||
"emitterIdentity": "worker-1",
|
||||
"environmentLabel": "team-g004"
|
||||
}
|
||||
}
|
||||
],
|
||||
"reports": [
|
||||
{
|
||||
"schemaVersion": "g004.report.v1",
|
||||
"reportId": "report-with-gaps",
|
||||
"identity": { "contentHash": "sha256:report-content" },
|
||||
"projection": { "provenance": "runtime.event_projection.v1" },
|
||||
"redaction": { "provenance": "runtime.redaction_policy.v1" },
|
||||
"consumerCapabilities": [],
|
||||
"findings": [
|
||||
{
|
||||
"kind": "guess",
|
||||
"confidence": "certain",
|
||||
"statement": "bad labels should be rejected"
|
||||
}
|
||||
],
|
||||
"fieldDeltas": []
|
||||
}
|
||||
],
|
||||
"approvalTokens": [
|
||||
{
|
||||
"tokenId": "approval-token-fixture",
|
||||
"owner": "leader-fixed",
|
||||
"scope": "g004.contract.bundle.fixture",
|
||||
"issuedAt": "2026-05-14T00:00:01Z",
|
||||
"oneTimeUse": false,
|
||||
"replayPreventionNonce": "nonce-fixture-001",
|
||||
"delegationChain": []
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
let errors = validate_g004_contract_bundle(&invalid);
|
||||
let paths: Vec<&str> = errors.iter().map(|error| error.path.as_str()).collect();
|
||||
|
||||
assert!(paths.contains(&"/laneEvents/0/metadata/eventFingerprint"));
|
||||
assert!(paths.contains(&"/reports/0/consumerCapabilities"));
|
||||
assert!(paths.contains(&"/reports/0/findings/0/kind"));
|
||||
assert!(paths.contains(&"/reports/0/findings/0/confidence"));
|
||||
assert!(paths.contains(&"/reports/0/fieldDeltas"));
|
||||
assert!(paths.contains(&"/approvalTokens/0/oneTimeUse"));
|
||||
assert!(paths.contains(&"/approvalTokens/0/delegationChain"));
|
||||
}
|
||||
Reference in New Issue
Block a user