fix: address contribution review validation and harness findings

This commit is contained in:
djpjronline-netizen committed 2026-10-30 11:28:42 -04:00
1 parent 1754844aa4
commit d6b84ecef8
14 files changed
+412 -107

No files matched your search

@@ -0,0 +1,28 @@
# ECC cross-harness skill contribution review
This compiler converts supplied skill observations into a structured contribution
review packet. It supports only `changeKind: "skill"`, with canonical source
under `skills/` and the required skill artifacts and harness mirrors. It checks
the declared source ownership, generated-root exclusion, install coverage, cross-harness identity, catalog reconciliation,
TDD claims, security claims, validation gates, and commit proposal for internal
consistency. It does not inspect the repository or independently verify any
claim or referenced evidence, so it cannot establish contribution readiness.
PCCA ownership:
- observation-and-data: repository, diff, artifact, gate, count, and coverage
observations;
- epistemic-and-lineage: base/head, hashes, canonical source, mirrors, and test
evidence;
- state-and-relationship: artifact graph, harness parity, manifests, catalogs,
and checkpoint;
- cognitive-control: TDD, gate selection, coverage, and commit formulation;
- meta-control: contradiction detection, page faults, hostile probes, and typed
runners;
- viability-and-policy: security, provenance, breaking-change, budget, and
external-effect boundaries.
The semantic checksum uses sorted compact UTF-8 JSON and excludes
`artifactId`, `semanticChecksum`, and `returnReceipt`. The compiler writes a
capsule file only when the caller supplies `--output`; the receipt distinguishes
that generated artifact from implementation-file changes.
@@ -0,0 +1,30 @@
# Skill contribution workflow
1. Resolve the active ECC checkout, non-default branch, base/head, package lock,
manifests, catalog script, placement policy, and checkpoint.
2. Use `changeKind: "skill"` and name the canonical source under `skills/`
before editing a mirror. This version supports skill contributions only.
3. Observe RED with named failing behaviors.
4. Implement GREEN in the canonical surface, then REFACTOR.
5. Update only required install manifests, documentation, and harness adapters.
6. Normalize content identity across Claude, Codex, and Cursor; record every
intentional frontmatter or metadata adaptation.
7. Reconcile agent, skill, command, manifest, catalog, registry, and intentionally
unshipped counts.
8. Run the eight exact validation gates and record argv, exit status, and
evidence.
9. Check secrets, personal paths, permissions, hooks, prompt-injection boundary,
supply chain, coverage, breaking-change status, and budgets.
10. Compile the review packet. The compiler checks supplied claims for shape and
internal consistency but does not verify referenced evidence or approve a
contribution. Exit code 0 means a packet was emitted without reported
faults or contradictions; review is still required. Exit code 2 means
validation faults, contradictions, or an input/output error. A diagnostic
packet may still be emitted with exit code 2. Inspect the packet and stderr;
the exit code alone does not establish whether output exists. Resolve
every contradiction and semantic page fault before preparing a commit.
11. The compiler runs no proposed runners. Obtain separate authorization
before implementation-file, test, catalog, commit, push, PR, Control Store,
canonical-memory, or Semantic Commit effects.
12. Supersede the packet on HEAD, policy, manifest, catalog, adapter, test,
coverage, security, or review drift.
@@ -0,0 +1,36 @@
# ECC skill contribution review contract
The compiler prepares packets for skill contributions only
(`changeKind: "skill"`). It validates the shape and internal consistency of
supplied observations; it does not independently
inspect repository files, Git state, CI, tests, coverage, or evidence refs.
Every structurally valid packet returns `require_review`. Contradictions
return `reject`. Neither result approves or qualifies a contribution.
The envelope requires `schemaVersion: "1.0.0"`, an ISO 8601 `observedAt`
timestamp with a timezone, and a nonempty string `subjectRef`. Unsupported
versions and malformed identifiers produce validation faults.
The local observation contract checks for:
- exact active repository, non-default branch, base/head, package lock, install
manifests, catalog script, placement policy, and checkpoint identity;
- a bounded, non-breaking skill change under `skills/` with no unnecessary
command shim;
- one canonical curated source, explicit non-generated artifacts, manifest
coverage, tests, and required harness metadata;
- normalized content parity across Claude, Codex, and Cursor with zero drift;
- filesystem/documented counts, manifest coverage, intentional unshipped
exceptions, catalog check, and command registry reconciled, with nonnegative
curated and intentionally unshipped skill counts;
- observed RED/GREEN/REFACTOR, named failing tests, passing behavior tests, and
line/function/branch/statement coverage between 80% and 100% inclusive;
- eight green validators, security and supply-chain review, bounded change/test
budgets, twelve hostile probes, and seven typed runners;
- a concise conventional commit proposal, while commit/push/PR effects remain
false;
- no source-file, test, catalog, git, PR, Control Store, canonical-memory, or
Semantic Commit claim or requested effect;
- every generated `may*` authority false.
Contradictions reject. Missing or malformed observations require review.
@@ -0,0 +1,28 @@
# ECC cross-harness skill contribution review
This compiler converts supplied skill observations into a structured contribution
review packet. It supports only `changeKind: "skill"`, with canonical source
under `skills/` and the required skill artifacts and harness mirrors. It checks
the declared source ownership, generated-root exclusion, install coverage, cross-harness identity, catalog reconciliation,
TDD claims, security claims, validation gates, and commit proposal for internal
consistency. It does not inspect the repository or independently verify any
claim or referenced evidence, so it cannot establish contribution readiness.
PCCA ownership:
- observation-and-data: repository, diff, artifact, gate, count, and coverage
observations;
- epistemic-and-lineage: base/head, hashes, canonical source, mirrors, and test
evidence;
- state-and-relationship: artifact graph, harness parity, manifests, catalogs,
and checkpoint;
- cognitive-control: TDD, gate selection, coverage, and commit formulation;
- meta-control: contradiction detection, page faults, hostile probes, and typed
runners;
- viability-and-policy: security, provenance, breaking-change, budget, and
external-effect boundaries.
The semantic checksum uses sorted compact UTF-8 JSON and excludes
`artifactId`, `semanticChecksum`, and `returnReceipt`. The compiler writes a
capsule file only when the caller supplies `--output`; the receipt distinguishes
that generated artifact from implementation-file changes.
@@ -0,0 +1,30 @@
# Skill contribution workflow
1. Resolve the active ECC checkout, non-default branch, base/head, package lock,
manifests, catalog script, placement policy, and checkpoint.
2. Use `changeKind: "skill"` and name the canonical source under `skills/`
before editing a mirror. This version supports skill contributions only.
3. Observe RED with named failing behaviors.
4. Implement GREEN in the canonical surface, then REFACTOR.
5. Update only required install manifests, documentation, and harness adapters.
6. Normalize content identity across Claude, Codex, and Cursor; record every
intentional frontmatter or metadata adaptation.
7. Reconcile agent, skill, command, manifest, catalog, registry, and intentionally
unshipped counts.
8. Run the eight exact validation gates and record argv, exit status, and
evidence.
9. Check secrets, personal paths, permissions, hooks, prompt-injection boundary,
supply chain, coverage, breaking-change status, and budgets.
10. Compile the review packet. The compiler checks supplied claims for shape and
internal consistency but does not verify referenced evidence or approve a
contribution. Exit code 0 means a packet was emitted without reported
faults or contradictions; review is still required. Exit code 2 means
validation faults, contradictions, or an input/output error. A diagnostic
packet may still be emitted with exit code 2. Inspect the packet and stderr;
the exit code alone does not establish whether output exists. Resolve
every contradiction and semantic page fault before preparing a commit.
11. The compiler runs no proposed runners. Obtain separate authorization
before implementation-file, test, catalog, commit, push, PR, Control Store,
canonical-memory, or Semantic Commit effects.
12. Supersede the packet on HEAD, policy, manifest, catalog, adapter, test,
coverage, security, or review drift.
@@ -0,0 +1,36 @@
# ECC skill contribution review contract
The compiler prepares packets for skill contributions only
(`changeKind: "skill"`). It validates the shape and internal consistency of
supplied observations; it does not independently
inspect repository files, Git state, CI, tests, coverage, or evidence refs.
Every structurally valid packet returns `require_review`. Contradictions
return `reject`. Neither result approves or qualifies a contribution.
The envelope requires `schemaVersion: "1.0.0"`, an ISO 8601 `observedAt`
timestamp with a timezone, and a nonempty string `subjectRef`. Unsupported
versions and malformed identifiers produce validation faults.
The local observation contract checks for:
- exact active repository, non-default branch, base/head, package lock, install
manifests, catalog script, placement policy, and checkpoint identity;
- a bounded, non-breaking skill change under `skills/` with no unnecessary
command shim;
- one canonical curated source, explicit non-generated artifacts, manifest
coverage, tests, and required harness metadata;
- normalized content parity across Claude, Codex, and Cursor with zero drift;
- filesystem/documented counts, manifest coverage, intentional unshipped
exceptions, catalog check, and command registry reconciled, with nonnegative
curated and intentionally unshipped skill counts;
- observed RED/GREEN/REFACTOR, named failing tests, passing behavior tests, and
line/function/branch/statement coverage between 80% and 100% inclusive;
- eight green validators, security and supply-chain review, bounded change/test
budgets, twelve hostile probes, and seven typed runners;
- a concise conventional commit proposal, while commit/push/PR effects remain
false;
- no source-file, test, catalog, git, PR, Control Store, canonical-memory, or
Semantic Commit claim or requested effect;
- every generated `may*` authority false.
Contradictions reject. Missing or malformed observations require review.
@@ -10,7 +10,7 @@
"id": "hand-seeded",
"source": "manual-curation-pending-regeneration"
},
"registryDigest": "e1ed66042497cce6f093f7b856baf4731ece6c3344c44650c863f22e020f38f7",
"registryDigest": "ac3209d3e03a4b28d796dd6bf75c81a0452c88aae691c8a4fec95544c07e82c8",
"schemaVersion": 1,
"triggers": {
"skill:agent-runtime-gateway-smoke-test": [
@@ -300,9 +300,12 @@ def compile_contract(
**_packet_memory(data),
"returnReceipt": output_receipt,
}
artifact["semanticChecksum"] = checksum(artifact)
artifact["returnReceipt"]["semanticChecksum"] = artifact["semanticChecksum"]
return artifact
semantic_checksum = checksum(artifact)
return {
**artifact,
"semanticChecksum": semantic_checksum,
"returnReceipt": {**output_receipt, "semanticChecksum": semantic_checksum},
}
def main() -> int:
@@ -90,13 +90,14 @@ def safe_repo_path(value: Any) -> bool:
return not path.is_absolute() and path.as_posix() == value
def add_issue(issues: list[dict[str, Any]], code: str, plane: int, detail: str) -> None:
if code not in {issue["code"] for issue in issues}:
issues.append({"code": code, "plane": plane, "detail": detail})
def add_issue(issues: list[dict[str, Any]], code: str, plane: int, detail: str) -> list[dict[str, Any]]:
if code in {issue["code"] for issue in issues}:
return list(issues)
return [*issues, {"code": code, "plane": plane, "detail": detail}]
def _validate_repo(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_repo(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
repo = observation["repoIdentity"]
repo_fields = {
"rootName", "rootPathRef", "branch", "baseSha256", "headSha256",
@@ -114,11 +115,12 @@ def _validate_repo(observation: dict[str, Any], faults: list[dict[str, Any]]) ->
or any(not is_sha256(repo.get(key)) for key in repo_fields if key.endswith("Sha256"))
or repo.get("baseSha256") == repo.get("headSha256")
):
add_issue(faults, "repo_identity_failed", 2,
faults = add_issue(faults, "repo_identity_failed", 2,
"Active ECC root, non-default branch, distinct base/head, manifests, catalog, policy, and checkpoint hashes are required.")
return faults
def _validate_intent(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_intent(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
intent = observation["changeIntent"]
intent_fields = {
"changeId", "changeKind", "canonicalSurface", "canonicalPath",
@@ -143,11 +145,12 @@ def _validate_intent(observation: dict[str, Any], faults: list[dict[str, Any]])
or not intent.get("evidenceRefs")
or not isinstance(intent.get("counterevidenceRefs"), list)
):
add_issue(faults, "change_intent_failed", 1,
faults = add_issue(faults, "change_intent_failed", 1,
"A bounded non-breaking skills-first change with explicit scopes and evidence refs is required.")
return faults
def _validate_surface(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_surface(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
surface = observation["surfaceContract"]
surface_fields = {
"canonicalFirst", "generatedRootsExcluded", "curatedSkill",
@@ -169,11 +172,12 @@ def _validate_surface(observation: dict[str, Any], faults: list[dict[str, Any]])
or not isinstance(surface.get("evidenceRefs"), list)
or not surface.get("evidenceRefs")
):
add_issue(faults, "canonical_surface_failed", 6,
faults = add_issue(faults, "canonical_surface_failed", 6,
"Curated skills/ must lead; generated roots must be excluded; manifest, docs, and intentional mirrors are required.")
return faults
def _validate_artifacts(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_artifacts(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
intent = observation["changeIntent"]
artifacts = observation["artifactRecords"]
artifact_fields = {
@@ -186,7 +190,7 @@ def _validate_artifacts(observation: dict[str, Any], faults: list[dict[str, Any]
if not isinstance(artifact, dict):
artifact_bad = True
continue
artifact_paths.append(artifact.get("path"))
artifact_paths = [*artifact_paths, artifact.get("path")]
source_of_truth = artifact.get("role") == "canonical-skill"
if (
set(artifact) != artifact_fields
@@ -213,8 +217,9 @@ def _validate_artifacts(observation: dict[str, Any], faults: list[dict[str, Any]
or canonical_artifacts[0].get("path") != intent.get("canonicalPath")
or artifact_bad
):
add_issue(faults, "artifact_graph_failed", 2,
faults = add_issue(faults, "artifact_graph_failed", 2,
"Six unique, extant, hash-bound artifacts with one exact canonical source are required.")
return faults
def _parity_targets_valid(targets: list[Any], canonical_content: Any) -> bool:
@@ -234,7 +239,7 @@ def _parity_targets_valid(targets: list[Any], canonical_content: Any) -> bool:
for item in targets
)
def _validate_parity(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_parity(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
artifacts = observation["artifactRecords"]
parity = observation["harnessParity"]
parity_fields = {
@@ -274,11 +279,12 @@ def _validate_parity(observation: dict[str, Any], faults: list[dict[str, Any]])
or not parity.get("evidenceRefs")
or parity_artifacts_bad
):
add_issue(faults, "harness_parity_failed", 3,
faults = add_issue(faults, "harness_parity_failed", 3,
"Claude, Codex, and Cursor surfaces must retain normalized content identity with explicit adaptations and no drift.")
return faults
def _validate_catalog(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_catalog(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
catalog = observation["catalogContract"]
catalog_fields = {
"filesystemAgents", "documentedAgents", "filesystemSkills", "documentedSkills",
@@ -318,11 +324,12 @@ def _validate_catalog(observation: dict[str, Any], faults: list[dict[str, Any]])
or not isinstance(catalog.get("evidenceRefs"), list)
or not catalog.get("evidenceRefs")
):
add_issue(faults, "catalog_reconciliation_failed", 3,
faults = add_issue(faults, "catalog_reconciliation_failed", 3,
"Filesystem/documented counts, manifest coverage, intentional exceptions, catalog, and registry checks must reconcile.")
return faults
def _validate_gates(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_gates(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
validation = observation["validationMatrix"]
validation_fields = {"gateId", "commandArgv", "expectedExit", "observedExit", "evidenceRefs"}
if (
@@ -341,11 +348,12 @@ def _validate_gates(observation: dict[str, Any], faults: list[dict[str, Any]]) -
for item in validation
)
):
add_issue(faults, "validation_matrix_failed", 5,
faults = add_issue(faults, "validation_matrix_failed", 5,
"Eight exact argv gates must be recorded green with evidence references.")
return faults
def _validate_tdd(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_tdd(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
tdd = observation["tddContract"]
tdd_fields = {
"redObserved", "failingTestIds", "greenObserved", "refactorObserved",
@@ -370,11 +378,12 @@ def _validate_tdd(observation: dict[str, Any], faults: list[dict[str, Any]]) ->
or not isinstance(tdd.get("evidenceRefs"), list)
or not tdd.get("evidenceRefs")
):
add_issue(faults, "tdd_contract_failed", 4,
faults = add_issue(faults, "tdd_contract_failed", 4,
"Observed RED/GREEN/REFACTOR, named failures, passing behavior tests, and at least 80 percent coverage are required.")
return faults
def _validate_security(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_security(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
security = observation["securityContract"]
security_fields = {
"secretsDetected", "personalPathsDetected", "unsafePermissionsDetected",
@@ -393,11 +402,12 @@ def _validate_security(observation: dict[str, Any], faults: list[dict[str, Any]]
or not isinstance(security.get("evidenceRefs"), list)
or not security.get("evidenceRefs")
):
add_issue(faults, "security_contract_failed", 6,
faults = add_issue(faults, "security_contract_failed", 6,
"Secret, path, permission, hook, prompt-injection, supply-chain, and authority observations are required.")
return faults
def _validate_budget(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_budget(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
budget = observation["budgetContract"]
budget_fields = {
"maximumChangedFiles", "observedChangedFiles", "maximumChangedLines",
@@ -421,11 +431,12 @@ def _validate_budget(observation: dict[str, Any], faults: list[dict[str, Any]])
or not isinstance(budget.get("evidenceRefs"), list)
or not budget.get("evidenceRefs")
):
add_issue(faults, "change_budget_failed", 6,
faults = add_issue(faults, "change_budget_failed", 6,
"Changed-file, changed-line, and test-runtime budgets must be nonnegative and bounded.")
return faults
def _validate_commit(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_commit(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
commit = observation["commitContract"]
commit_fields = {
"type", "scope", "subject", "subjectLength", "conventional", "commitCreated",
@@ -445,11 +456,12 @@ def _validate_commit(observation: dict[str, Any], faults: list[dict[str, Any]])
or not isinstance(commit.get("evidenceRefs"), list)
or not commit.get("evidenceRefs")
):
add_issue(faults, "commit_contract_failed", 6,
faults = add_issue(faults, "commit_contract_failed", 6,
"A concise conventional commit proposal is required; commit, push, and PR effects must remain false.")
return faults
def _validate_probes(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_probes(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
probes = observation["failureProbes"]
probe_fields = {"probeId", "failureMode", "expectedOutcome", "observedOutcome", "evidenceRefs"}
if (
@@ -468,11 +480,12 @@ def _validate_probes(observation: dict[str, Any], faults: list[dict[str, Any]])
for item in probes
)
):
add_issue(faults, "failure_probe_coverage_failed", 5,
faults = add_issue(faults, "failure_probe_coverage_failed", 5,
"All twelve ECC contribution probes must match expected outcomes and cite evidence.")
return faults
def _validate_checkpoint(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_checkpoint(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
repo = observation["repoIdentity"]
checkpoint = observation["checkpointContract"]
checkpoint_fields = {
@@ -491,11 +504,12 @@ def _validate_checkpoint(observation: dict[str, Any], faults: list[dict[str, Any
or not isinstance(checkpoint.get("remainingUnknowns"), list)
or not checkpoint.get("remainingUnknowns")
):
add_issue(faults, "checkpoint_contract_failed", 5,
faults = add_issue(faults, "checkpoint_contract_failed", 5,
"Exact repository, policy, checkpoint, runner, state, and unknown identities are required.")
return faults
def _validate_runners(observation: dict[str, Any], faults: list[dict[str, Any]]) -> None:
def _validate_runners(observation: dict[str, Any], faults: list[dict[str, Any]]) -> list[dict[str, Any]]:
runners = observation["runnerProposals"]
runner_fields = {"role", "argv"}
if (
@@ -510,11 +524,12 @@ def _validate_runners(observation: dict[str, Any], faults: list[dict[str, Any]])
for item in runners
)
):
add_issue(faults, "runner_proposals_invalid", 5,
faults = add_issue(faults, "runner_proposals_invalid", 5,
"Seven typed non-shell argv proposals are required.")
return faults
def _validate_authority(observation: dict[str, Any], contradictions: list[dict[str, Any]]) -> None:
def _validate_authority(observation: dict[str, Any], contradictions: list[dict[str, Any]]) -> list[dict[str, Any]]:
forbidden_claims = (
("claimsSourceFilesWrittenByController", "file_write_claim_forbidden"),
("claimsTestsExecutedByController", "test_execution_claim_forbidden"),
@@ -525,29 +540,27 @@ def _validate_authority(observation: dict[str, Any], contradictions: list[dict[s
)
for field, code in forbidden_claims:
if observation.get(field) is not False:
contradictions.append({
"code": code,
"plane": 2,
"detail": "The compiler cannot claim repository or external effects.",
})
requested_effects = observation["requestedEffects"]
if set(requested_effects) != EFFECT_FIELDS or any(
contradictions = add_issue(
contradictions, code, 2,
"The compiler cannot claim repository or external effects.",
)
requested_effects = observation.get("requestedEffects")
if not isinstance(requested_effects, dict) or set(requested_effects) != EFFECT_FIELDS or any(
value is not False for value in requested_effects.values()
):
contradictions.append({
"code": "external_action_requested",
"plane": 6,
"detail": "Compilation cannot request source, test, catalog, Git, PR, or memory effects.",
})
claimed_authority = observation["claimedAuthority"]
if set(claimed_authority) != AUTHORITY_FIELDS or any(
contradictions = add_issue(
contradictions, "external_action_requested", 6,
"Compilation cannot request source, test, catalog, Git, PR, or memory effects.",
)
claimed_authority = observation.get("claimedAuthority")
if not isinstance(claimed_authority, dict) or set(claimed_authority) != AUTHORITY_FIELDS or any(
value is not False for value in claimed_authority.values()
):
contradictions.append({
"code": "unsafe_generated_authority",
"plane": 6,
"detail": "Generated authority must remain false.",
})
contradictions = add_issue(
contradictions, "unsafe_generated_authority", 6,
"Generated authority must remain false.",
)
return contradictions
def _valid_timestamp(value: Any) -> bool:
@@ -562,7 +575,7 @@ def _valid_timestamp(value: Any) -> bool:
return stamp.tzinfo is not None and stamp.utcoffset() is not None
def _valid_envelope(observation: Any, faults: list[dict[str, Any]]) -> bool:
def _valid_envelope(observation: Any, faults: list[dict[str, Any]]) -> tuple[bool, list[dict[str, Any]]]:
required = {
"schemaVersion", "observedAt", "subjectRef", "repoIdentity", "changeIntent",
"surfaceContract", "artifactRecords", "harnessParity", "catalogContract",
@@ -573,17 +586,17 @@ def _valid_envelope(observation: Any, faults: list[dict[str, Any]]) -> bool:
"claimsPullRequestOpened", "requestedEffects", "claimedAuthority",
}
if not isinstance(observation, dict) or not required.issubset(observation):
add_issue(faults, "observation_envelope_incomplete", 1,
faults = add_issue(faults, "observation_envelope_incomplete", 1,
"Required ECC contribution observations are missing.")
return False
return False, faults
if observation.get("schemaVersion") != "1.0.0":
add_issue(faults, "schema_version_unsupported", 1, "Only schema version 1.0.0 is supported.")
faults = add_issue(faults, "schema_version_unsupported", 1, "Only schema version 1.0.0 is supported.")
if not _valid_timestamp(observation.get("observedAt")):
add_issue(faults, "observed_at_invalid", 1, "An ISO 8601 observation timestamp with a timezone is required.")
faults = add_issue(faults, "observed_at_invalid", 1, "An ISO 8601 observation timestamp with a timezone is required.")
subject = observation.get("subjectRef")
if not isinstance(subject, str) or not subject.strip():
add_issue(faults, "subject_ref_invalid", 1, "A nonempty subject reference string is required.")
faults = add_issue(faults, "subject_ref_invalid", 1, "A nonempty subject reference string is required.")
map_fields = (
"repoIdentity", "changeIntent", "surfaceContract", "harnessParity",
@@ -594,43 +607,30 @@ def _valid_envelope(observation: Any, faults: list[dict[str, Any]]) -> bool:
if any(not isinstance(observation[field], dict) for field in map_fields) or any(
not isinstance(observation[field], list) for field in list_fields
):
add_issue(faults, "observation_shape_invalid", 1,
faults = add_issue(faults, "observation_shape_invalid", 1,
"Declared maps and arrays must retain their documented shapes.")
return False
return True
return False, faults
return True, faults
def _validate(observation: Any) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
faults: list[dict[str, Any]] = []
contradictions: list[dict[str, Any]] = []
if not _valid_envelope(observation, faults):
return faults, contradictions
_validate_repo(observation, faults)
_validate_intent(observation, faults)
_validate_surface(observation, faults)
_validate_artifacts(observation, faults)
_validate_parity(observation, faults)
_validate_catalog(observation, faults)
_validate_gates(observation, faults)
_validate_tdd(observation, faults)
_validate_security(observation, faults)
_validate_budget(observation, faults)
_validate_commit(observation, faults)
_validate_probes(observation, faults)
_validate_checkpoint(observation, faults)
_validate_runners(observation, faults)
_validate_authority(observation, contradictions)
return faults, contradictions
def validate(observation: Any) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
"""Validate an untrusted JSON value without letting malformed shapes crash the CLI."""
try:
return _validate(observation)
except (AttributeError, TypeError, ValueError):
fault = {
"code": "observation_shape_invalid",
"plane": 1,
"detail": "Observation values must match the documented JSON types.",
}
return [fault], []
"""Retain independent diagnostics even when one untrusted section is malformed."""
valid_envelope, faults = _valid_envelope(observation, [])
contradictions = _validate_authority(observation, []) if isinstance(observation, dict) else []
if not valid_envelope:
return faults, contradictions
validators = (
_validate_repo, _validate_intent, _validate_surface, _validate_artifacts,
_validate_parity, _validate_catalog, _validate_gates, _validate_tdd,
_validate_security, _validate_budget, _validate_commit, _validate_probes,
_validate_checkpoint, _validate_runners,
)
for validator in validators:
try:
faults = validator(observation, faults)
except (AttributeError, TypeError, ValueError):
faults = add_issue(
faults, "observation_shape_invalid", 1,
"Observation values must match the documented JSON types.",
)
return faults, contradictions
@@ -1,6 +1,6 @@
{
"errors": [],
"generated_at": "2026-10-18T00:03:57Z",
"generated_at": "2026-10-30T15:27:34Z",
"metrics": {
"_totals": {
"CONFIDENCE.HIGH": 0,
@@ -11,7 +11,7 @@
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UNDEFINED": 0,
"loc": 904,
"loc": 909,
"nosec": 0,
"skipped_tests": 0
},
@@ -24,7 +24,7 @@
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UNDEFINED": 0,
"loc": 321,
"loc": 324,
"nosec": 0,
"skipped_tests": 0
},
@@ -37,7 +37,7 @@
"SEVERITY.LOW": 0,
"SEVERITY.MEDIUM": 0,
"SEVERITY.UNDEFINED": 0,
"loc": 583,
"loc": 585,
"nosec": 0,
"skipped_tests": 0
}
@@ -46,8 +46,8 @@
"source_provenance": {
"scanner": "bandit",
"sha256": {
"skills/ecc-contribution-review/scripts/compile_contribution_review.py": "8c74b2f5aad224cdc7ba731dd7a60ba7ff9c92091f591f13b87177a62f2b763c",
"skills/ecc-contribution-review/scripts/contribution_review_validation.py": "a69156be6608c3f9a74d68e2fa0b815e77d44e68ffafd9a183fdefadbbfd5dd3"
"skills/ecc-contribution-review/scripts/compile_contribution_review.py": "51be6d82e222eb7dcf35f6c2db55dd06dd04a480d6c5734d2e671bac1bbb820c",
"skills/ecc-contribution-review/scripts/contribution_review_validation.py": "f56d3a9a01a3393a41b3a546cbfe6b64cb7a28745b5e78939832d8bb40c7b932"
},
"version": "1.9.4"
}
@@ -1,10 +1,12 @@
{
"skills/ecc-contribution-review/agents/openai.yaml": "43a1fec439fa8ef2b1bb57f938a61df11ef78ef3c2e901038b8836868cb8e3b1",
"skills/ecc-contribution-review/scripts/compile_contribution_review.py": "8c74b2f5aad224cdc7ba731dd7a60ba7ff9c92091f591f13b87177a62f2b763c",
"skills/ecc-contribution-review/scripts/contribution_review_validation.py": "a69156be6608c3f9a74d68e2fa0b815e77d44e68ffafd9a183fdefadbbfd5dd3",
"skills/ecc-contribution-review/scripts/compile_contribution_review.py": "51be6d82e222eb7dcf35f6c2db55dd06dd04a480d6c5734d2e671bac1bbb820c",
"skills/ecc-contribution-review/scripts/contribution_review_validation.py": "f56d3a9a01a3393a41b3a546cbfe6b64cb7a28745b5e78939832d8bb40c7b932",
"skills/ecc-contribution-review/tests/record_security_evidence.py": "527d5a4bb922fee759768e6f46f40404344075f314dfe045ed6e293aff0ff6c7",
"skills/ecc-contribution-review/tests/test_compile_contribution_review.py": "609e562330237f1cbd92ee500a4c2773b749c196085e6c8bef39dbc4d4c05cba",
"skills/ecc-contribution-review/tests/test_packet_review_fixes.py": "391f763657e48accfba29814100d284aee986200d9d10d6aa578d051fdb1d160",
"skills/ecc-contribution-review/tests/test_review_regressions.py": "956f8e7fb026a73a59226053bac167581bbf1644666824f81510396eb025f202",
"skills/ecc-contribution-review/tests/test_security_evidence.py": "e3d1d2f82612efa45343ab696aca84951b965ecbe6057051ea17633a7729ac76",
"skills/ecc-contribution-review/tests/test_security_regression.py": "db28d20929428567f2be0a1aa194797a8ff5c2731d26700c91bc62b0df7fe3fd"
"skills/ecc-contribution-review/tests/test_security_regression.py": "6ff109c9d052bd6d8bf9a2e2dcd37f238e0d53c833c57caf051f54c6eff4b4d8",
"skills/ecc-contribution-review/tests/test_validation_findings.py": "7f1b93cfcb73b688a4e4ed09e95801ed385c67978e3e423f4b7adc060b0086e5"
}
@@ -0,0 +1,33 @@
"""Regressions for receipt ownership and self-contained harness documentation."""
import copy
import sys
import unittest
from pathlib import Path
from unittest.mock import patch
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / 'scripts'))
import compile_contribution_review as compiler # noqa: E402
from test_compile_contribution_review import worked # noqa: E402
class PacketReviewFixTests(unittest.TestCase):
def test_compile_does_not_mutate_output_receipt(self):
receipt = compiler._output_receipt(False)
before = copy.deepcopy(receipt)
with patch.object(compiler, '_output_receipt', return_value=receipt):
packet = compiler.compile_contract(worked(), Path('observation.json'))
self.assertEqual(before, receipt)
self.assertIsNot(receipt, packet['returnReceipt'])
self.assertEqual(packet['semanticChecksum'], compiler.checksum(packet))
def test_harness_documentation_targets_exist_and_match_canonical(self):
repo = ROOT.parents[1]
for harness in ('.agents', '.cursor'):
mirror = repo / harness / 'skills/ecc-contribution-review'
for relative in ('docs/WORKFLOW.md', 'docs/DESIGN.md',
'references/contribution-review-contract.md'):
with self.subTest(harness=harness, target=relative):
target = mirror / relative
self.assertTrue(target.is_file(), str(target))
self.assertEqual((ROOT / relative).read_bytes(), target.read_bytes())
@@ -79,6 +79,8 @@ class SecurityRegressionTests(unittest.TestCase):
"tests/test_security_evidence.py",
"tests/record_security_evidence.py",
"tests/test_review_regressions.py",
"tests/test_packet_review_fixes.py",
"tests/test_validation_findings.py",
"agents/openai.yaml",
)
}
@@ -0,0 +1,77 @@
"""Immutable validation and independent authority-scan regressions."""
import copy
import json
import sys
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
from compile_contribution_review import compile_contract # noqa: E402
from contribution_review_validation import ( # noqa: E402
_validate_authority,
_validate_repo,
add_issue,
validate,
)
def observation():
return json.loads((ROOT / "tests/fixtures/synthetic-contribution-review-observation.json").read_text())
class ValidationFindingsTests(unittest.TestCase):
def test_add_issue_returns_new_list_without_mutating_caller(self):
original = [{"code": "prior", "plane": 1, "detail": "prior fault"}]
before = copy.deepcopy(original)
result = add_issue(original, "new", 2, "new fault")
self.assertEqual(before, original)
self.assertEqual(["prior", "new"], [item["code"] for item in result])
duplicate = add_issue(result, "new", 2, "duplicate")
self.assertEqual(result, duplicate)
self.assertIsNot(result, duplicate)
def test_section_validators_leave_caller_owned_lists_unchanged(self):
data = observation()
data["repoIdentity"]["branch"] = "main"
data["claimedAuthority"]["mayCommit"] = True
for validator in (_validate_repo, _validate_authority):
with self.subTest(validator=validator.__name__):
prior = [{"code": "prior", "plane": 1, "detail": "prior fault"}]
before = copy.deepcopy(prior)
result = validator(data, prior)
self.assertEqual(before, prior)
self.assertGreater(len(result), len(prior))
def test_malformed_gate_does_not_hide_authority_rejection(self):
data = observation()
data["validationMatrix"][0]["gateId"] = []
data["claimedAuthority"]["mayCommit"] = True
before = copy.deepcopy(data)
packet = compile_contract(data, Path("observation.json"))
self.assertEqual(before, data)
self.assertEqual("reject", packet["controllerDecision"]["decision"])
self.assertIn("unsafe_generated_authority", packet["controllerDecision"]["reasonCodes"])
self.assertIn("observation_shape_invalid", packet["controllerDecision"]["reasonCodes"])
def test_malformed_section_preserves_other_faults_and_authority(self):
data = observation()
data["repoIdentity"]["branch"] = "main"
data["validationMatrix"][0]["gateId"] = []
data["claimedAuthority"]["mayCommit"] = True
faults, contradictions = validate(data)
self.assertIn("repo_identity_failed", [item["code"] for item in faults])
self.assertIn("observation_shape_invalid", [item["code"] for item in faults])
self.assertIn("unsafe_generated_authority", [item["code"] for item in contradictions])
def test_invalid_top_level_section_does_not_hide_authority(self):
data = observation()
data["validationMatrix"] = None
data["claimedAuthority"]["mayCommit"] = True
_, contradictions = validate(data)
self.assertIn("unsafe_generated_authority", [item["code"] for item in contradictions])
if __name__ == "__main__":
unittest.main()