Skip to content

Commit 342ad5f

Browse files
Qualification lifecycle: supersession, revocation, and remaining scope pins
A bound qualification set now carries record-lifecycle facts alongside envelope state, both derived from the bound documents and stamped on the assessment — never a mutable state on the immutable record. - `QualificationRecord.supersedes`: a newer record names the digests it replaces, authenticated by its own signature under issuer recognition. Among records matching a step a live one wins; a dead record attaches only as sole match, marked `superseded_by`. A record bound solely as a supersession witness need not cover an exercised pair — it still names a bound capability exactly. Campaign refusal: `CORE-A4101`. - `qualification_revocation` document role (new schema, `avila.core/qualification-revocation/v0.1-draft`) naming the withdrawn record's digest. Under issuer recognition it must verify under the declared issuer key — an unverifiable withdrawal is ignored, `CORE-X3405`. Otherwise package-asserted and unsigned: it can only deny evidence. Campaign refusal: `CORE-A4603`. - Both flags ride on claims (`superseded_by`, `revoked_by`) like `owner` — deterministic, bound-set derived. Refusal precedence: not_recognized > revoked > superseded > expired > outside/unknown; nominal basis exempt. Verifier re-derives both flags including the issuer-signature rule. - Pins: same-role inputs addressed by slot (`inputs_carrying_the_same_role_are_addressed_by_slot`), predicate node-limit fail-closed (`a_wide_predicate_fails_closed_on_the_node_limit`), and the envelope-level resource-limit unknown (`a_scope_term_over_the_resource_limit_is_unknown_not_affirmative`). - `scope.maturity-migration` marked not applicable — no v0.1 contract format ever shipped in-tree. Pins: two campaign fixtures, five runner adversarial tests, three kernel/compiler pins. fixtures-check: 94 covered / 125 named / 18 unbounded / 62 absent. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 65b2e2f commit 342ad5f

24 files changed

Lines changed: 1309 additions & 86 deletions

