Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ All fixture files use **JSON** format (`.json`), with one intentional exception:

SDK conformance runners **must** load `.json` files with a JSON parser. The `.yaml` file is consumed directly by binding-loader tests, not by the generic conformance runner.

The `profile` field identifies the runtime profile exercised by a fixture.
`core` fixtures can run against a default in-memory SDK installation.
Configuration, Discovery, Events, and System Modules fixtures use their
declared extension. Adapter wire projections are verified in Surfaces.
Each JSON fixture declares its primary runtime `profile`. Use `core` for
in-memory SDK behavior and `config`, `discovery`, `system-modules`, `events`,
or `observability` for extension behavior. Some fixtures exercise cooperating
profiles during setup. Adapter wire projections are verified in Surfaces.

> **Note for tooling authors:** Some ecosystem skill docs describe conformance fixtures as YAML; this is incorrect. The canonical format for all conformance test cases is JSON. The README is the authoritative format reference.

Expand Down
23 changes: 18 additions & 5 deletions conformance/check_driver_coverage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Report which conformance fixtures are not driven by all three SDKs.
"""Check conformance fixture profiles and report gaps in SDK driver coverage.

A conformance fixture exists to prove three implementations agree. One that only
two SDKs load is not doing that job — it is proving two implementations agree,
Expand All @@ -13,7 +13,8 @@

python3 conformance/check_driver_coverage.py [--sdk-root DIR] [--strict]

Without --strict this reports and exits 0, so the existing backlog does not
Missing or unknown fixture profiles always fail. Without --strict, driver gaps
are reported without failing, so the existing backlog does not
block unrelated work. With --strict it exits 1 on any gap — the setting to
switch on once the backlog is closed, so new fixtures cannot land undriven.
`--baseline` accepts the current gap set and fails only on NEW gaps, which is the
Expand All @@ -36,6 +37,7 @@
REPO = Path(__file__).resolve().parent.parent
FIXTURES = REPO / "conformance" / "fixtures"
BASELINE = REPO / "conformance" / "driver_coverage_baseline.json"
PROFILES = {"core", "config", "discovery", "system-modules", "events", "observability"}

SDKS = {
"python": ("apcore-python", ("tests",), (".py",)),
Expand Down Expand Up @@ -158,6 +160,17 @@ def main() -> int:
ap.add_argument("--write-baseline", action="store_true")
args = ap.parse_args()

fixtures = sorted(FIXTURES.glob("*.json"))
invalid_profiles = []
for path in fixtures:
profile = json.loads(path.read_text(encoding="utf-8")).get("profile")
if not isinstance(profile, str) or profile not in PROFILES:
invalid_profiles.append(path.name)
if invalid_profiles:
for name in invalid_profiles:
print(f"{name}: invalid or missing runtime profile", file=sys.stderr)
return 1

present = [s for s, (repo, *_) in SDKS.items() if sdk_dir(args.sdk_root, repo).is_dir()]
if len(present) < 3:
print(f"Need all three SDK checkouts under {args.sdk_root} "
Expand All @@ -166,19 +179,19 @@ def main() -> int:

gaps: dict[str, list[str]] = {}
full = 0
for path in sorted(FIXTURES.glob("*.json")):
for path in fixtures:
stem = path.stem
missing = [s for s in SDKS if not drivers_for(args.sdk_root, s, stem)]
if missing:
gaps[stem] = missing
else:
full += 1

total = len(list(FIXTURES.glob("*.json")))
total = len(fixtures)
print(f"{total} fixtures — {full} driven by all three SDKs, {len(gaps)} with gaps")

vacuous: list[str] = []
for path in sorted(FIXTURES.glob("*.json")):
for path in fixtures:
for sdk, (repo, *_rest) in SDKS.items():
for rel in drivers_for(args.sdk_root, sdk, path.stem):
q, d = quarantine_ratio(sdk_dir(args.sdk_root, repo) / rel)
Expand Down
1 change: 1 addition & 0 deletions conformance/fixtures/acl_agent_scoping.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profile": "core",
"description": "AI-agent tool-governance ACL scenario (issue #72). One canonical default-deny ruleset (mirrors examples/acl/agent-tool-governance.yaml) scopes tool access by caller pattern + identity roles + call-chain depth. The shared `rules` / `default_effect` apply to every case; each case is a (caller_id, caller_identity, call_depth, target_id) -> expected access decision (true = allow, false = deny). Locks the agent-governance scenario as a cross-language contract: all SDKs and framework integrations MUST produce identical decisions. Exercises ACL first-match-wins (spec §6) with conditions {roles, max_call_depth} and the @external special caller. Privilege gradient: @external < reader < data_admin.",
"default_effect": "deny",
"rules": [
Expand Down
1 change: 1 addition & 0 deletions conformance/fixtures/acl_argument_scoped_approval.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profile": "core",
"description": "Argument-scoped approval — PROTOCOL_SPEC §6.1.1 / §6.1.6 / §6.1.7 / §6.1.8 / §6.8.1 / §6.9 (spec v1.28.0 apcore#108, extended v1.29.0 apcore#109). Authorization and approval requirement are two orthogonal results: `effect` carries the first, the orthogonal optional `approval` field the second, and the built-in structure-only `arguments` condition decides whether a rule matches THIS call.\n\n**Every case runs TWICE.** The `arguments` condition can only be answered when a governance projection is available, and §6.1.8 case 1 makes `check()` a public entry point that may be called without one — so the same rules and the same call have two well-defined answers, and both are contracts. Run 1 supplies a projection derived from `arguments` (key set, optionally types — never values, §6.1.8 rule 2) by whatever route the SDK uses; §6.1.8 rule 4 leaves that idiomatic. Run 2 supplies NO PROJECTION AT ALL. `arguments: null` means the case has no projection to supply in either run, so the two runs coincide and both columns hold the same values.\n\nDriver contract. Build an ACL from `rules` in order with the given `default_effect`. For each run call the STRUCTURED accessor with caller_id/target_id and assert `access`, the approval requirement and `matched_rule_index` (null when the decision came from `default_effect`); assert the LEGACY boolean; and assert the AuditEntry's `handler_error` is non-null exactly where the run's column says so — §6.3.1 makes it the if-and-only-if marker of an unevaluable condition, which is what keeps 'the handler said no' and 'no answer was obtainable' tellable apart after the fact. Keys ending `_no_projection` belong to run 2; the unsuffixed ones to run 1.\n\n**An SDK whose legacy boolean cannot receive a projection asserts run 2's `expected_legacy_check_no_projection` and skips only `expected_legacy_check`.** apcore-rust is that SDK: `ACL::check(caller_id, target_id, ctx)` has no parameter for one and passes `None` to `check_access` internally, which is conforming — §6.1.8 rule 4 fixes only that the condition sees the projection, and §6.1.8 case 1 contemplates `check()` being called without one. Both structured columns remain fully assertable there via `check_access(..., Some(&projection))` and `check_access(..., None)`. This split replaces a driver-side skip. The skip was honest and reconciled against the fixture, but it left 17 of 20 cases unverified on one SDK, and #109 — an unevaluable `allow` rule discarding the `approval: required` it carried, so a broader rule granted the call unapproved — was sitting in exactly those cases. A skip justified as 'this SDK is being asked a different question' still owes the other question an answer, because the difference may itself be the bug.\n\nWhere `expected_validation_finding_path` is non-null, assert `validate_rules()` reports a finding at that condition path — §6.1.8 descends to `arguments.<predicate>` where one predicate is at fault and stops at `arguments` where none can be named. Where `expected_validation_finding_paths` is non-null, assert the rule's findings are EXACTLY those paths in that order — §6.1.8 rule 3 requires every faulty predicate to be reported, not just the first. Validation is context-free, so it has one column, not two.\n\n`callers_raw` / `targets_raw` carry a deliberately malformed pattern field in place of the well-formed key, which a statically typed SDK cannot represent; those cases carry `skip_if_unrepresentable`. Both fields are covered because §6.1.1 rule 5's malformed-scope clause names both and they are separate code paths.\n\nThree cases use `default_effect: allow` against the house rule, and say so in their notes: a `deny` rule TAKING EFFECT under §6.1.1, and a pending approval requirement riding through the default under §6.1.1 rule 5, are not observable against a `deny` default, because not-granting produces the same answer.\n\nLesson recorded from the #107 fixture: it reached for `approval` as its example of a rule key 'from a proposal that has not landed', and v1.28.0 landed that proposal, so the case asserted the opposite of the spec. Do not draw negative examples from live proposals.",
"test_cases": [
{
Expand Down
1 change: 1 addition & 0 deletions conformance/fixtures/acl_audit_delivery.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profile": "core",
"description": "PROTOCOL_SPEC §6.3.2 (spec v1.45.0, apcore#118 decision D-66): ACL audit DELIVERY. §6.3.1 has always specified the record — thirteen fields, `handler_error` and `approval_required` with precise semantics — and nothing specified how it is delivered. `ACL(audit_logger=…)` was the entire surface: no default sink, no statement of what happens when delivery fails, and no meaning for the `audit:` block's `enabled` / `include_denied` / `log_level`, which were declared in TWO places and read in neither. The sharpest consequence was measured, not inferred: a failing audit callback propagated out of `check()` and turned an ALLOWED call into an error, in all three SDKs. Drivers MUST load a real ACL FILE and drive real `check()` calls: reading the parsed block back off a config object proves the parser works, which was never the question. `input.callback` selects what the driver installs programmatically — `none`, `collecting` (records every entry it receives), or `failing` (raises/throws/panics on every entry).",
"test_cases": [
{
Expand Down
1 change: 1 addition & 0 deletions conformance/fixtures/acl_effect_value_closure.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profile": "config",
"description": "An ACL rule's `effect` value is a CLOSED set, at every entry point (PROTOCOL_SPEC §6.1.5, spec v1.30.0, #111). `allow` and `deny` are the only legal values — §6.1's field table has always said **MUST** and `schemas/acl-config.schema.json` has always declared the enum — and a rule carrying anything else **MUST** be rejected with `ACLRuleError` naming the rule index and the offending value.\n\n**The entry point is the substance of this fixture, not a detail.** #107 closed the rule KEY set; this closes a legal key's VALUE, and it was found because the check already existed and was reachable from only one of three doors. Drivers **MUST** exercise each door in `entry_points` that the SDK exposes: `load` (an ACL file), `construct` (building the ACL/rule directly in code) and `add_rule` (runtime insertion). §6.1.6 rule 3 is the governing text — accepting a rule through one door while rejecting it at two is worse than either — and an SDK whose `add_rule` returns nothing by its own contract provides a fallible variant beside it or fails loudly in whatever way that language signals an unconstructable value.\n\n`expected_load: ok` means the rule is accepted at every listed door; `reject` means it is rejected at every listed door. There is deliberately no per-door expectation: a value legal through one entry point and illegal through another is the defect, so the fixture cannot have a shape that can express it.\n\n**An unrecognised `effect` MUST NOT be resolved to a decision.** Reading it as `deny` looks safe and is not: under `default_effect: allow` a rule written to permit becomes one that denies everything it matches, and on a `deny` rule the fallback is only accidentally right — correct until someone revisits which way it points. Where a case is rejected there is no access decision to assert, which is the point.\n\n`default_effect` is closed on the same terms. All three SDKs already validated it at every door before v1.30.0, which is what made a rule's `effect` guarding only the file path an internal inconsistency as well as a cross-language one; `default_effect` cases are pinned here so that behaviour stops being correct-by-convention.",
"test_cases": [
{
Expand Down
1 change: 1 addition & 0 deletions conformance/fixtures/acl_evaluation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profile": "core",
"description": "ACL rule evaluation (first-match-wins, spec §6)",
"test_cases": [
{
Expand Down
1 change: 1 addition & 0 deletions conformance/fixtures/acl_handler_error.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profile": "core",
"description": "ACL condition evaluation failure — cross-language SECURITY golden test (spec v1.22.0 / v1.25.0, #100). A condition that CANNOT BE EVALUATED is not the same as a condition that is FALSE, and the rule's `effect` decides what the difference means: an unevaluable condition MUST resolve the rule toward refusing access — a `deny` rule takes effect and the call is DENIED; an `allow` rule does not match and MUST NOT grant. \"Unevaluable\" is a PRINCIPLE, not a closed list (§6.1.1): no resolvable handler, a handler that raises/throws/panics, an async handler unresolvable on the sync path, a value malformed for its key, or a `conditions` that is not a mapping. §6.1.4's precheck is context-independent and runs BEFORE §6.5's no-context check, so a malformed rule is unevaluable even for a caller that supplied no context. Driver contract: register a handler under `throwing_condition_key` whose evaluate() raises/throws/panics; register NOTHING for `unknown_condition_key`. Build an ACL from `rules` with the given `default_effect`, wire an audit sink, call check(caller_id, target_id) — passing a context only when `with_context` is true — and when it is true, the context MUST carry exactly the identity given by that case's `context_identity` (id, type, roles). Several cases turn on whether a `roles` condition is SATISFIED, so a driver that supplies a bare identity-less context will get the wrong decision and the failure will look like over-gating when it is not. Assert the decision equals `expected`, that AuditEntry.handler_error is non-null when `expected_audit_handler_error_present` is true, and — where `expected_handler_error_paths` is present — that handler_error names exactly those condition paths, in that order (§6.1.1 rule 2 orders by path). Cases whose rule carries `callers_raw` / `targets_raw` supply that value in place of the normal list, to exercise §6.1.4.1: a driver in a language where the malformed value is not representable (apcore-rust's `Vec<String>`) MUST skip those cases and say so, rather than reporting them as passing.",
"throwing_condition_key": "__test_throwing_condition__",
"test_cases": [
Expand Down
Loading
Loading