‎crates/avila-core-cli/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ mod tests {
14771477
assert_eq!(report.implemented_vector_sets.len(), 4);
14781478
assert_eq!(report.total_compiler_fixtures, 70);
14791479
assert_eq!(report.implemented_compiler_fixture_sets.len(), 5);
1480-
assert_eq!(report.total_campaign_fixtures, 20);
1480+
assert_eq!(report.total_campaign_fixtures, 22);
14811481
assert_eq!(report.total_supplemental_fixtures, 39);
14821482
assert_eq!(report.implemented_supplemental_fixture_sets.len(), 2);
14831483
assert_eq!(report.implemented_campaign_fixture_sets.len(), 1);

‎crates/avila-core-compiler/src/campaign/verdicts.rs‎

Lines changed: 106 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use super::document::{ClaimValue, ClaimsDocument};
1313
use super::{AdmissionRecord, AdmissionState, VerdictBoundary, VerdictRecord};
1414
use crate::compile::registry::RegistryIndex;
1515
use crate::compile::{CanonicalTypedQuantity, CompiledContract};
16-
use crate::diagnostic::{CORE_A4401, CORE_A4402, CORE_A4403, CORE_A4601, CORE_A4602};
16+
use crate::diagnostic::{
17+
CORE_A4101, CORE_A4401, CORE_A4402, CORE_A4403, CORE_A4601, CORE_A4602, CORE_A4603,
18+
};
1719
use crate::document::{BasisKind, CategoricalPredicate, Comparison, QuantityValue, SourceRef};
1820
use crate::qualification::{ClaimQualification, EnvelopeState};
1921

@@ -86,25 +88,25 @@ pub(super) fn evaluate(
8688
// (ADR-0008 clause 4).
8789
let applies_qualification = requirement.basis.kind != BasisKind::Nominal;
8890
let quarantined = quarantined_by_qualification(&requirement.metric, claims, admissions);
89-
let not_recognized = if applies_qualification {
90-
unrecognized_claims(
91+
let refusals = if applies_qualification {
92+
refused_claims(
9193
&requirement.metric,
9294
claims,
9395
admissions,
9496
&compiled.execution_policy.recognized_qualification_owners,
9597
)
9698
} else {
97-
Vec::new()
99+
LifecycleRefusals::default()
98100
};
99101
let unqualified = if applies_qualification {
100102
unqualified_claims(&requirement.metric, claims, admissions)
101103
} else {
102104
Vec::new()
103105
};
104106
let verdict = if applies_qualification
105-
&& (!quarantined.is_empty() || !not_recognized.is_empty())
107+
&& (!quarantined.is_empty() || !refusals.is_empty())
106108
{
107-
qualification_verdict(&quarantined, &not_recognized)
109+
qualification_verdict(&quarantined, &refusals)
108110
} else if applies_qualification
109111
&& compiled.execution_policy.require_qualification
110112
&& !unqualified.is_empty()
@@ -212,13 +214,13 @@ pub(super) fn evaluate(
212214
evidence,
213215
};
214216
let quarantined = quarantined_by_qualification(&requirement.metric, claims, admissions);
215-
let not_recognized = unrecognized_claims(
217+
let refusals = refused_claims(
216218
&requirement.metric,
217219
claims,
218220
admissions,
219221
&compiled.execution_policy.recognized_qualification_owners,
220222
);
221-
let verdict = if quarantined.is_empty() && not_recognized.is_empty() {
223+
let verdict = if quarantined.is_empty() && refusals.is_empty() {
222224
CategoricalVerdictEvaluator::evaluate(&case).unwrap_or_else(|error| VerdictOutput {
223225
status: VerdictStatus::NotEvaluated,
224226
rule: "not_evaluated.kernel_refusal".into(),
@@ -241,7 +243,7 @@ pub(super) fn evaluate(
241243
display_upper_text: None,
242244
})
243245
} else {
244-
let mut output = qualification_verdict(&quarantined, &not_recognized);
246+
let mut output = qualification_verdict(&quarantined, &refusals);
245247
output.accepted_categories = Some(case.requirement.accepted_values.clone());
246248
output
247249
};
@@ -281,35 +283,61 @@ fn quarantined_by_qualification(
281283
.collect()
282284
}
283285

284-
/// Admitted claims for the requirement's metric whose qualification record
285-
/// declares an owner the contract's recognition policy does not list. When
286-
/// `recognized_qualification_owners` is non-empty, an unlisted owner's
287-
/// assessment cannot establish the requirement whatever its envelope terms
288-
/// evaluated — including `inside`. Distinct from `unqualified_claims`: the
289-
/// assessment exists, its issuer is simply not one this organization accepts.
290-
fn unrecognized_claims(
286+
/// Claims refused on record-lifecycle grounds rather than envelope state:
287+
/// the assessment attaches and reports what the record said, but the record
288+
/// itself cannot stand. By refusal class — an unrecognized issuer cannot
289+
/// count at all; a withdrawn record is dead; a superseded record has been
290+
/// replaced. `superseded` and `revoked` ride on the claim as the bound
291+
/// set's lifecycle facts, so the check needs no package access.
292+
#[derive(Default)]
293+
struct LifecycleRefusals {
294+
not_recognized: Vec<(String, ClaimQualification)>,
295+
revoked: Vec<(String, ClaimQualification)>,
296+
superseded: Vec<(String, ClaimQualification)>,
297+
}
298+
299+
impl LifecycleRefusals {
300+
fn is_empty(&self) -> bool {
301+
self.not_recognized.is_empty() && self.revoked.is_empty() && self.superseded.is_empty()
302+
}
303+
}
304+
305+
/// Admitted claims for the requirement's metric refused on lifecycle
306+
/// grounds: an owner the contract's recognition policy does not list
307+
/// (`recognized_qualification_owners` non-empty), a record a bound
308+
/// revocation document withdrew, or a record a bound peer superseded.
309+
/// Distinct from `unqualified_claims`: the assessment exists, the record
310+
/// simply cannot stand.
311+
fn refused_claims(
291312
metric: &SourceRef,
292313
claims: &ClaimsDocument,
293314
admissions: &[AdmissionRecord],
294315
recognized_owners: &std::collections::BTreeMap<String, String>,
295-
) -> Vec<(String, ClaimQualification)> {
296-
if recognized_owners.is_empty() {
297-
return Vec::new();
298-
}
299-
admissions
316+
) -> LifecycleRefusals {
317+
let mut refusals = LifecycleRefusals::default();
318+
for record in admissions
300319
.iter()
301320
.filter(|record| &record.source == metric)
302321
.filter(|record| record.state == AdmissionState::Admitted)
303-
.filter_map(|record| {
304-
claims
305-
.claims
306-
.iter()
307-
.find(|claim| claim.claim_id == record.evidence_id)
308-
.and_then(|claim| claim.qualification.clone())
309-
.filter(|qualification| !recognized_owners.contains_key(&qualification.owner))
310-
.map(|qualification| (record.evidence_id.clone(), qualification))
311-
})
312-
.collect()
322+
{
323+
let Some(qualification) = claims
324+
.claims
325+
.iter()
326+
.find(|claim| claim.claim_id == record.evidence_id)
327+
.and_then(|claim| claim.qualification.clone())
328+
else {
329+
continue;
330+
};
331+
let entry = (record.evidence_id.clone(), qualification.clone());
332+
if !recognized_owners.is_empty() && !recognized_owners.contains_key(&qualification.owner) {
333+
refusals.not_recognized.push(entry);
334+
} else if qualification.revoked_by.is_some() {
335+
refusals.revoked.push(entry);
336+
} else if qualification.superseded_by.is_some() {
337+
refusals.superseded.push(entry);
338+
}
339+
}
340+
refusals
313341
}
314342

315343
/// Admitted claims for the requirement's metric that carry no qualification
@@ -378,7 +406,7 @@ fn unqualified_reasons(code: &str, owner: &str, evidence_ids: &[String]) -> Vec<
378406

379407
fn qualification_reasons(
380408
quarantined: &[(String, ClaimQualification)],
381-
not_recognized: &[(String, ClaimQualification)],
409+
refusals: &LifecycleRefusals,
382410
) -> Vec<VerdictReason> {
383411
let expired = quarantined
384412
.iter()
@@ -387,12 +415,24 @@ fn qualification_reasons(
387415
.iter()
388416
.any(|(_, qualification)| qualification.state != EnvelopeState::Expired);
389417
let mut reasons = Vec::new();
390-
if !not_recognized.is_empty() {
418+
if !refusals.not_recognized.is_empty() {
391419
reasons.push(VerdictReason::CodeOwner {
392420
code: CORE_A4601.into(),
393421
owner: "policy_owner".into(),
394422
});
395423
}
424+
if !refusals.revoked.is_empty() {
425+
reasons.push(VerdictReason::CodeOwner {
426+
code: CORE_A4603.into(),
427+
owner: "method_owner".into(),
428+
});
429+
}
430+
if !refusals.superseded.is_empty() {
431+
reasons.push(VerdictReason::CodeOwner {
432+
code: CORE_A4101.into(),
433+
owner: "method_owner".into(),
434+
});
435+
}
396436
if expired {
397437
reasons.push(VerdictReason::CodeOwner {
398438
code: CORE_A4602.into(),
@@ -405,7 +445,7 @@ fn qualification_reasons(
405445
owner: "method_owner".into(),
406446
});
407447
}
408-
for (evidence_id, qualification) in not_recognized {
448+
for (evidence_id, qualification) in &refusals.not_recognized {
409449
reasons.push(VerdictReason::EvidenceState {
410450
evidence_id: evidence_id.clone(),
411451
state: format!(
@@ -414,6 +454,28 @@ fn qualification_reasons(
414454
),
415455
});
416456
}
457+
for (evidence_id, qualification) in &refusals.revoked {
458+
reasons.push(VerdictReason::EvidenceState {
459+
evidence_id: evidence_id.clone(),
460+
state: format!(
461+
"qualification_revoked ({} rev {}): withdrawn by revocation {}",
462+
qualification.qualification_id,
463+
qualification.revision,
464+
qualification.revoked_by.as_deref().unwrap_or("?")
465+
),
466+
});
467+
}
468+
for (evidence_id, qualification) in &refusals.superseded {
469+
reasons.push(VerdictReason::EvidenceState {
470+
evidence_id: evidence_id.clone(),
471+
state: format!(
472+
"qualification_superseded ({} rev {}): replaced by record {}",
473+
qualification.qualification_id,
474+
qualification.revision,
475+
qualification.superseded_by.as_deref().unwrap_or("?")
476+
),
477+
});
478+
}
417479
for (evidence_id, qualification) in quarantined {
418480
let state = match qualification.state {
419481
EnvelopeState::Outside => "outside_qualification",
@@ -444,7 +506,7 @@ fn qualification_reasons(
444506

445507
fn qualification_verdict(
446508
quarantined: &[(String, ClaimQualification)],
447-
not_recognized: &[(String, ClaimQualification)],
509+
refusals: &LifecycleRefusals,
448510
) -> VerdictOutput {
449511
let expired = quarantined
450512
.iter()
@@ -454,10 +516,15 @@ fn qualification_verdict(
454516
.any(|(_, qualification)| qualification.state == EnvelopeState::Outside);
455517
VerdictOutput {
456518
status: VerdictStatus::NotEvaluated,
457-
// An unrecognized issuer's assessment cannot count at all — that
458-
// refusal outranks whatever the record's own envelope said.
459-
rule: if !not_recognized.is_empty() {
519+
// A record that cannot stand — unrecognized issuer, withdrawn, or
520+
// replaced — outranks whatever its own envelope said, and among the
521+
// lifecycle refusals the issuer check is the most fundamental.
522+
rule: if !refusals.not_recognized.is_empty() {
460523
"not_evaluated.qualification_not_recognized".into()
524+
} else if !refusals.revoked.is_empty() {
525+
"not_evaluated.qualification_revoked".into()
526+
} else if !refusals.superseded.is_empty() {
527+
"not_evaluated.qualification_superseded".into()
461528
} else if expired {
462529
"not_evaluated.qualification_expired".into()
463530
} else if outside {
@@ -477,7 +544,7 @@ fn qualification_verdict(
477544
numbers_present: Some(false),
478545
observed_category: None,
479546
accepted_categories: None,
480-
reasons: qualification_reasons(quarantined, not_recognized),
547+
reasons: qualification_reasons(quarantined, refusals),
481548
display_upper_text: None,
482549
}
483550
}

‎crates/avila-core-compiler/src/catalog.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ pub struct DiagnosticExplanation {
2020

2121
/// Every explained code, sorted by code.
2222
pub const DIAGNOSTIC_CATALOG: &[DiagnosticExplanation] = &[
23+
DiagnosticExplanation {
24+
code: "CORE-A4101",
25+
title: "Qualification record superseded",
26+
rule: "SC-7; SC-15",
27+
meaning: "A bounded or enclosure requirement depends on a claim whose producing capability carries a qualification record that a bound newer record declares superseded — the newer record names this record's digest in its `supersedes` list. Whatever the superseded record's envelope terms evaluated, it no longer stands: a superseded record cannot satisfy a role, so the claim cannot establish the requirement.",
28+
next_action: "Rerun the step under the superseding record, or supply evidence from a capability qualified by a current record. The owner is the method owner.",
29+
},
2330
DiagnosticExplanation {
2431
code: "CORE-A4201",
2532
title: "Nominal basis not permitted",
@@ -76,6 +83,13 @@ pub const DIAGNOSTIC_CATALOG: &[DiagnosticExplanation] = &[
7683
meaning: "A bounded or enclosure requirement depends on a claim whose producing capability carries a qualification record, but the record's `not_after` lapsed before the claim's evaluation instant — the producing receipt's `started_at`. The envelope no longer stands, whatever its terms would have said — the claim cannot establish the requirement. The calculation may be fine; the credential naming where it may be trusted has lapsed.",
7784
next_action: "Renew the qualification record (a new revision with a later `not_after`) and rerun the step, or supply evidence from a capability whose qualification is current. The owner is the method owner.",
7885
},
86+
DiagnosticExplanation {
87+
code: "CORE-A4603",
88+
title: "Qualification record revoked",
89+
rule: "SC-7; SC-15",
90+
meaning: "A bounded or enclosure requirement depends on a claim whose producing capability carries a qualification record that a bound `qualification_revocation` document withdraws — the package binds a withdrawal naming this record's digest. Whatever the record's envelope terms evaluated, it no longer stands: a revoked record cannot satisfy a role, so the claim cannot establish the requirement. Under issuer recognition only a revocation signed under the declared issuer key can withdraw a record.",
91+
next_action: "Supply evidence from a capability qualified by a record that has not been withdrawn, or bind a current qualification and rerun the step. The owner is the method owner.",
92+
},
7993
DiagnosticExplanation {
8094
code: "CORE-E7001",
8195
title: "Claims bind a different snapshot",

‎crates/avila-core-compiler/src/diagnostic.rs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub const CORE_S1101: &str = "CORE-S1101";
55
pub const CORE_S1102: &str = "CORE-S1102";
66
pub const CORE_S1103: &str = "CORE-S1103";
77
pub const CORE_S1301: &str = "CORE-S1301";
8+
pub const CORE_A4101: &str = "CORE-A4101";
89
pub const CORE_A4201: &str = "CORE-A4201";
910
pub const CORE_A4301: &str = "CORE-A4301";
1011
pub const CORE_A4401: &str = "CORE-A4401";
@@ -13,6 +14,7 @@ pub const CORE_A4403: &str = "CORE-A4403";
1314
pub const CORE_A4404: &str = "CORE-A4404";
1415
pub const CORE_A4601: &str = "CORE-A4601";
1516
pub const CORE_A4602: &str = "CORE-A4602";
17+
pub const CORE_A4603: &str = "CORE-A4603";
1618
pub const CORE_E7001: &str = "CORE-E7001";
1719
pub const CORE_E7002: &str = "CORE-E7002";
1820
pub const CORE_E7101: &str = "CORE-E7101";
@@ -45,11 +47,12 @@ pub const CORE_T2601: &str = "CORE-T2601";
4547
/// Every code a compile report can carry, including `CORE-S1103`, which the
4648
/// authoritative reader raises for a duplicate object key.
4749
pub const COMPILER_FINDING_CODES: &[&str] = &[
48-
CORE_A4201, CORE_A4301, CORE_A4401, CORE_A4402, CORE_A4403, CORE_A4404, CORE_A4601, CORE_A4602,
49-
CORE_E7001, CORE_E7002, CORE_E7101, CORE_E7103, CORE_E7201, CORE_E7301, CORE_R3101, CORE_R3102,
50-
CORE_R3201, CORE_R3202, CORE_R3203, CORE_R3301, CORE_R3401, CORE_R3501, CORE_R3601, CORE_R3602,
51-
CORE_S1101, CORE_S1102, CORE_S1103, CORE_S1301, CORE_T2001, CORE_T2101, CORE_T2102, CORE_T2103,
52-
CORE_T2104, CORE_T2201, CORE_T2203, CORE_T2301, CORE_T2401, CORE_T2402, CORE_T2501, CORE_T2601,
50+
CORE_A4101, CORE_A4201, CORE_A4301, CORE_A4401, CORE_A4402, CORE_A4403, CORE_A4404, CORE_A4601,
51+
CORE_A4602, CORE_A4603, CORE_E7001, CORE_E7002, CORE_E7101, CORE_E7103, CORE_E7201, CORE_E7301,
52+
CORE_R3101, CORE_R3102, CORE_R3201, CORE_R3202, CORE_R3203, CORE_R3301, CORE_R3401, CORE_R3501,
53+
CORE_R3601, CORE_R3602, CORE_S1101, CORE_S1102, CORE_S1103, CORE_S1301, CORE_T2001, CORE_T2101,
54+
CORE_T2102, CORE_T2103, CORE_T2104, CORE_T2201, CORE_T2203, CORE_T2301, CORE_T2401, CORE_T2402,
55+
CORE_T2501, CORE_T2601,
5356
];
5457

5558
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]

‎crates/avila-core-compiler/src/lib.rs‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ pub use coverage::{
3636
parse_requirement_set,
3737
};
3838
pub use diagnostic::{
39-
COMPILER_FINDING_CODES, CORE_A4201, CORE_A4301, CORE_A4601, CORE_A4602, CORE_E7001, CORE_E7002,
40-
CORE_E7101, CORE_E7103, CORE_E7201, CORE_E7301, CORE_R3101, CORE_R3102, CORE_R3201, CORE_R3202,
41-
CORE_R3203, CORE_R3301, CORE_R3401, CORE_R3501, CORE_R3601, CORE_R3602, CORE_S1101, CORE_S1102,
42-
CORE_S1103, CORE_S1301, CORE_T2001, CORE_T2101, CORE_T2102, CORE_T2103, CORE_T2104, CORE_T2201,
43-
CORE_T2203, CORE_T2301, CORE_T2401, CORE_T2402, CORE_T2501, CORE_T2601, CoreDiagnostic,
44-
DiagnosticRepair, FindingClass, RepairApplicability, RepairEdit, SourceLocation,
39+
COMPILER_FINDING_CODES, CORE_A4101, CORE_A4201, CORE_A4301, CORE_A4601, CORE_A4602, CORE_A4603,
40+
CORE_E7001, CORE_E7002, CORE_E7101, CORE_E7103, CORE_E7201, CORE_E7301, CORE_R3101, CORE_R3102,
41+
CORE_R3201, CORE_R3202, CORE_R3203, CORE_R3301, CORE_R3401, CORE_R3501, CORE_R3601, CORE_R3602,
42+
CORE_S1101, CORE_S1102, CORE_S1103, CORE_S1301, CORE_T2001, CORE_T2101, CORE_T2102, CORE_T2103,
43+
CORE_T2104, CORE_T2201, CORE_T2203, CORE_T2301, CORE_T2401, CORE_T2402, CORE_T2501, CORE_T2601,
44+
CoreDiagnostic, DiagnosticRepair, FindingClass, RepairApplicability, RepairEdit,
45+
SourceLocation,
4546
};
4647
pub use document::{
4748
AuthoredBinding, BasisKind, BoundSide, COMPILE_REPORT_SCHEMA_VERSION,
@@ -58,8 +59,9 @@ pub use document::{
5859
};
5960
pub use qualification::{
6061
ClaimQualification, EnvelopeAssessment, EnvelopeState, EnvelopeTerm,
61-
QUALIFICATION_SCHEMA_VERSION, QualificationRecord, QualifiedCapability, ValidationEvidence,
62-
evaluate_envelope, parse_qualification, registry_kinds,
62+
QUALIFICATION_SCHEMA_VERSION, QualificationRecord, QualificationRevocation,
63+
QualifiedCapability, REVOCATION_SCHEMA_VERSION, ValidationEvidence, evaluate_envelope,
64+
parse_qualification, parse_revocation, registry_kinds,
6365
};
6466
pub use render::{
6567
SourceSpan, locate, render_campaign_report, render_compile_report, render_findings,

0 commit comments

Comments
 (0)