diff --git a/AGENTS.md b/AGENTS.md index be291b0..ba2abe4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -24,7 +24,8 @@ the engine live in the [engine repository](https://github.com/andreibesleaga/age Run from the repository root, with the engine checked out beside it at `../agentic-system-core` and Node 22.13 or later (without them the equivalence tests are -skipped): +skipped). To compare with another engine checkout, set `AGSC_ENGINE_DIR` to its path +([docs/MAINTAINING.md](docs/MAINTAINING.md), "The equivalence proof"): ```bash python -m venv .venv && .venv/bin/pip install -e ".[test]" @@ -38,8 +39,9 @@ Tests are deterministic: fixed data, no clock, no network. Write the failing tes ## What you may change, and what you may not - **Do not edit** the vector copies under `tests/fixtures/vectors/`; copy them again from - the engine. Do not type `src/agentic_system_core/data/spec-index.json`; derive it with - the command in [docs/MAINTAINING.md](docs/MAINTAINING.md). + the engine. Do not type `src/agentic_system_core/data/spec-index.json` or + `src/agentic_system_core/data/context.jsonld`; derive them with the commands in + [docs/MAINTAINING.md](docs/MAINTAINING.md). - **A rule, a vector or the engine is wrong:** propose the change in the engine repository; this package follows in its next release. - **Do not add a runtime dependency.** `pyproject.toml` has `dependencies = []` and the diff --git a/CHANGELOG.md b/CHANGELOG.md index c54f38d..6db9312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,64 @@ differently (SemVer's `1.1.0-rc.1` is `1.1.0rc1` here). ## [Unreleased] +## [1.1.0] - 2026-11-13 + +The package of specification `1.1.0`: the specification version and the package version move together (README, "Version"). + +- Changed: the package version and `SPEC_VERSION` are `1.1.0`; `agsc --version` prints `agsc 1.1.0 (Python package; specification 1.1.0)` (AGSC-00-14, AGSC-09-11). The vector copies carry the specification version the release edits in place (AGSC-00-16): `options.spec_version` of every case, and the implementation's version in the expected output of `cli-0002` and `build-0025`. `data/spec-index.json` is regenerated from the specification of 1.1.0 and names it. +- Changed: `links.link_warnings` reports AGSC-E315 for a `related` that joins a cluster, at either end, at parity with the engine (AGSC-03-25 and AGSC-05-20; the copy of `links-0020`); `data/relations.json` carries the cell of `related`, and the AGSC-10-15 table names `lint-0065`. +- Docs: the README links the "Ideas after 1.1" of the engine's roadmap; the readings and the ten questions above trace to the engine's 1.1 EARS row PRD-074, written since. +- Changed: the 1.1 errata of 2026-11-10, at parity with the engine. The Dataset block of the home page is the node `@id` = the Bundle IRI and names one creator `Person` by `@id`, and `catalog_block` writes the opt-in DCAT 3 catalogue block of `discovery.dcat` (AGSC-06-41; `disc-0037`, the successor of the withdrawn `disc-0027`). The agent card carries a responder's `securitySchemes` and `securityRequirements`, a `credential` responder without them is the warning AGSC-E210, and `served_declarations` leaves out an `a2a-card` that gets no card (AGSC-06-34, AGSC-11-16; `disc-0035`, `disc-0038`). The checker refuses a `webmcp` surface version that is not a `YYYY-MM-DD` date with AGSC-E210 (AGSC-11-16; `disc-0036`). `HIGHER_LEVEL_CASES` gains `disc-0035` to `disc-0038` and `lint-0063` (AGSC-10-15 as amended). The vector copies are refreshed. README: the second known difference, the card's security members. - Docs: README, `docs/MAINTAINING.md` corrected and extended (tests, CI jobs, release steps); `AGENTS.md` and `docs/ARCHITECTURE.md` added. +- Added: `graph.to_jsonld` and `graph.restrict_to` write `graph.jsonld` and the per-item `/pages/.jsonld` files (AGSC-05-09, AGSC-06-02) from the same triples as `graph.nq`, as the engine's `src/knowledge/jsonld.js` does; `run-vectors` now runs `graph-0028`. +- Added: `data/context.jsonld`, the published context (AGSC-06-32) as the engine's `tools/gen-ns` derives it, read by `context.published()`; the suite fails when it drifts from the engine's. +- Added: `areas/build_tree.py` checks the files a whole build wrote against `build-0020` to `build-0028` (AGSC-00-05, AGSC-01-19, AGSC-01-20, AGSC-05-07, AGSC-06-01, AGSC-06-18, AGSC-07-19, AGSC-07-20), member for member as the engine's handler does; the suite runs it over the engine's build of each case. `run-vectors` still reports them as not run (README, "What runs here"). +- Changed: the source distribution ships `SECURITY.md` and `data/context.jsonld`. +- Tests: the environment variable `AGSC_ENGINE_DIR` names the engine checkout the suite compares with; unset, it is `../agentic-system-core` as before. +- Tests: two fitness functions: the package imports only the standard library, and only `cli.py` starts a process. +- Changed: the vector copies under `tests/fixtures/vectors/` are the 1.1 engine's seven areas (156 files; `disc-0013`, `disc-0014`, `disc-0019` and `build-0024` are withdrawn there), and the drift test also fails when a file is missing or extra (AGSC-09-04; EARS row PRD-010). +- Changed: `data/spec-index.json` is regenerated from the 1.1 specification: 385 rules and 105 registered codes, among them AGSC-E005, AGSC-E313 to E317, AGSC-E417 to E423 and AGSC-E512 (AGSC-09-15; PRD-010); the declared version stays the one constant `SPEC_VERSION`. +- Changed: `HIGHER_LEVEL_CASES` is the AGSC-10-15 table as amended for 1.1.0 (72 cases; PRD-010). +- Added: `relations.py` and `data/relations.json`, the relation table of AGSC-03-01 as the engine's `src/knowledge/relations.js` holds it; `links.py` and `graph.py` read their key lists, inverses and RDF properties from it instead of their own copies (AGSC-03-01, AGSC-05-16; PRD-002). +- Added: `links.link_warnings`, the warnings AGSC-E313 (a self-link, AGSC-03-23), AGSC-E314 (two relations a pair cannot both hold, AGSC-03-24), AGSC-E315 (a target of an unexpected kind, AGSC-03-25) and AGSC-E316 (superseding a stable item, AGSC-03-26); `run-vectors` passes `links-0010` to `links-0017` (PRD-003). +- Added: `derive.readings`, the readings of the Link graph with their reasons (AGSC-05-33, `graph-0029`), as the engine's `src/knowledge/derive.js` gives them (PRD-023; the 1.1 EARS row comes with the engine's B12 requirements pass). +- Added: `questions.answer`, the ten questions of AGSC-05-34 (`graph-0030` to `graph-0039`), as the engine's `src/knowledge/questions.js` answers them (PRD-023; 1.1 EARS row as above). +- Added: `skos.skos_view` and `skos.scheme_record`, the SKOS view `export --skos` writes, byte for byte (AGSC-05-36, `graph-0040`; PRD-060); `rdf.turtle` takes the prefix block it writes. +- Added: a frontmatter nested deeper than 64 levels is the warning AGSC-E105 and is still read (AGSC-02-02 as amended for 1.1, `fm-0021`, `fm-0026`; PRD-003); `yamlsubset.depth` counts block nesting. +- Changed: `/llms.txt` and `/llms-full.txt` follow the 1.1 layout: the blockquote straight after the H1, then the provenance comment, the backslash, `[`, `]` and `(` of a link line escaped, and no `bundle_version` line on a restricted node (AGSC-06-13a as amended for 1.1, AGSC-11-20; `disc-0024`, `disc-0025`, `disc-0034`; PRD-060). +- Added: `site.security_txt(..., policy=)` writes the declared disclosure page as `Policy` (AGSC-06-36 as amended for 1.1, `build-0035`; PRD-047), and `site.now_line(..., visibility=)` gives a restricted node's line without the content version and the fingerprint (AGSC-06-22 with AGSC-11-20, `build-0036`; PRD-010). +- Changed: `run-vectors` reports as not run, each with its reason, the cases it cannot run: `build-0031` and `build-0032` (it writes no HTML), `build-0037` (it has no chunk writer), and the domain-layer cases `fm-0022` to `fm-0025`, `fm-0027`, `graph-0042`, `graph-0044` to `graph-0046`, `links-0018`, `links-0019` ("domain layer: engine only in 1.1") (AGSC-09-02; PRD-010). +- Changed: `bundle-0018` and `bundle-0019` (the `.diagram` grammar, AGSC-01-42) are reported not run with the reason "needs the diagram compiler (Level 3)"; the `bundle` area keeps its own reason (PRD-010). +- Tests: `test_link_parity.py` compares the Link warnings, the readings and the ten answers with the engine's on 120 seeded generated graphs; a fitness function keeps one source for the relation table. +- Added: `validate-wellknown` requires, at Level 2 and above, the `digest`, `agsc-chunk-count` and `agsc-chunk-set` of the chunks surface link of a document of 1.1.0 or later (AGSC-E202) and recomputes the count and the set commitment over the chunk lines read, a sharded file's shards included (AGSC-E201), as the engine's `requireChunkFacts` and `recomputeChunkFacts` do (AGSC-06-44, AGSC-09-93 (b); `disc-0033`; PRD-061, PRD-024). +- Added: `validate-wellknown` compares an `agsc-ledger-length` with the entries of the ledger read, from a file at every Level and from a URL at Level 2 and above (AGSC-E201; AGSC-06-44, AGSC-09-93 (c); the engine's `checkLedgerLength`; PRD-024). +- Added: `validate-wellknown` resolves an `a2a-card` declared on the node's own origin and warns AGSC-E210 when the node serves no card there; a card on another origin is not read (AGSC-11-16, AGSC-11-17, decision D-15; the engine's `checkCardTarget`; PRD-024). +- Added: given a URL, `validate-wellknown` reads the `Link` header of the node's home page and warns AGSC-E202 when it carries no `describedby` link to the discovery document (AGSC-06-25, AGSC-06-40, I-104; the engine's `homeLinkFindings`; `disc-0026` validator cases; PRD-020). +- Added: `validate-wellknown --max-requests <1..2000>` (default 500): every request of a run, its peer and its redirects included, counts against one budget, and the request past it is AGSC-E906 (AGSC-11-06, AGSC-11-10(c), I-083; the engine's `--max-requests`; PRD-024). An injected fetcher keeps its call `fetcher(url, dev, cap=n)`; the budget is spent once per call. +- Changed: the `chunks` surface of a restricted node (`agsc-access` `credential`) is not read by `validate-wellknown`, as it is not served unauthenticated (AGSC-11-20); an E906 while reading a surface target stays AGSC-E906 (the engine's `checkSurface`; PRD-024). +- Changed: `validate-wellknown` accepts `immutable` on a versioned copy under `/ns//` (AGSC-06-06, AGSC-11-05; `build-0034`; PRD-020), and knows the 1.1 attributes `agsc-chunk-count`, `agsc-chunk-set` and `agsc-ledger-length` (AGSC-06-44), so a newer document gets no AGSC-E506 for them. +- Changed: a response header sent on several lines is read as one value joined with ", ", as Node gives it to the engine's checker, so a split `Link` field is read whole (RFC 9110 section 5.3; PRD-024). +- Added: `signposting.home_links`, `signposting.license_url` and `signposting.dataset_block`: the FAIR Signposting links of `/` (AGSC-06-40, `disc-0026`), the licence URL (AGSC-06-44) and the home page's Dataset block with licence, creator, free access, downloads and the two PROV-O terms (AGSC-06-19, AGSC-06-41, `disc-0027`), as the engine's `headers.homeLinks` and `front-page.datasetBlock` give them (PRD-020). +- Added: `catalogue.catalogue_files`, the opt-in `/.well-known/ard.json` and `/.well-known/ai-catalog.json` with the SHA-256 of the exact bytes of each entry's target, `urn:air` identifiers and the domain-name rule (AGSC-E209, AGSC-E202 without `bundle.id`) (AGSC-06-42; `disc-0028`, `disc-0029`; the engine's `ai-catalog.js`; PRD-024). +- Added: `agentcard.card_bytes` and `agentcard.card_findings`, the A2A 1.0 agent card of a node that declares `a2a-card` and a responder, with the A2A-only rule: no card, and the warning AGSC-E210, when a responder is not `a2a:` or the `a2a-card` version is not a bare A2A version; a card without a responder is the error AGSC-E210 (AGSC-06-07, AGSC-06-34, AGSC-11-21; `disc-0030`, `disc-0031`; the engine's `a2a-card.ts`; PRD-024). +- Changed: `run-vectors` reads a case's reader version as the case states it, so `disc-0023` (a 1.1 reader and a `1.99.0` document) runs; `SPEC_VERSION` stays the one default (AGSC-00-21, AGSC-09-93; PRD-010). +- Added: `context.CONTEXT_VERSION`, the constant `1.0.0` of the persistent context address, which no longer follows the ontology version (AGSC-05-09 as amended for 1.1; `graph-0043` runs; the engine's `jsonld.js` `CONTEXT_VERSION`; PRD-060). The 1.0 name `context.ONTOLOGY_VERSION` stays, with the same value, and is deprecated. +- Changed: `run-vectors` reports four more cases as not run, each with its reason: `build-0029` and `build-0030` ("needs the engine's build and the query page (Level 3)", AGSC-06-39), `disc-0032` (it reads every file of a whole build, the HTML home page among them, AGSC-06-41) and `graph-0041` (`export --closure` with the OWL 2 RL rules of AGSC-05-37) (AGSC-09-02; PRD-010). The README lists every case not run and the counts. +- Tests: `test_equivalence.py` also compares the two checkers on the minimal fixture and on `agsc-demo-node` as the engine builds them, and on twelve new fixture cases of the 1.1 checks (chunk facts, ledger length, agent card); `test_wellknown_facts.py` and `test_web_connection.py` state the new checks; a fitness function keeps every connection in `net.py`. +- Changed: every area handler is guarded as the engine's are: a pass that left a member of a case's `expected` unread is a fail, and a case that states no member cannot pass (`areas/_expected_reads.py`, the engine's `tests/conformance/areas/_expected-reads.js`; AGSC-09-02, AGSC-09-06; PRD-010). The `jcs` and `slug` handlers are now held to it too. +- Fixed: `slug-0006` reads `engine_features_used`: the non-portable regular-expression features the slug pattern uses, named as the engine's `slug.js` names them (AGSC-01-10; PRD-010). A changed list used to pass here. +- Fixed: each entry of `graph-0018`'s `forbidden` is checked by its own reading, as the engine's `forbiddenCheck` does (no datatype on a language-tagged literal, no `^^xsd:string` in Turtle, no `asc:status` triple when no status is authored, predicates not in prefixed-name order), and an entry no reading knows fails (AGSC-05-10; PRD-010). Three of the four entries used to pass whatever the output was. +- Changed: `disc-0020` and `disc-0021` are reported not run with their reason: the engine builds the whole link table of AGSC-06-08 with its writer and compares the bytes, and this package's link-set writer covers part of that table (AGSC-09-02; PRD-010). They used to pass on a check of the stated document alone. +- Fixed: a target path that names a directory no longer stops `validate-wellknown` with a traceback: it is a target not found on disk (AGSC-E901), so an `a2a-card` there is a card not served, the warning AGSC-E210, as in the engine's `checkCardTarget` (AGSC-11-16; PRD-024). +- Fixed: a response field that Node's reader keeps only once (`Content-Type`, `ETag`, `Location` and fifteen more, `net.FIRST_LINE_ONLY`) is read from its first line when it is sent twice, as the engine's checker reads it; other repeated fields are still joined with ", " (PRD-024). +- Not added: `site.header_set` has no `/query/*` block, because no case this package runs reads it (the query page of `build-0029` and `build-0030` is not run here). +- Fixed: `validate-vectors` checks the `superseded_by` link: only a withdrawn vector may carry it (AGSC-E201), it is a vector id (AGSC-E204) and it names a vector of the same set (AGSC-E201) (AGSC-09-04; the engine's `tools/validate-vectors`; PRD-010). It used to be ignored. +- Fixed: `validate-vectors` refuses a folder where not one JSON file sits at `/-[-words].json` with one AGSC-E901 and judges none of its files, as the engine's `isVectorPath` rule does (AGSC-09-04, AGSC-09-90; PRD-010). One area folder used to pass, and a site's `skills/index.json` was judged as a vector. +- Changed: `validate-vectors` reports a missing folder as an AGSC-E901 finding with exit 1, as the engine does (AGSC-09-90; PRD-010); it used to be a usage fault, exit 2. +- Docs: the README names the one known difference from the engine's checker: a digest target or ledger that is a directory is `EISDIR` there and AGSC-E901 here; `test_equivalence.py` pins it (PRD-024). +- Tests: `test_actor_pattern.py` reads the engine from `AGSC_ENGINE_DIR` like every other engine test, and a fitness function fails on a test that spells out the engine path; `test_vectors.py` compares both validators on the vector copies, two `superseded_by` changes, one area folder, a skills index and a missing folder (PRD-010). +- Fixed: a link-shaped key (`peer-ref`, `mentions` or a foreign relation name) is the warning AGSC-E304, as the engine reports it, not AGSC-E207: one key, one code (AGSC-03-03; `links.LINK_SHAPED_UNKNOWN`, compared with the engine's `relations.js`; PRD-010). +- Fixed: `validate-wellknown` refuses a `webmcp` `agsc-surface-version` that has the form `YYYY-MM-DD` and names no day, such as `2026-13-45` (AGSC-E210, AGSC-11-16), as the engine's checker does (PRD-024). ## [1.0.1] - 2026-10-21 diff --git a/MANIFEST.in b/MANIFEST.in index 55d4fef..1bb9dc8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,9 @@ include README.md include CHANGELOG.md include LICENSE +include SECURITY.md recursive-include src/agentic_system_core/data *.json +recursive-include src/agentic_system_core/data *.jsonld recursive-include tests *.py recursive-include tests/fixtures * global-exclude __pycache__/* diff --git a/README.md b/README.md index dc60fd7..f4f5b1f 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,13 @@ always reaches this one. ## What runs here +The checkers and the vector runner below run here. One part of the specification does +not: the domain layer (site vocabulary, domain keys, warrants, contexts, crosswalks and +SHACL shapes). In 1.1 only the engine checks it; its cases are reported not run with +that reason, and Python parity for it is one of the +["Ideas after 1.1"](https://github.com/andreibesleaga/agentic-system-core/blob/main/docs/ROADMAP.md#ideas-after-11) +of the engine's roadmap. + ### `agsc validate-wellknown ` Checks one discovery document — the file a node serves at @@ -69,6 +76,16 @@ agsc validate-wellknown www/.well-known/knowledge-linkset \ --peer ../other/www/.well-known/knowledge-linkset ``` +No node to check yet? The engine builds one. With the npm package installed, in a git +repository of Markdown items with at least one commit (the ledger a Level-2 node links +is derived from that history; without it Level 2 reports AGSC-E202 for the missing +ledger link, in both checkers): + +``` +agsc build --level 2 +agsc validate-wellknown www/.well-known/knowledge-linkset --level 2 +``` + Levels 0 to 3 mean what the specification says they mean. At Level 0 and 1 the shape, the names, the ordering and the digest form are checked. At Level 2 and above the document must also be canonical bytes, every artefact link must carry @@ -81,6 +98,14 @@ same MAJOR may use relations and attributes this version does not define: they a ignored with the warning `AGSC-E506`, never reported as errors; a document of another MAJOR gets no such tolerance (AGSC-00-21, AGSC-09-93). +From 1.1, at Level 2 and above, the chunks surface link of a document that declares +1.1.0 or later must carry `digest`, `agsc-chunk-count` and `agsc-chunk-set` +(`AGSC-E202` for each one missing), and the count and the set commitment are +recomputed over the chunk lines read, a sharded file's shards included (`AGSC-E201` +when they differ); an `agsc-ledger-length` is compared with the entries of the ledger +read (AGSC-06-44, AGSC-09-93). At every Level, an `a2a-card` declared on the node's own +origin must be a card the node serves, else the warning `AGSC-E210` (AGSC-11-16). + When the document is a file inside a `.well-known/` directory, every same-origin target is resolved on disk and its digest is verified against the real bytes — so a build output is checked completely with no network at all. @@ -101,11 +126,18 @@ the last byte, and a cap of one mebibyte on the discovery document and of headers of the document and of every same-origin public file it fetches and checks the rules on cross-origin reading and caching (AGSC-11-03, AGSC-11-05): a missing header is `AGSC-E202`, a forbidden one `AGSC-E201`, errors at Level 2 -and above and warnings below (AGSC-09-93). +and above and warnings below (AGSC-09-93); only a versioned copy under +`/ns//` may be `immutable` (AGSC-06-06). It reads the `Link` header of the +node's home page `/` too, which should carry the `describedby` link to the discovery +document: its absence is the warning `AGSC-E202` (AGSC-06-25, AGSC-06-40). Every +request of a run, redirects included, counts against one budget, 500 by default and +`--max-requests <1..2000>` to set it; the request past it is `AGSC-E906` +(AGSC-11-10(c)). From Python, `agentic_system_core.wellknown.validate(target, level=2, allow_network=True, fetcher=my_fetch)` reads a URL through a fetcher you supply -instead of the built-in one. It is called as `my_fetch(url, dev, cap=n)`, where +instead of the built-in one (`max_requests=n` sets the budget, which each call +spends once). It is called as `my_fetch(url, dev, cap=n)`, where `cap` is the byte cap of that read — `1048576` for the discovery document, `33554432` for any other file — and it returns `(final_url, headers, body)`: the URL after redirects, the response headers as a dict with lower-case names, @@ -123,6 +155,12 @@ grammars, the file encoding, the canonical member order, and the resolution of every rule identifier and every error code against the specification. An empty set is a failure, not a clean run. +It also checks the `superseded_by` link: only a withdrawn vector carries it, and it +names a vector of the same set. A folder where not one JSON file sits at a vector's +path, `/-[-words].json` (one area folder, or a site's +`/skills/index.json`), is not a vector set: the verb reports AGSC-E901 and judges +none of its files. A missing folder is the same AGSC-E901 failure, exit 1. + Both verbs need a vector directory: this package ships no vector set of its own. The vectors are in the npm package `agentic-system-core`, in its `tests/vectors/` folder (after `npm install -g agentic-system-core`, `npm root -g` prints the folder @@ -149,10 +187,21 @@ rule text of the specification alone, in the standard library: | `frontmatter` | a reader for the closed YAML subset of AGSC-02-02 (failsafe scalars, each rejected construct under its own code, line numbers), the item checks of spec/02, and the drop-in adoption of AGSC-02-90…93 | | `slug` | the slug grammar and uniqueness | | `jcs` | RFC 8785 canonical JSON with NFC before sorting | -| `links` | the fourteen Link keys and their inverses, the cycle and cluster-tree checks, heading anchors, and inline-link resolution over a small CommonMark 0.31.2 scanner (headings and inline links only, outside code; its subset is written down in `agentic_system_core/markdown.py`) | -| `graph` | the RDF dataset of spec/05, canonical `graph.nq` (every line a quad named by the Bundle IRI, AGSC-04-15), the byte-pinned `graph.ttl` profile of AGSC-05-10, and the JSON-LD context of AGSC-06-32 with the compaction it round-trips | -| `build` | the `search.json` tokenizer and index, static query fragments, the served header set, `security.txt`, the content version and the staleness comparison; fourteen vectors of these seven areas need a whole build or the publisher's writers (`build-0015`, `build-0017`, `build-0020` to `build-0028`, `disc-0018`, `graph-0027`, `graph-0028`) and are reported as not run, by name | -| `discovery` | `/llms.txt` and `/llms-full.txt` byte for byte, reachability, the sitemap and robots facts, the link-set writer, and the discovery-document checks including the restricted-node rule of AGSC-11-20 | +| `links` | the fourteen Link keys and their inverses (the relation table of AGSC-03-01, shipped as data derived from the engine), the cycle and cluster-tree checks, the four warnings about what a Link says (a self-link, two relations a pair cannot both hold, a target of an unexpected kind, superseding a stable item: AGSC-03-23 to AGSC-03-26), heading anchors, and inline-link resolution over a small CommonMark 0.31.2 scanner (headings and inline links only, outside code; its subset is written down in `agentic_system_core/markdown.py`) | +| `graph` | the RDF dataset of spec/05, canonical `graph.nq` (every line a quad named by the Bundle IRI, AGSC-04-15), the byte-pinned `graph.ttl` profile of AGSC-05-10, `graph.jsonld` and the per-item `/pages/.jsonld` files of AGSC-05-09, written with the published context, the JSON-LD context of AGSC-06-32 with the compaction it round-trips, the readings of the Link graph with their reasons (AGSC-05-33), the ten questions of AGSC-05-34, the SKOS view of AGSC-05-36, and the context address that stays `1.0.0` whatever the ontology version (AGSC-05-09, graph-0043) | +| `build` | the `search.json` tokenizer and index, static query fragments, the served header set, `security.txt` (with a declared disclosure page), the content version, the `/now/` line (a restricted node's too) and the staleness comparison | +| `discovery` | `/llms.txt` and `/llms-full.txt` byte for byte (the 1.1 layout, a restricted node's header too), reachability, the sitemap and robots facts, the link-set writer, the discovery-document checks including the restricted-node rule of AGSC-11-20 and the chunk facts of AGSC-06-44, and the web connection of a node as data and bytes: the Signposting links of `/` (AGSC-06-40), the home page's Dataset block (AGSC-06-41), the opt-in `ard.json` and `ai-catalog.json` (AGSC-06-42) and the A2A agent card (AGSC-06-34) | + +Vectors of these seven areas that `run-vectors` reports as not run, each with its reason: + +- Seventeen need a whole Bundle build: `build-0015`, `build-0017`, `build-0020` to `build-0023`, `build-0025` to `build-0030`, `build-0033`, `build-0034`, `disc-0018`, `disc-0032`, `graph-0027`. +- Six need a writer this package does not carry, the HTML item pages, the chunk files, the closure file of `export --closure` (with the OWL 2 RL rules of AGSC-05-37) or the whole link table of AGSC-06-08 (this package's link-set writer covers part of it): `build-0031`, `build-0032`, `build-0037`, `disc-0020`, `disc-0021`, `graph-0041`. +- Eleven belong to the domain layer (site vocabulary, domain keys, warrants, contexts, crosswalks, SHACL), which only the engine checks in 1.1: `fm-0022` to `fm-0025`, `fm-0027`, `graph-0042`, `graph-0044` to `graph-0046`, `links-0018`, `links-0019`. + +Eight of the whole-build cases are still checked by this package: the test suite has +the engine build each Bundle, and `agentic_system_core/areas/build_tree.py` checks every +expectation of the 1.0 surface cases (`build-0020` to `build-0028`, less the withdrawn +`build-0024`) against the files written. The other areas need a Bundle build, the engine's composition or governance modules, or its command-line surface. Nothing is ever counted as a pass that @@ -206,14 +255,14 @@ arguments and never through a shell. ## Version -Two numbers, stated apart. The package version is `1.0.1`; the specification version -it implements is `1.0.0` (`SPEC_VERSION`). A patch of the package — a defect in a check, +Two numbers, stated apart. The package version is `1.1.0`; the specification version +it implements is `1.1.0` (`SPEC_VERSION`). A patch of the package — a defect in a check, a message — does not move the specification, and `agsc --version` prints both: -`agsc 1.0.1 (Python package; specification 1.0.0)`. Python packages use PEP 440, which -spells a release the same way as SemVer, so the version on PyPI is `1.0.1` too; a +`agsc 1.1.0 (Python package; specification 1.1.0)`. Python packages use PEP 440, which +spells a release the same way as SemVer, so the version on PyPI is `1.1.0` too; a release candidate is spelled differently: SemVer's `X.Y.Z-rc.N` is PEP 440's `X.Y.ZrcN`. A release is tested against the engine at its package tag of the same -version (`v1.0.1`). +version (`v1.1.0`). What changed in each version, and what the checker may now report, is in the [change log](https://github.com/andreibesleaga/agentic-system-core-python/blob/main/CHANGELOG.md). @@ -233,12 +282,25 @@ The discovery-file checker is meant to give the same verdict as the engine's `tools/validate-wellknown` on the same input. The test suite proves it: both tools are run over the same documents — the fixture set, a document taken from the engine's own conformance vectors, the built discovery files of two live -sites and a set of deliberately broken files — at every Level, with and without -a peer, and the status, the counts and the position and code of every finding +sites, two nodes the engine builds for the run (its minimal fixture and the +demonstration node) and a set of deliberately broken files — at every Level, with +and without a peer, and the status, the counts and the position and code of every finding are compared. Message text is not compared: the specification leaves a message unspecified so it can be translated, and pins the code. That test is skipped, with a message saying so, when Node or the engine checkout is not present. +One difference is known. When a digest target (`llms.txt`, say) or the ledger +is a directory instead of a file, the engine's checker reports `EISDIR`, Node's own +error name and not a registered code, and this package reports AGSC-E901, a +target not found on disk. The exit code, the status and the counts are the same. +A test pins the difference, so it fails once the engine reports a registered code. + +A second difference is in the agent card. A responder's `security_schemes` and +`security_requirements` (AGSC-06-34) pass, in the engine, through the official A2A SDK's +codec, which writes only the members A2A defines; this package has no SDK and leaves out +only empty strings and empty lists, as the codec does, so a member A2A does not define is +carried here and dropped there. The cases (`disc-0038`) state A2A's own members only. + ## Tests ``` @@ -250,8 +312,9 @@ python -m venv .venv && .venv/bin/pip install -e ".[test]" Deterministic, fixed data, no clock, no network. The subprocesses are the Node tool and vector runner in the two equivalence tests, and the workflow steps that `tests/test_ci_workflows.py` runs on scratch input. The tests that need Node and the -engine checkout beside this repository (`../agentic-system-core`) are skipped, with a -message, when either is absent: a fresh clone passes with those skipped, and a pull +engine checkout beside this repository (`../agentic-system-core`, or the checkout the +environment variable `AGSC_ENGINE_DIR` names) are skipped, with a message, when either +is absent: a fresh clone passes with those skipped, and a pull request is checked with the engine present ([docs/MAINTAINING.md](https://github.com/andreibesleaga/agentic-system-core-python/blob/main/docs/MAINTAINING.md)). diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 10ecfcf..6bb6502 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -38,9 +38,12 @@ flowchart TD cli --> vectors["vectors.py
vector checker and runner"] cli -->|"passes fetch in"| net cli -->|"subprocess, no shell"| node["Node engine agsc"] - wellknown --> net["net.py
guarded HTTP reader"] - vectors --> areas["areas/
one handler per area"] + wellknown --> net["net.py
guarded HTTP reader,
request budget"] + wellknown --> facts["wellknown_facts.py
chunk, ledger, card, home-link checks"] + facts --> net + vectors --> areas["areas/
one handler per area,
each behind the expected-reads guard"] vectors --> index[("data/spec-index.json")] + context --> published[("data/context.jsonld")] areas --> frontmatter["frontmatter.py"] areas --> slug["slug.py"] @@ -52,19 +55,56 @@ flowchart TD areas --> wellknown areas --> rdf + areas --> derive["derive.py
readings"] + areas --> questions["questions.py
ten questions"] + areas --> skos["skos.py
SKOS view"] + areas --> signposting["signposting.py
Link of /, Dataset block"] + areas --> catalogue["catalogue.py
ard.json, ai-catalog.json"] + areas --> agentcard["agentcard.py
A2A agent card"] + catalogue --> signposting + frontmatter --> yamlsubset["yamlsubset.py"] frontmatter --> slug frontmatter --> links links --> markdown["markdown.py"] + links --> relations["relations.py
relation table"] + relations --> table[("data/relations.json")] graphmod --> links + graphmod --> relations graphmod --> rdf["rdf.py"] + graphmod --> context context --> rdf + derive --> relations + questions --> links + questions --> relations + skos --> rdf discovery --> graphmod discovery --> links reader["reader.py
reading API"] ``` +The relation table of AGSC-03-01 has one source in the package: `relations.py` reads +`data/relations.json`, the engine's table written out by Node, and every module that +needs a key, an inverse or a property takes it from there (`tests/test_architecture.py` +fails when a module spells out a computed inverse name). + +`areas/build_tree.py` checks the files a whole build wrote against the `build` cases +that need one (`build-0020` to `build-0028`, less `build-0024`, withdrawn in 1.1). It +builds nothing: the caller passes a function that runs a build, and the test suite +passes one that runs the engine's. + +Every area handler runs behind `areas/_expected_reads.py`, the twin of the engine's +guard: a pass that left a member of a case's `expected` unread is turned into a fail, +so a vector cannot pass on an expectation no code compared. + +`net.py` is the only module that opens a connection (`tests/test_architecture.py` +fails otherwise): every request of a run passes its address classification, its caps, +its deadline and one request budget for the run, redirects included (AGSC-11-10(c)). +`signposting.py`, `catalogue.py` and `agentcard.py` are pure writers of data: they give +what the home page, the two catalogue files and the agent card carry, so the vectors +that pin those bytes run here, though this package writes no site. + `reader.py` stands apart: no other module imports it, and it imports only the package constants, `urls.py` and `jcs.py`. It never opens a connection; a fetcher is passed in by the caller. @@ -86,6 +126,12 @@ sequenceDiagram N-->>W: final URL, headers, bytes end W->>W: check(source, level, findings) + opt the document links chunks, a ledger or an agent card + W->>W: wellknown_facts: recompute count and set, ledger length, card served + end + opt target is a URL + W->>N: fetch(/): the Link header of the home page (describedby, AGSC-06-40) + end W->>D: envelope(findings, verb) D-->>W: envelope W-->>C: envelope, number of files read diff --git a/docs/MAINTAINING.md b/docs/MAINTAINING.md index eb754ef..a0ba2fc 100644 --- a/docs/MAINTAINING.md +++ b/docs/MAINTAINING.md @@ -17,11 +17,38 @@ the sixteen engine verbs, to the npm package's `agsc` when it is on the `PATH`. README's "What runs here" and "What forwards to Node" sections are the detail. [ARCHITECTURE.md](ARCHITECTURE.md) draws the parts and how they call each other. +Inside the seven areas, a case is reported as not run, with its reason, when it needs +a whole build (the query page of `build-0029` and `build-0030` among them), a writer +this package does not carry (HTML pages, the chunk files, the closure file of +`export --closure`, the whole link table of AGSC-06-08), or the domain layer (site +vocabulary, domain keys, warrants, contexts, crosswalks, SHACL), which only the engine +checks in 1.1; the reason of the last is `domain layer: engine only in 1.1`, and Python +parity for it is one of the "Ideas after 1.1" of the engine's roadmap. Every handler is +guarded as the engine's are (`areas/_expected_reads.py`, the twin of the engine's +`tests/conformance/areas/_expected-reads.js`): a pass that left a member of a case's +`expected` unread is a fail. The web connection of a node +(the Signposting links and the Dataset block of `/`, the two catalogue files, the A2A +agent card) is written here as data and bytes, though no page is, so its cases +(`disc-0026` to `disc-0031`) run. The cases and reasons are in +`src/agentic_system_core/areas/__init__.py` (`CASES_NOT_RUN`) and the handlers, and +the README lists them by name; `tests/test_readme_counts.py` keeps the two in step. + ## The equivalence proof `tests/test_equivalence.py` runs this package's discovery-file checker and the engine's `tools/validate-wellknown` over the same documents, at every Level, with and without a peer, and compares the status, the counts and each finding's position and code. The +documents are every case under `tests/fixtures/wellknown/`, the built files of the two +sites when they are here, and two nodes the engine builds for the run with +`SOURCE_DATE_EPOCH=1767225600`: its own `tests/fixtures/minimal` and, when it is checked +out beside this repository, `../agsc-demo-node` (copied with its git history, so the +build writes the ledger and the chunk and ledger facts of AGSC-06-44 that both checkers +recompute). The fixture cases of the 1.1 checks (`chunks-*`, `ledger-length-wrong`, +`card-*`) are the documents and files of vector disc-0033, and variants of them with one +fact changed; the checks of a URL alone (the `Link` header of `/`, the response headers, +the request budget) are stated by `tests/test_wellknown_facts.py` and +`tests/test_wellknown.py` with an injected fetcher, because the proof opens no +connection. The cross-runner test (`tests/test_vector_equivalence.py`) runs the engine's vector runner over its live set and requires both runners to agree on every vector of the seven areas. Both need the engine checked out beside this repository at `../agentic-system-core` and @@ -33,6 +60,35 @@ demo node (its built `www/` is committed there; the public `agsc-demo-node` does commit `www/`), so CI checks out only the main site and the patterns node's discovery file is read on the maintainer's machine. +To compare with another engine checkout (a second worktree of a release branch, say), +set `AGSC_ENGINE_DIR` to its path; unset or empty, the suite uses +`../agentic-system-core`. Every test that runs the engine reads it from there +(`tests/conftest.py`, `engine_dir`): + +```bash +AGSC_ENGINE_DIR=../agentic-system-core-1.1 .venv/bin/python -m pytest +``` + +On the `next-1.1` branch the vector copies, the rule index and the relation table are +the 1.1 engine's, so the suite agrees with a 1.1 engine checkout; run it with +`AGSC_ENGINE_DIR` naming one. Against a 1.0 checkout the drift tests and the +equivalence proof fail, as they should: they compare with another version. + +`tests/test_link_parity.py` is a property test against the same checkout: a seeded +generator (the same 120 item sets on every run) draws Link graphs, and the engine's +`links.resolve`, `derive.readings` and `questions.answer` must give what this package's +`links.link_warnings`, `derive.readings` and `questions.answer` give. + +Two more proofs need the same checkout and Node, and are skipped with a message without +them. `tests/test_graph_jsonld.py` checks that the shipped context is the one the +engine derives and that this package's `graph.jsonld` and per-item files equal the +engine's for every graph vector that states a dataset. `tests/test_build_cross_check.py` +has the engine build the Bundle of each of `build-0020` to `build-0028`, the way the +engine's own handler does, and `agentic_system_core/areas/build_tree.py` checks every +expectation of the vector against the files written (`build-0024` is withdrawn in 1.1 +and skipped with that reason). `run-vectors` still reports these cases as not run, +because this package writes no site. + ## Tests ```bash @@ -56,6 +112,10 @@ description. In short: - `ruff and mypy (Python 3.13)` runs `ruff check --select E4,E7,E9,F src tests` and `mypy src/agentic_system_core tests` at exact pins. - The engine is taken at `ENGINE_REF` (`main`) unless a manual run names another ref. + While this package follows an engine version that is not yet on the engine's `main`, + a push runs against the older engine and the drift and equivalence tests fail: run the + workflow by hand with `engine_ref` set to the engine's branch of that version before + the pull request is merged. - The required checks on `main` are the 3.9 and 3.13 test legs and the ruff and mypy job; the 3.14 leg is not required, but a release waits for it. - `.github/dependabot.yml` opens one monthly pull request for the pinned actions. @@ -66,12 +126,46 @@ The rule index (`src/agentic_system_core/data/spec-index.json`) is derived, neve typed. From this repository's root, with the engine beside it: ```bash -PYTHONPATH=src python3 -c "import json; from agentic_system_core import vectors; open('src/agentic_system_core/data/spec-index.json', 'w').write(json.dumps(vectors.spec_index_from('../agentic-system-core/spec'), sort_keys=True) + '\n')" +ENGINE="${AGSC_ENGINE_DIR:-../agentic-system-core}" +PYTHONPATH=src python3 -c "import json, sys; from agentic_system_core import vectors; open('src/agentic_system_core/data/spec-index.json', 'w').write(json.dumps(vectors.spec_index_from(sys.argv[1] + '/spec'), sort_keys=True) + '\n')" "$ENGINE" +``` + +The higher-Level case table of AGSC-10-15 (`HIGHER_LEVEL_CASES` in +`src/agentic_system_core/vectors.py`) is the table of `spec/10-implementation-profiles.md`; +`tests/test_vectors.py` reads the specification's table and fails when the two differ. + +The relation table of AGSC-03-01 (`src/agentic_system_core/data/relations.json`: the +fourteen Link keys, their inverses, RDF properties, self-link readings and Expected +target kinds) is the engine's `src/knowledge/relations.js`, written out by Node, never +typed. `links.py`, `graph.py`, `derive.py` and `questions.py` read it through +`relations.py`; the suite fails when it drifts, and a fitness test fails when a module +spells out a computed inverse name instead of reading the table: + +```bash +ENGINE="${AGSC_ENGINE_DIR:-../agentic-system-core}" +node -e "const r = require(require('node:path').resolve(process.argv[1], 'src/knowledge/relations.js')); process.stdout.write(JSON.stringify({ relations: r.RELATIONS }, null, 2) + '\n');" "$ENGINE" > src/agentic_system_core/data/relations.json ``` The vector copies under `tests/fixtures/vectors/` are byte-for-byte copies of the engine's `tests/vectors//` for the seven areas; the suite fails when they drift, -and the fix is to copy the files again, never to edit them. +and the fix is to copy the files again, never to edit them: + +```bash +ENGINE="${AGSC_ENGINE_DIR:-../agentic-system-core}" +for area in build discovery frontmatter graph jcs links slug; do + rm -r "tests/fixtures/vectors/$area" && cp -R "$ENGINE/tests/vectors/$area" tests/fixtures/vectors/ +done +``` + +The published JSON-LD context (`src/agentic_system_core/data/context.jsonld`, the bytes +a node serves at `/ns/context.jsonld`) is the engine's `tools/gen-ns` output, never +typed; `graph.jsonld` is compacted with it, and the suite fails when it drifts: + +```bash +ENGINE="${AGSC_ENGINE_DIR:-../agentic-system-core}" +out="$(mktemp -d)" && node "$ENGINE/tools/gen-ns" --quiet --out "$out" \ + && cp "$out/context.jsonld" src/agentic_system_core/data/context.jsonld && rm -r "$out" +``` ## Releases diff --git a/pyproject.toml b/pyproject.toml index 44f57b4..97085d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta" [project] name = "agentic-system-core" -version = "1.0.1" -description = "Two standalone checkers and a reading API for AgenticSystemCore knowledge nodes, in pure Python, with one agsc command that hands every other verb to the Node engine." +version = "1.1.0" +description = "Two standalone checkers and a reading API for AgenticSystemCore knowledge nodes, in pure Python, with one agsc command that hands every other verb to the Node engine; the domain layer is checked by the engine only." readme = "README.md" requires-python = ">=3.9" license = "Apache-2.0" @@ -47,7 +47,7 @@ test = ["pytest>=7", "coverage>=7"] where = ["src"] [tool.setuptools.package-data] -agentic_system_core = ["data/*.json"] +agentic_system_core = ["data/*.json", "data/*.jsonld"] [tool.pytest.ini_options] testpaths = ["tests"] diff --git a/src/agentic_system_core/README.md b/src/agentic_system_core/README.md index ca80045..f22c5fc 100644 --- a/src/agentic_system_core/README.md +++ b/src/agentic_system_core/README.md @@ -11,14 +11,21 @@ and hands every other verb to the Node engine. Standard library only. |---|---| | `cli.py` | the `agsc` command: the three checker verbs here, every other verb forwarded to Node | | `wellknown.py` | the discovery-file checker, the Python twin of the engine's `validate-wellknown` | +| `wellknown_facts.py` | the checker's 1.1 checks of what the document links: the chunk count, set commitment and digest (AGSC-06-44), the ledger length, the agent card on the node's own origin (AGSC-11-16), the `describedby` link in the `Link` header of `/` (AGSC-06-40) | +| `signposting.py` | the Signposting links of `/` (AGSC-06-40), the licence URL (AGSC-06-44) and the home page's Dataset block (AGSC-06-41), as data | +| `catalogue.py`, `agentcard.py` | the opt-in `/.well-known/ard.json` and `ai-catalog.json` (AGSC-06-42) and the A2A agent card (AGSC-06-34), as bytes | | `vectors.py` | the conformance-vector checker, the runner, and the specification index | -| `areas/` | one handler per vector area this package runs natively | +| `areas/` | one handler per vector area this package runs natively (`discovery_web.py` holds the web-connection cases disc-0026 to disc-0031, disc-0033 and disc-0035 to disc-0038, by vector id), `build_tree.py`, which checks the files a whole build wrote against `build-0020` to `build-0028`, and `_expected_reads.py`, the guard that fails a pass which left a member of `expected` unread, as the engine's handlers are guarded | | `reader.py` | the reading API: a discovery document, its links, digests, chunks and graph | | `diagnostics.py` | the diagnostics envelope and its findings | | `jcs.py` | canonical JSON (RFC 8785) and the strict I-JSON reader | | `yamlsubset.py`, `frontmatter.py` | the closed YAML subset, item checks and adoption | -| `slug.py`, `links.py`, `markdown.py` | slugs, the fourteen Link keys, a small CommonMark scanner | -| `graph.py`, `rdf.py`, `context.py` | the RDF dataset, canonical N-Quads and Turtle, the JSON-LD context | +| `slug.py`, `links.py`, `markdown.py` | slugs, the fourteen Link keys with the four Link warnings of AGSC-03-23 to 03-26, a small CommonMark scanner | +| `relations.py` | the relation table of AGSC-03-01 (keys, inverses, RDF properties, self-link readings, expected target kinds), read from `data/relations.json`; `links.py` and `graph.py` take theirs from it | +| `derive.py`, `questions.py` | the readings of the Link graph with their reasons (AGSC-05-33) and the ten questions (AGSC-05-34) | +| `graph.py`, `rdf.py`, `context.py`, `skos.py` | the RDF dataset, canonical N-Quads and Turtle, `graph.jsonld` and the per-item files, the JSON-LD context, the SKOS view of `export --skos` (AGSC-05-36) | | `discovery.py`, `site.py` | `llms.txt`, the link set, the search index, headers, `security.txt`, the content version | -| `urls.py`, `net.py` | URL handling, and the guarded HTTP reader used only with `--allow-network` | +| `urls.py`, `net.py` | URL handling, and the guarded HTTP reader used only with `--allow-network`, with the run's request budget (AGSC-11-10(c)); the only module that opens a connection | | `data/spec-index.json` | the rule identifiers, error codes and version this package ships | +| `data/context.jsonld` | the published JSON-LD context, as the engine's `tools/gen-ns` derives it; `graph.jsonld` is compacted with it | +| `data/relations.json` | the relation table, as the engine's `src/knowledge/relations.js` holds it (written out by the command in docs/MAINTAINING.md) | diff --git a/src/agentic_system_core/__init__.py b/src/agentic_system_core/__init__.py index a04bb99..565c281 100644 --- a/src/agentic_system_core/__init__.py +++ b/src/agentic_system_core/__init__.py @@ -14,13 +14,13 @@ # The PEP 440 spelling of the version; for a release it is the SemVer spelling too # (see README, "Version"). -__version__ = "1.0.1" +__version__ = "1.1.0" #: The SemVer spelling of the package version, the one the Node package uses too. -SEMVER_VERSION = "1.0.1" +SEMVER_VERSION = "1.1.0" #: The specification version this package implements (spec/00-overview.md). -SPEC_VERSION = "1.0.0" +SPEC_VERSION = "1.1.0" #: The well-known URI suffix of AGSC-06-07: /.well-known/knowledge-linkset. WELLKNOWN_SUFFIX = "knowledge-linkset" diff --git a/src/agentic_system_core/agentcard.py b/src/agentic_system_core/agentcard.py new file mode 100644 index 0000000..b31c063 --- /dev/null +++ b/src/agentic_system_core/agentcard.py @@ -0,0 +1,184 @@ +"""The Agent2Agent agent card ``/.well-known/agent-card.json`` (AGSC-06-34). + +The twin of the engine's ``src-ts/distribution/a2a-card.ts``: the A2A 1.0 Agent Card, +written only for a node that declares the ``a2a-card`` surface and a ``responder`` +surface (AGSC-06-07), every responder an A2A one (version ``a2a:``, +AGSC-11-21) and the ``a2a-card`` version a bare A2A version such as ``1.0``. A card +declared with no responder is a card without an endpoint, the error AGSC-E210; one +that would not be a true A2A card is not written, with the warning AGSC-E210, and the +discovery document does not declare it (``served_declarations``). A responder's +``security_schemes`` and ``security_requirements`` become the card's ``securitySchemes`` +and ``securityRequirements``. Vectors disc-0030, disc-0031, disc-0035 and disc-0038. + +The engine writes the card through the official A2A JavaScript SDK's JSON form of the +message (``AgentCard.toJSON``, the protobuf JSON mapping: an empty string, an empty list +and an empty map are left out, a sub-message stays), then sets ``skills`` to ``[]`` +when the node has no skill pack, then JCS and one LF. This module writes the same +members by the same rule. The Python A2A SDK (``a2a-sdk``) is not used: it is a +runtime dependency with seven of its own, and this package has none +(``dependencies = []``); the engine's bytes, through the shared vectors, are the +oracle. Pure: data in, text out. Standard library only. +""" + +import re + +from .diagnostics import finding +from .jcs import canonicalize + +#: AGSC-06-34 with AGSC-01-18: the ``protocolBinding`` of a responder that names none. +DEFAULT_BINDING = "JSONRPC" +#: AGSC-06-34: the ``tags`` of every skill (A2A 1.0 section 4.4.5 requires them). +SKILL_TAGS = ("knowledge", "skill-pack") +#: AGSC-11-21: the version prefix of a responder that is an Agent2Agent server. +A2A_PREFIX = "a2a:" +#: AGSC-11-16: the protocol version of ``a2a-card``, the bare form the schema admits. +A2A_VERSION = re.compile(r"^[0-9]+\.[0-9]+(?:\.[0-9]+)?$") + + +def declared(surfaces, name): + """The ``surfaces[]`` entries that declare the surface ``name``, in order.""" + return [one for one in surfaces if isinstance(one, dict) and one.get("surface") == name] + + +def _text(value): + """JavaScript's ``String()`` of a configured value: ``undefined`` when absent.""" + if value is None: + return "undefined" + return str(value) + + +def _unpublishable(surfaces): + """Why a node that declares ``a2a-card`` and a responder gets no card, or None.""" + if any(not _text(one.get("version")).startswith(A2A_PREFIX) + for one in declared(surfaces, "responder")): + return ("a responder whose version is not a2a: is not an A2A endpoint, and the " + "card would list it as one") + version = declared(surfaces, "a2a-card")[0].get("version") + if A2A_VERSION.match(_text(version)) is None: + shown = "undefined" if version is None else canonicalize(version) + return ("the a2a-card version %s is not an A2A protocol version such as 1.0, and the " + "card would carry it as the protocolVersion of every interface" % shown) + return None + + +def eligible(surfaces): + """AGSC-06-34: both surfaces declared, every responder an A2A one, a bare A2A version.""" + return bool(declared(surfaces, "a2a-card")) and bool(declared(surfaces, "responder")) \ + and _unpublishable(surfaces) is None + + +def card_findings(surfaces): + """AGSC-06-07, AGSC-06-34: the findings of a declared card that is not written.""" + if not declared(surfaces, "a2a-card"): + return [] + if not declared(surfaces, "responder"): + return [finding("AGSC-E210", "agsc.config.json", + "surfaces[] declares a2a-card but no responder surface: a card without " + "an endpoint is not published (AGSC-06-07, AGSC-06-34; a local MCP tool " + "server is not an A2A endpoint)")] + why = _unpublishable(surfaces) + if why is None: + return _open_credential_findings(surfaces) + target = _text(declared(surfaces, "a2a-card")[0].get("target")) + return [finding("AGSC-E210", "agsc.config.json", + "no /.well-known/agent-card.json is written: %s; the discovery document does " + "not declare a2a-card at %s either (AGSC-06-34, AGSC-11-16, AGSC-11-21)" + % (why, target), severity="warn")] + + +def _open_credential_findings(surfaces): + """AGSC-06-34 as amended 2026-11-10: a ``credential`` responder that names no + ``security_schemes`` leaves a card an A2A client reads as open.""" + return [finding("AGSC-E210", "agsc.config.json", + "the responder %s is declared with access credential and its entry names no " + "security_schemes, so the card carries no securitySchemes and an A2A client " + "reads it as open (AGSC-06-34, AGSC-11-16)" % _text(one.get("target")), + severity="warn") + for one in declared(surfaces, "responder") + if one.get("access") == "credential" and not one.get("security_schemes")] + + +def served_declarations(surfaces): + """AGSC-11-16 as amended 2026-11-10: the declaration-only surfaces less an ``a2a-card`` + that gets no card, so the discovery document declares no card the node does not serve + (the engine's ``well-known.js#servedDeclarations``).""" + if not declared(surfaces, "a2a-card") or eligible(surfaces): + return list(surfaces) + return [one for one in surfaces + if not (isinstance(one, dict) and one.get("surface") == "a2a-card")] + + +def _pruned(value): + """The protobuf JSON mapping the SDK writes a message in: an empty string or list is + left out, a sub-message stays. Members A2A does not define are not dropped here, as + the engine's codec drops them (README, "Differences from the engine").""" + if isinstance(value, dict): + return dict((name, _pruned(one)) for name, one in value.items() if one not in ("", [])) + if isinstance(value, list): + return [_pruned(one) for one in value] + return value + + +def _security(surfaces): + """AGSC-06-34 as amended 2026-11-10: the card's ``securitySchemes`` (the first entry + to give a name wins) and ``securityRequirements``, from the responder entries in order.""" + schemes, requirements = {}, [] + for one in declared(surfaces, "responder"): + for name, scheme in (one.get("security_schemes") or {}).items(): + schemes.setdefault(name, _pruned(scheme)) + requirements.extend(_pruned(entry) for entry in one.get("security_requirements") or []) + return schemes, requirements + + +def _first_text(*values): + for value in values: + if isinstance(value, str) and value != "": + return value + return "" + + +def _present(fields): + """The protobuf JSON mapping of the SDK's writer: an empty string or list is left out.""" + return dict((name, value) for name, value in fields.items() if value not in ("", [])) + + +def card(surfaces, packs, title, bundle_version, spec_version, visibility=None, + description=None, tagline=None): + """AGSC-06-34: the card's members as the SDK's JSON writer writes them. ``version`` + is the content version, and on a restricted node the specification version + (AGSC-11-20 stamps no content version where an unauthenticated reader can read it).""" + protocol = _first_text(declared(surfaces, "a2a-card")[0].get("version")) + interfaces = [_present({"protocolBinding": _first_text(one.get("binding"), DEFAULT_BINDING), + "protocolVersion": protocol, "tenant": "", + "url": _text(one.get("target"))}) + for one in declared(surfaces, "responder")] + skills = [_present({"description": _first_text(pack.get("description")), "examples": [], + "id": pack.get("name"), "inputModes": [], "name": pack.get("name"), + "outputModes": [], "securityRequirements": [], "tags": list(SKILL_TAGS)}) + for pack in packs] + version = spec_version if visibility == "restricted" else bundle_version + schemes, requirements = _security(surfaces) + out = _present({ + "defaultInputModes": ["text/plain"], "defaultOutputModes": ["application/json"], + "description": _first_text(description, tagline, title), "name": title, + "securityRequirements": requirements, "signatures": [], "skills": skills, + "supportedInterfaces": interfaces, "version": version, + }) + if schemes: + out["securitySchemes"] = schemes + # A sub-message stays, its own empty `extensions` left out; an empty map (the + # security schemes) is left out. A2A 1.0 section 4.4.1: `skills` is required, so a + # node with no pack has `skills` []. + out["capabilities"] = {} + out.setdefault("skills", []) + return out + + +def card_bytes(surfaces, packs, title, bundle_version, spec_version, visibility=None, + description=None, tagline=None): + """AGSC-06-34: the bytes of ``/.well-known/agent-card.json`` (JCS, one trailing LF), + or None when the node is not eligible (AGSC-06-07).""" + if not eligible(surfaces): + return None + return canonicalize(card(surfaces, packs, title, str(bundle_version), str(spec_version), + visibility, description, tagline)) + "\n" diff --git a/src/agentic_system_core/areas/__init__.py b/src/agentic_system_core/areas/__init__.py index 048f15d..2b4d1c5 100644 --- a/src/agentic_system_core/areas/__init__.py +++ b/src/agentic_system_core/areas/__init__.py @@ -4,25 +4,38 @@ rule text of the specification: * ``frontmatter`` — the closed YAML subset, failsafe scalars, the item checks - of spec/02 and adoption. + of spec/02, the 64-level nesting bound and adoption. * ``slug`` — the slug grammar and uniqueness. * ``jcs`` — RFC 8785 canonical JSON, NFC before sorting. -* ``links`` — Link keys, inverses, cycles, the cluster tree, anchors and - inline-link resolution over a small CommonMark scanner. -* ``graph`` — the RDF dataset, canonical N-Quads, the stable-Turtle profile and - the JSON-LD context. +* ``links`` — Link keys, inverses, cycles, the cluster tree, the four Link + warnings of AGSC-03-23 to 03-26, anchors and inline-link resolution over a small + CommonMark scanner. +* ``graph`` — the RDF dataset, canonical N-Quads, the stable-Turtle profile, + ``graph.jsonld`` with the per-item files, the JSON-LD context, the readings and + the ten questions of the Link graph, and the SKOS view. * ``build`` — the search index and tokenizer, fragments, headers, - ``security.txt`` and the content version. + ``security.txt``, the content version and the ``/now/`` line. * ``discovery`` — ``/llms.txt``, ``/llms-full.txt``, reachability, sitemap and - robots facts, and the link set. + robots facts, the link set, and the web connection of a node. + +Every handler is guarded as the engine's are: a pass that left a member of a case's +``expected`` unread is a fail (``_expected_reads``). + +``build_tree`` is not an area runner: it checks the nine ``build`` cases that need a +whole build (build-0020 to build-0028) against the files another writer built. Every other area needs something this package does not carry: a Bundle build, the engine's composition, governance, ledger or boundary modules, or its command-line surface. Each one is named below with its reason, and the runner reports it as not run — never as a silent pass and never as a skip that a -reader could mistake for one. +reader could mistake for one. Inside the seven areas, a case whose input is a +whole Bundle is reported not run by its handler; ``CASES_NOT_RUN`` names the other +cases this package cannot run (a writer it does not carry, or the domain layer, +which the engine alone checks in 1.1), each with its reason, and the few cases of +an area not run here whose reason is narrower than the area's. """ +from ._expected_reads import guarded from .build_area import run as _run_build from .discovery_area import run as _run_discovery from .frontmatter_area import run as _run_frontmatter @@ -31,17 +44,73 @@ from .links_area import run as _run_links from .slug_area import run as _run_slug -#: area name -> callable(vector) -> {"status": "pass"|"fail", "detail": str} -AREA_RUNNERS = { - "build": _run_build, - "discovery": _run_discovery, - "frontmatter": _run_frontmatter, - "graph": _run_graph, - "jcs": _run_jcs, - "links": _run_links, - "slug": _run_slug, +#: The reason every domain-layer case gives (site vocabulary, domain keys, warrants, +#: contexts, crosswalks, SHACL): the engine checks the domain layer, this package not yet. +DOMAIN_LAYER = "domain layer: engine only in 1.1" +_NO_HTML = "needs the HTML page writer of a full build (AGSC-06-38); this package writes no HTML" +_QUERY_PAGE = "needs the engine's build and the query page (Level 3)" +_WHOLE_LINK_TABLE = ("needs the engine's writer of the whole link table of AGSC-06-08 " + "(surfaces, contribute, successor, related-system and typed peer links); " + "this package's link-set writer covers part of it") + +#: vector id -> why this package does not run it: cases of the seven areas whose input +#: shape the handler could read but whose subject is a writer or a layer this package +#: does not carry, and cases of an area it does not run whose reason is narrower than +#: the area's own (the diagram compiler of bundle-0018 and bundle-0019). +CASES_NOT_RUN = { + "bundle-0018": "needs the diagram compiler (Level 3)", + "bundle-0019": "needs the diagram compiler (Level 3)", + "build-0029": _QUERY_PAGE, + "build-0030": _QUERY_PAGE, + "build-0031": _NO_HTML, + "build-0032": _NO_HTML, + "build-0037": "needs the chunk writer of a full build (/chunks.jsonl, /chunks-index.toon)", + "disc-0020": _WHOLE_LINK_TABLE, + "disc-0021": _WHOLE_LINK_TABLE, + "disc-0032": ("needs a whole build of the minimal fixture: it reads every file the engine " + "writes, the HTML home page among them, for the PROV-O terms (AGSC-06-41); " + "this package writes no HTML"), + "fm-0022": DOMAIN_LAYER, + "fm-0023": DOMAIN_LAYER, + "fm-0024": DOMAIN_LAYER, + "fm-0025": DOMAIN_LAYER, + "fm-0027": DOMAIN_LAYER, + "graph-0041": ("needs export --closure: a Turtle reader of the engine's ontology/agsc.ttl " + "and the OWL 2 RL rules of AGSC-05-37 (the engine runs them with the n3 " + "Reasoner); this package carries no export verb and no reasoner"), + "graph-0042": DOMAIN_LAYER, + "graph-0044": DOMAIN_LAYER, + "graph-0045": DOMAIN_LAYER, + "graph-0046": DOMAIN_LAYER, + "links-0018": DOMAIN_LAYER, + "links-0019": DOMAIN_LAYER, } + +def _unless_not_run(runner): + """The area runner, behind the ``CASES_NOT_RUN`` table and the guard against a + pass that left a member of ``expected`` unread (``_expected_reads``).""" + checked = guarded(runner) + + def run(vector): + reason = CASES_NOT_RUN.get(vector.get("id")) + if reason is not None: + return {"status": "not-run", "detail": reason} + return checked(vector) + return run + + +#: area name -> callable(vector) -> {"status": "pass"|"fail"|"not-run", "detail": str} +AREA_RUNNERS = dict((name, _unless_not_run(runner)) for name, runner in ( + ("build", _run_build), + ("discovery", _run_discovery), + ("frontmatter", _run_frontmatter), + ("graph", _run_graph), + ("jcs", _run_jcs), + ("links", _run_links), + ("slug", _run_slug), +)) + #: area name -> why this package does not run it. NOT_RUN_REASONS = { "adapters": "needs the engine's adapters; not implemented by this package", @@ -64,4 +133,4 @@ "skills": "needs the skills writer of a full build", } -__all__ = ["AREA_RUNNERS", "NOT_RUN_REASONS"] +__all__ = ["AREA_RUNNERS", "CASES_NOT_RUN", "DOMAIN_LAYER", "NOT_RUN_REASONS"] diff --git a/src/agentic_system_core/areas/_expected_reads.py b/src/agentic_system_core/areas/_expected_reads.py new file mode 100644 index 0000000..5ad127b --- /dev/null +++ b/src/agentic_system_core/areas/_expected_reads.py @@ -0,0 +1,77 @@ +"""A guard against a vacuous pass (AGSC-09-02, AGSC-09-06). + +The twin of the engine's ``tests/conformance/areas/_expected-reads.js``. A handler +that never reads a member of ``expected`` has asserted nothing about it, and a pass +it returns says nothing about that member. The guard runs a handler over a copy of +the case whose ``expected`` records every top-level member the handler reads, and +turns a pass into a fail when a member was never read, or when the case states no +member at all. A fail or a not-run is returned unchanged, so the guard can only make +a result stricter. + +A member counts as read as it does in the engine: by name (``expected["x"]``, +``expected.get("x")`` or a presence test ``"x" in expected``, which the engine's +``expected.x !== undefined`` is), or by listing the members. +""" + + +class _Recording(dict): + """``expected`` that notes the name of every member read.""" + + def __init__(self, members): + super().__init__(members) + self.read = set() + + def __getitem__(self, key): + self.read.add(key) + return super().__getitem__(key) + + def get(self, key, default=None): + self.read.add(key) + return super().get(key, default) + + def __contains__(self, key): + self.read.add(key) + return super().__contains__(key) + + def _listed(self): + self.read.update(super().keys()) + + def __iter__(self): + self._listed() + return super().__iter__() + + def keys(self): + self._listed() + return super().keys() + + def items(self): + self._listed() + return super().items() + + def values(self): + self._listed() + return super().values() + + +def guarded(handler): + """``handler``, with a pass that left a member of ``expected`` unread turned into a + fail that names the members.""" + def run(vector): + expected = vector.get("expected") + if not isinstance(expected, dict): + return handler(vector) + tracked = _Recording(expected) + result = handler(dict(vector, expected=tracked)) + if not result or result.get("status") != "pass": + return result + unread = [key for key in expected if key not in tracked.read] + if expected and not unread: + return result + if not expected: + detail = "%s: the case states no expected member, so a pass would assert nothing" \ + % vector.get("id") + else: + detail = "%s: no branch of the handler reads %s" % ( + vector.get("id"), ", ".join('"%s"' % key for key in unread)) + return {"status": "fail", "detail": detail} + return run diff --git a/src/agentic_system_core/areas/build_area.py b/src/agentic_system_core/areas/build_area.py index 8dac02a..76f0b99 100644 --- a/src/agentic_system_core/areas/build_area.py +++ b/src/agentic_system_core/areas/build_area.py @@ -1,10 +1,12 @@ """Area ``build`` — AGSC-06-16/06-23 (search), AGSC-06-21 (the sharded index), AGSC-06-33 (fragments), AGSC-06-17 (headers and the page policy), AGSC-06-36 -(security.txt) and AGSC-04-25/06-22 (content version). +(security.txt, with the declared disclosure page of 1.1) and AGSC-04-25/06-22 (content +version, and the ``/now/`` line of a restricted node, AGSC-11-20). Every member of ``expected`` is checked; an unknown member is a failure. A vector whose input is a whole Bundle (``bundle`` or inline ``files``) needs a -site build this package does not carry, and is reported as not run, by name. +site build this package does not carry, and is reported as not run, by name; +``build_tree.py`` checks build-0020 to build-0028 over a tree another writer built. """ from .. import site @@ -30,8 +32,9 @@ def _cases(given, expected, handler): def _security(case, want, base): + # build-0035 (AGSC-06-36 as amended for 1.1) declares site.security_policy. text, findings = site.security_txt(case["authored"], case["instant"], base, - case["legal"]) + case["legal"], policy=case.get("security_policy")) out = [(case["name"] + ":text", text == want["text"], shown(text)), (case["name"] + ":findings", _codes(findings) == want["findings"], shown(_codes(findings)))] @@ -54,6 +57,12 @@ def _version(case, want): kind == want["ledger_kind_of_built_commit"], kind)) unknown = set(want) - {"bundle_version", "findings", "ledger_kind_of_built_commit", "name"} + elif "visibility" in case: + # build-0036 (AGSC-06-22 with AGSC-11-20): the whole line, public or restricted. + line = site.now_line(case["bundle_version"], case["instant"], case["fingerprint"], + case["spec_version"], visibility=case["visibility"]) + out.append((case["name"] + ":line", line == want["line"], line)) + unknown = set(want) - {"line", "name"} else: line = site.now_line(case["bundle_version"], case["generated_at"], case["bundle_hash"], case["spec_version"]) diff --git a/src/agentic_system_core/areas/build_tree.py b/src/agentic_system_core/areas/build_tree.py new file mode 100644 index 0000000..3da4048 --- /dev/null +++ b/src/agentic_system_core/areas/build_tree.py @@ -0,0 +1,347 @@ +"""The ``build`` cases whose expectations are facts about a whole build (build-0020 to +build-0028): AGSC-00-05 (what a retired and a draft item leave on each surface), +AGSC-01-19 (``build.out`` naming ``content/`` or ``dist/`` is refused), AGSC-01-20 (the +release switchboard), AGSC-05-07 (the page copy drops a Link to a draft), AGSC-06-01 +(the route set), AGSC-07-19 and AGSC-07-20 (``/skills/index.json`` and its locks) and +AGSC-06-18 (the TDM reservation file and its robots groups). + +This package writes no site, so it cannot produce the files these cases speak about; +``run-vectors`` reports them as not run. What it can do is read a tree another writer +built and check every expectation against it, so the cases are checked by a second +implementation. :func:`check` takes the vector and ``build``, a callable that runs a +build for a sub-case (or ``None``) and returns ``{"exit", "findings", "files", +"written"}``: the exit code, the findings of the ``--json`` envelope, the bytes of each +file under ``build.out`` by route (``/index.html``), and every path the run added +anywhere in the Bundle. The test suite passes one that runs the engine's build. The +checks follow the engine's handler, ``tests/conformance/areas/_build-surfaces.js``, +member for member; a member nothing reads is a failure. +""" + +import hashlib +import json +import posixpath +import re + +from ..jcs import canonicalize +from ._assert import checks, shown + +#: The members one build's surface checks read (build-0020, 0022, 0023, 0028). +SURFACE_MEMBERS = frozenset(("carried_by", "files_contain", "in_no_file", "no_error_finding", + "not_carried_by", "route_bytes", "routes_absent", "routes_present")) + + +def file_of(route): + """The file a route is served from: a route ending in ``/`` is its ``index.html``.""" + return route + "index.html" if route.endswith("/") else route + + +def _text(files, route): + data = files.get(file_of(route)) + return None if data is None else data.decode("utf-8") + + +def _same(one, other): + """Equal JSON values: arrays in order, objects in any member order, ``true`` never ``1``.""" + return canonicalize(one) == canonicalize(other) + + +def _parse(text, fallback): + try: + return json.loads(text) + except (TypeError, ValueError): + return fallback + + +def is_jcs_with_one_lf(text): + """AGSC-04-04: one JSON value in JCS form followed by exactly one LF.""" + if text is None or not text.endswith("\n") or text.endswith("\n\n"): + return False + value = _parse(text, None) + return value is not None and canonicalize(value) + "\n" == text + + +# --- one build, the surfaces ------------------------------------------------------- + +def _clean_build(expected, run): + errors = [one["code"] for one in run["findings"] if one.get("severity") == "error"] + ok = (not errors) == expected["no_error_finding"] and run["exit"] == 0 + return [("no error finding", ok, "exit %s %s" % (run["exit"], shown(errors)))] + + +def _strings(expected, member, files, wanted): + """``carried_by``, ``not_carried_by``, ``files_contain``: route -> strings.""" + out = [] + for route, strings in sorted(expected.get(member, {}).items()): + body = _text(files, route) + for one in strings: + ok = body is not None and (one in body) == wanted + out.append(("%s %s %s" % (route, member, one), ok, + "absent" if body is None else shown(body[:400]))) + return out + + +def surface_checks(expected, run): + """Every surface member a vector states over one build.""" + files = run["files"] + out = _clean_build(expected, run) if "no_error_finding" in expected else [] + out.extend(("emits " + route, file_of(route) in files, route) + for route in expected.get("routes_present", [])) + out.extend(("no " + route, file_of(route) not in files, route) + for route in expected.get("routes_absent", [])) + out.extend(_strings(expected, "carried_by", files, True)) + out.extend(_strings(expected, "not_carried_by", files, False)) + out.extend(_strings(expected, "files_contain", files, True)) + for one in expected.get("in_no_file", []): + hits = [route for route, data in sorted(files.items()) + if one in route or one in data.decode("latin-1")] + out.append(("no file names " + one, not hits, shown(hits))) + for route, data in sorted(expected.get("route_bytes", {}).items()): + body = _text(files, route) + out.append((route + " bytes", body == data, shown(body))) + return out + + +def _surfaces(vector, build): + return surface_checks(vector["expected"], build(None)), SURFACE_MEMBERS + + +# --- the route set (build-0024) ------------------------------------------------------ + +_SCRIPT_SRC = re.compile(r']*\bsrc="([^"]+)"') +_STYLESHEET = re.compile(r']*\brel="stylesheet"[^>]*\bhref="([^"]+)"') +_OTHER_ORIGIN = re.compile(r"^[a-z][a-z0-9+.-]*:|^//", re.I) + + +def page_assets(files): + """The same-origin files the emitted HTML pages load (script src, stylesheet href).""" + loaded = set() + for route, data in files.items(): + if not route.endswith(".html"): + continue + folder = route[:route.rindex("/") + 1] + html = data.decode("utf-8") + for ref in _SCRIPT_SRC.findall(html) + _STYLESHEET.findall(html): + if not _OTHER_ORIGIN.search(ref): + loaded.add(ref if ref.startswith("/") else posixpath.normpath(folder + ref)) + return loaded + + +def _route_set(vector, build): + expected = vector["expected"] + run = build(None) + loaded = page_assets(run["files"]) + assets = [one for one in run["files"] if one.endswith((".js", ".css")) and one in loaded] + routes = sorted(one[:-len("index.html")] if one.endswith("/index.html") else one + for one in run["files"] if one not in assets) + want = sorted(expected["routes"]) + out = surface_checks(expected, run) + out.append(("the route set", routes == want, "extra %s missing %s" % ( + shown([one for one in routes if one not in want]), + shown([one for one in want if one not in routes])))) + out.extend(("emits " + one, one in assets, shown(assets)) + for one in expected["page_assets_required"]) + out.append(("other files are page assets", expected["other_files_are_page_assets"] is True, + shown(assets))) + out.append(("deployment profile", vector["input"].get("deployment_profile") == "cloudflare-pages", + "this check reads the Cloudflare Pages profile (AGSC-06-17)")) + return out, SURFACE_MEMBERS | {"other_files_are_page_assets", "page_assets_required", "routes"} + + +# --- sub-cases ------------------------------------------------------------------------- + +def _sub_cases(vector, build, members, handler): + """Run ``handler(name, want, run)`` for each sub-case; ``members`` are the ones it reads.""" + out = [] + wanted = dict((one["name"], one) for one in vector["expected"]["cases"]) + for sub in vector["input"]["cases"]: + want = wanted.get(sub["name"]) + if want is None: + out.append((sub["name"], False, "the vector states no expected case of this name")) + continue + out.extend(handler(sub["name"], want, build(sub))) + unknown = sorted(set(want) - members - {"name"}) + if unknown: + out.append((sub["name"] + " unhandled", False, shown(unknown))) + return out, {"cases"} + + +def _subset_of(expected, actual): + """Every member the vector states is present and equal in the finding.""" + return all(key in actual and _same(value, actual[key]) for key, value in expected.items()) + + +def _build_out_case(name, want, run): + out = [] + if "exit" in want: + out.append((name + " exit", run["exit"] == want["exit"], "exit %s" % run["exit"])) + if "exit_one_of" in want: + out.append((name + " exit", run["exit"] in want["exit_one_of"], "exit %s" % run["exit"])) + if "findings" in want: + missing = [one for one in want["findings"] + if not any(_subset_of(one, have) for have in run["findings"])] + out.append((name + " findings", not missing, "unmatched %s in %s" % ( + shown(missing), shown([one.get("code") for one in run["findings"]])))) + for code in want.get("codes_absent", []): + out.append(("%s no %s" % (name, code), + all(one.get("code") != code for one in run["findings"]), shown(run["findings"]))) + if "nothing_written" in want: + out.append((name + " nothing written", (not run["written"]) == want["nothing_written"], + shown(run["written"]))) + if "written_only_under" in want: + outside = [one for one in run["written"] if not one.startswith(want["written_only_under"])] + out.append(("%s writes only under %s" % (name, want["written_only_under"]), + bool(run["written"]) and not outside, shown(outside))) + return out + + +def _build_out(vector, build): + members = {"codes_absent", "exit", "exit_one_of", "findings", "nothing_written", + "written_only_under"} + return _sub_cases(vector, build, members, _build_out_case) + + +def _skills_index_case(name, want, run): + text = _text(run["files"], "/skills/index.json") + index = _parse(text, None) + index = index if isinstance(index, dict) else {} + out = [(name + " JCS and one LF", is_jcs_with_one_lf(text) == want["jcs_with_one_lf"], shown(text)), + (name + " members", sorted(index) == sorted(want["members"]), shown(sorted(index)))] + for key in ("bundle_version", "license", "spec_version", "terms"): + out.append(("%s %s" % (name, key), index.get(key) == want[key], shown(index.get(key)))) + packs = index.get("packs") if isinstance(index.get("packs"), list) else [] + out.append((name + " packs", len(packs) == len(want["packs"]), shown(packs))) + for number, pack in enumerate(want["packs"]): + got = packs[number] if number < len(packs) else {} + label = "%s pack %d" % (name, number) + rest = dict((key, value) for key, value in got.items() if key != "lock") + out.append((label + " members", sorted(got) == sorted(want["pack_members"]), shown(sorted(got)))) + out.append((label, _same(rest, pack), shown(rest))) + out.append((label + " has a lock", "lock" in got, shown(got))) + return out + + +def _skills_index(vector, build): + members = {"bundle_version", "jcs_with_one_lf", "license", "members", "pack_members", "packs", + "spec_version", "terms"} + return _sub_cases(vector, build, members, _skills_index_case) + + +# --- the skill locks (build-0026) ---------------------------------------------------- + +_HEX64 = re.compile(r"^[0-9a-f]{64}$") +_LOCK_ROUTE = re.compile(r"\.lock$|lock(file)?\.json$", re.I) + + +def _skills_lock(vector, build): + expected = vector["expected"] + run = build(None) + index = _parse(_text(run["files"], "/skills/index.json"), None) + packs = index.get("packs") if isinstance(index, dict) and isinstance(index.get("packs"), list) else [] + out = [("packs_count", len(packs) == expected["packs_count"], str(len(packs)))] + for pack in packs: + lock = pack.get("lock") or {} + out.append(("%s lock members" % pack.get("name"), + sorted(lock) == sorted(expected["lock_members"]), shown(lock))) + served = run["files"].get(str(pack.get("path"))) + digest = None if served is None else hashlib.sha256(served).hexdigest() + ok = bool(_HEX64.match(str(lock.get("SKILL.md")))) and lock.get("SKILL.md") == digest + out.append(("%s lock is the hash of %s" % (pack.get("name"), pack.get("path")), + ok == expected["lock_is_sha256_of_skill_md"], + "lock %s served %s" % (lock.get("SKILL.md"), digest))) + routes = [one for one in sorted(run["files"]) if _LOCK_ROUTE.search(one)] + out.append(("no lock route", (not routes) == expected["no_lock_route"], shown(routes))) + return out, {"lock_is_sha256_of_skill_md", "lock_members", "no_lock_route", "packs_count"} + + +# --- the TDM reservation (build-0027) ------------------------------------------------ + +def tdm_matches(pattern, target): + """A TDMRep location against a path: a prefix match in which ``*`` stands for any + characters and a final ``$`` ends the pattern (TDM Reservation Protocol, 6.1).""" + anchored = pattern.endswith("$") + body = pattern[:-1] if anchored else pattern + source = ".*".join(re.escape(part) for part in body.split("*")) + return re.match(source + ("$" if anchored else ""), target) is not None + + +_FIELD = re.compile(r"^([A-Za-z-]+)\s*:\s*(.*)$") + + +def disallow_all_groups(robots): + """The user agents of the robots.txt groups that carry ``Disallow: /``, in file order.""" + out, agents, in_rules = [], [], False + for raw in (robots or "").split("\n"): + match = _FIELD.match(re.sub(r"#.*$", "", raw).strip()) + if match is None: + continue + field, value = match.group(1).lower(), match.group(2) + if field == "user-agent": + if in_rules: + agents, in_rules = [], False + agents.append(value) + elif field in ("allow", "disallow"): + in_rules = True + if field == "disallow" and value == "/": + out.extend(one for one in agents if one not in out) + return out + + +def _reservation(rules, target): + for rule in rules if isinstance(rules, list) else []: + if isinstance(rule, dict) and isinstance(rule.get("location"), str) \ + and tdm_matches(rule["location"], target): + return rule.get("tdm-reservation") + return None + + +def _tdmrep_case(name, want, run): + text = _text(run["files"], "/.well-known/tdmrep.json") + rules = _parse(text, []) + out = [(name + " JCS and one LF", is_jcs_with_one_lf(text) == want["jcs_with_one_lf"], shown(text))] + for target, reservation in sorted(want["reservation_for_paths"].items()): + got = _reservation(rules, target) + out.append(("%s %s" % (name, target), got == reservation, "got %s" % shown(got))) + out.extend(("%s no %s" % (name, route), route not in run["files"], route) + for route in want["routes_absent"]) + groups = disallow_all_groups(_text(run["files"], "/robots.txt")) + out.append((name + " robots groups", groups == want["robots_disallow_all_groups"], shown(groups))) + return out + + +def _tdmrep(vector, build): + members = {"jcs_with_one_lf", "reservation_for_paths", "robots_disallow_all_groups", + "routes_absent"} + return _sub_cases(vector, build, members, _tdmrep_case) + + +#: case id -> handler(vector, build) -> (checks, the expected members it reads). +HANDLERS = { + "build-0020": _surfaces, + "build-0021": _build_out, + "build-0022": _surfaces, + "build-0023": _surfaces, + "build-0024": _route_set, + "build-0025": _skills_index, + "build-0026": _skills_lock, + "build-0027": _tdmrep, + "build-0028": _surfaces, +} + + +def check(vector, build): + """The verdict on one case over the tree ``build`` returns: pass, fail with the + reasons, skip for a withdrawn case, or not run for a case this module does not hold.""" + if vector.get("level") == "withdrawn": + return {"status": "skip", "withdrawn": True, "detail": "withdrawn (AGSC-00-16)"} + handler = HANDLERS.get(vector["id"]) + if handler is None: + return {"status": "not-run", "detail": "%s is not a case over a whole build" % vector["id"]} + items, members = handler(vector, build) + unknown = sorted(set(vector["expected"]) - members) + if unknown: + items.append(("unhandled", False, "expected members not checked: %s" % shown(unknown))) + return checks(items) + + +__all__ = ["HANDLERS", "SURFACE_MEMBERS", "check", "disallow_all_groups", "file_of", + "is_jcs_with_one_lf", "page_assets", "surface_checks", "tdm_matches"] diff --git a/src/agentic_system_core/areas/discovery_area.py b/src/agentic_system_core/areas/discovery_area.py index a8d503b..d9b2f9f 100644 --- a/src/agentic_system_core/areas/discovery_area.py +++ b/src/agentic_system_core/areas/discovery_area.py @@ -2,26 +2,32 @@ Every member of ``expected`` is checked; an unknown member is a failure. A vector whose input is a whole Bundle (``bundle``) needs a site build this package -does not carry, and is reported as not run, by name. +does not carry, and is reported as not run, by name. The cases of the web +connection and of the 1.1 chunk facts (disc-0026 to disc-0031, disc-0033, disc-0035 to disc-0038) are +handled by vector id in ``discovery_web.py``, as the engine handles them. The +whole-document cases disc-0020 and disc-0021 are not run (``CASES_NOT_RUN``): the +engine builds the document with its writer of the whole link table and compares the +bytes, a writer this package carries only part of. """ -import base64 import copy -import hashlib from .. import MEDIA_TYPE, PROFILE_URI, REL_BASE, SPEC_VERSION, WELLKNOWN_PATH from .. import discovery from .. import wellknown +from . import discovery_web from ._assert import checks, shown _OMITTABLE = ("agsc-bundle-hash", "agsc-bundle-version", "agsc-counts", "agsc-generated-at", "agsc-ledger-head", "agsc-spec-version", "digest") -def _check(document, level): - """(errors, findings) of the package's own checker over an in-memory document.""" +def _check(document, level, reader=SPEC_VERSION): + """(errors, findings) of the package's own checker over an in-memory document, + read by a reader of the specification version ``reader``.""" findings = [] - result = wellknown.check(wellknown.from_value(document), level, findings) + result = wellknown.check(wellknown.from_value(document), level, findings, + spec_version=reader) errors = [one for one in findings if one["severity"] == "error"] return errors, findings, result @@ -199,7 +205,9 @@ def _ledger_case(case, want): def _reader_case(case, want): - """One disc-0019 case: a received document read by a reader of a given version. + """One disc-0019 or disc-0023 case: a received document read by a reader of the + version the case states (``reader_version``), as the engine's handler passes it to + its reader. The case is about one unknown relation: of a newer MINOR it is the warning AGSC-E506 and nothing else, of another MAJOR the error AGSC-E209 (AGSC-00-21, @@ -208,12 +216,7 @@ def _reader_case(case, want): digest rule and AGSC-00-23 to a document of another MAJOR, which the case does not state.""" name = case["name"] - mine = SPEC_VERSION.split("-")[0].split(".")[:2] - reader = str(case["reader_version"]).split("-")[0].split(".")[:2] - if reader != mine: - return [(name + ":reader", False, "this package reads as %s, not %s" - % (SPEC_VERSION, case["reader_version"]))] - errors, findings, _ = _check(case["document"], case["level"]) + errors, findings, _ = _check(case["document"], case["level"], str(case["reader_version"])) out = [(name + ":valid", (errors == []) == want["valid"], shown(errors))] known = {"name", "valid"} if "findings" in want: @@ -227,43 +230,6 @@ def _reader_case(case, want): return out -def _digest(text): - return "sha-256=:%s:" % base64.b64encode(hashlib.sha256(text.encode("utf-8")).digest()).decode("ascii") - - -def _whole_case(case, want): - """One disc-0020 case: the whole document a publisher emits for the input. - - This package is a checker, not a publisher, so it checks the stated document: it - is valid at its Level, its anchor is the node's, and every ``digest`` it carries - is the SHA-256 of the file text the input gives for that route, with - ``agsc-bundle-hash`` the digest of ``graph.nq`` (AGSC-06-08, AGSC-04-15).""" - name = case["name"] - document = want["document"] - errors, _, _ = _check(document, case["level"]) - out = [(name + ":valid", errors == [], shown(errors))] - context = document["linkset"][0] - out.append((name + ":anchor", context.get("anchor") == case["base"].rstrip("/") + "/", - shown(context.get("anchor")))) - wrong = [] - for relation, targets in context.items(): - if not isinstance(targets, list): - continue - for target in targets: - route = target["href"][len(case["base"].rstrip("/")):] - if "digest" in target and target["digest"] != [_digest(case["files"].get(route, ""))]: - wrong.append(route) - out.append((name + ":digests", wrong == [], shown(wrong))) - bundle_hash = _describedby(document).get("agsc-bundle-hash") - if bundle_hash is not None: - out.append((name + ":bundle-hash", bundle_hash == [_digest(case["files"]["/graph.nq"])], - shown(bundle_hash))) - unknown = sorted(set(want) - {"document", "name"}) - if unknown: - out.append((name + ":unhandled", False, shown(unknown))) - return out - - def _robots_case(case, want): groups, findings = discovery.robots_groups(case["tdm_crawlers"], case["tdm_reservation"]) name = case["name"] @@ -284,6 +250,9 @@ def _robots_case(case, want): def run(vector): + web = discovery_web.run(vector) + if web is not None: + return web given = vector["input"] expected = vector["expected"] if "bundle" in given and "items" not in given: @@ -309,8 +278,6 @@ def have(name): handler = _reader_case elif "document" in case: handler = _document_case - elif "files" in case: - handler = _whole_case elif "ledger_head" in case: handler = _ledger_case else: @@ -440,7 +407,8 @@ def have(name): common = dict(clusters=given.get("clusters"), spec_version=given.get("spec_version", SPEC_VERSION), bundle_version=given.get("bundle_version", ""), - generated_at=given.get("generated_at", "")) + generated_at=given.get("generated_at", ""), + visibility=given.get("visibility")) short = discovery.llms_txt(given["bundle"], given["items"], **common) full = discovery.llms_full_txt(given["bundle"], given["items"], **common) if have("output"): diff --git a/src/agentic_system_core/areas/discovery_web.py b/src/agentic_system_core/areas/discovery_web.py new file mode 100644 index 0000000..fbe7a07 --- /dev/null +++ b/src/agentic_system_core/areas/discovery_web.py @@ -0,0 +1,198 @@ +"""The ``discovery`` cases of the web connection and of the 1.1 chunk facts. + +Each handler is the twin of the engine's handler of the same vector in +``tests/conformance/areas/_discovery-web.js``, and calls the module that gives the data +the case pins: + +* disc-0026 (AGSC-06-40) — the Signposting links of ``/`` as a set of {href, rel, type} + (``signposting.home_links``), and the checker's warning AGSC-E202 for a home page + whose ``Link`` header lacks the ``describedby`` link + (``wellknown_facts.home_link_findings``); +* disc-0027, withdrawn, and its successor disc-0037 (AGSC-06-41) — the Dataset block of + the home page, as a JSON value (``signposting.dataset_block``), and the DCAT 3 catalogue + block of the ``discovery.dcat`` switch (``signposting.catalog_block``); +* disc-0028, disc-0029 (AGSC-06-42) — ``/.well-known/ai-catalog.json`` and + ``/.well-known/ard.json``, as bytes, with their findings (``catalogue``); +* disc-0030, disc-0031, disc-0035, disc-0038 (AGSC-06-34, AGSC-06-07, AGSC-11-16) — the + agent card as bytes, or none and why, and whether the discovery document declares it + (``agentcard``); +* disc-0033, disc-0036 (AGSC-06-44, AGSC-11-16, AGSC-09-93 (b)) — this package's checker at + the case's Level over the document and the files it names, held as a build output: + valid, and the codes reported (``wellknown.from_build``). + +Every member of ``expected`` a handler does not read is a failure, so a case never +passes on an assertion nobody made. +""" + +from .. import agentcard, catalogue, signposting, wellknown, wellknown_facts +from ._assert import checks, shown + +#: The routes every disc-0026 node writes (the engine's handler lists the same). +_HOME_ROUTES = ("/index.html", "/.well-known/knowledge-linkset", "/graph.jsonld", "/graph.nq", + "/graph.ttl") + + +def _by_name(cases): + return dict((one["name"], one) for one in cases or []) + + +def _codes(found): + return [{"code": one["code"], "severity": one["severity"]} for one in found] + + +def _unknown(name, want, known): + unknown = sorted(set(want) - set(known) - {"name"}) + return [(name + ":unhandled", False, shown(unknown))] if unknown else [] + + +def _findings_match(expected, found): + """Every expected finding is met by one found (code and severity), and no more.""" + got = _codes(found) + missing = [one for one in expected if not any( + all(other.get(key) == value for key, value in one.items()) for other in got)] + return not missing and len(got) == len(expected), shown(got) + + +def _link_key(link): + return shown(link) + + +def _signposting(vector): + items = [] + wanted = _by_name(vector["expected"].get("cases")) + for given in vector["input"]["cases"]: + config = {"bundle": {} if "license_url" not in given else + {"license_url": given["license_url"]}, + "related": given.get("related"), "site": {"base": given["base"]}, + "visibility": given.get("visibility")} + routes = list(_HOME_ROUTES) + (["/chunks.jsonl"] if given.get("chunks_served") else []) \ + + (["/legal/index.html"] if given.get("legal_emitted") else []) + got = sorted(signposting.home_links(config, routes), key=_link_key) + want = wanted.get(given["name"], {}) + expected = sorted(want.get("links_as_set") or [], key=_link_key) + items.append((given["name"] + ":links", got == expected and "links_as_set" in want, + shown(got))) + items.extend(_unknown(given["name"], want, ["links_as_set"])) + validators = _by_name(vector["expected"].get("validator_cases")) + for given in vector["input"].get("validator_cases") or []: + want = validators.get(given["name"], {}) + found = wellknown_facts.home_link_findings(given["home_link_header"], + anchor="https://a.example/") + ok, detail = _findings_match(want.get("findings") or [], found) + items.append((given["name"] + ":findings", ok and "findings" in want, detail)) + items.extend(_unknown(given["name"], want, ["findings"])) + return items + + +def _dataset(vector): + items = [] + wanted = _by_name(vector["expected"]["cases"]) + for given in vector["input"]["cases"]: + config = {"bundle": given.get("bundle"), "discovery": given.get("discovery"), + "site": given.get("site"), "visibility": given.get("visibility")} + facts = (config, given["instant"], set(given["files_served"])) + named = {"description": given.get("description"), + "name": (given.get("site") or {}).get("title")} + block = signposting.dataset_block(*facts, **named) + want = wanted.get(given["name"], {}) + items.append((given["name"], "block" in want and block == want["block"], shown(block))) + if "catalog" in want: + catalog = signposting.catalog_block(*facts, **named) + items.append((given["name"] + ":catalog", catalog == want["catalog"], shown(catalog))) + items.extend(_unknown(given["name"], want, ["block", "catalog"])) + return items + + +def _catalogue(route): + def handler(vector): + items = [] + wanted = _by_name(vector["expected"]["cases"]) + for given in vector["input"]["cases"]: + config = {"bundle": {"id": given.get("bundle_id")}, + "discovery": {"ai_catalog": given.get("ai_catalog")}, + "site": given.get("site")} + files, found = catalogue.catalogue_files( + config, given["discovery_document_bytes"], card_bytes=given.get("card_bytes"), + description=given.get("description")) + want = wanted.get(given["name"], {}) + text = files.get(route) + items.append((given["name"] + ":file", "file" in want and text == want["file"], + shown(text))) + ok, detail = _findings_match(want.get("findings", []), found) + items.append((given["name"] + ":findings", ok, detail)) + items.extend(_unknown(given["name"], want, ["file", "findings"])) + return items + return handler + + +def _card(vector): + items = [] + wanted = _by_name(vector["expected"]["cases"]) + for given in vector["input"]["cases"]: + surfaces = given.get("surfaces") or [] + text = agentcard.card_bytes(surfaces, given.get("packs") or [], + (given.get("site") or {}).get("title"), + given.get("bundle_version"), given.get("spec_version"), + visibility=given.get("visibility"), + description=given.get("description")) + want = wanted.get(given["name"], {}) + if "file" in want or "declares_a2a_card" not in want: + items.append((given["name"] + ":file", "file" in want and text == want["file"], + shown(text))) + if "findings" in want: + ok, detail = _findings_match(want["findings"], agentcard.card_findings(surfaces)) + items.append((given["name"] + ":findings", ok, detail)) + if "declares_a2a_card" in want: + declared = any(one.get("surface") == "a2a-card" + for one in agentcard.served_declarations(surfaces)) + items.append((given["name"] + ":declares", declared == want["declares_a2a_card"], + shown(declared))) + items.extend(_unknown(given["name"], want, ["file", "findings", "declares_a2a_card"])) + return items + + +def _chunk_surface(vector): + items = [] + wanted = _by_name(vector["expected"]["cases"]) + for given in vector["input"]["cases"]: + findings = [] + wellknown.check(wellknown.from_build(given["document"], given["files"]), given["level"], + findings) + errors = [one for one in findings if one["severity"] == "error"] + codes = sorted(set(one["code"] for one in findings)) + want = wanted.get(given["name"], {}) + items.append((given["name"] + ":valid", (errors == []) == want.get("valid"), + shown(findings))) + items.append((given["name"] + ":codes", codes == want.get("codes_reported"), shown(codes))) + items.extend(_unknown(given["name"], want, ["valid", "codes_reported"])) + return items + + +#: vector id -> handler, as the engine's ``HANDLERS`` of ``_discovery-web.js``. +HANDLERS = { + "disc-0026": _signposting, + "disc-0027": _dataset, + "disc-0028": _catalogue(catalogue.AI_CATALOG_PATH), + "disc-0029": _catalogue(catalogue.ARD_PATH), + "disc-0030": _card, + "disc-0031": _card, + "disc-0033": _chunk_surface, + "disc-0035": _card, + "disc-0036": _chunk_surface, + "disc-0037": _dataset, + "disc-0038": _card, +} + + +def run(vector): + """The verdict of one web-connection case, or None when the id is not one of them.""" + handler = HANDLERS.get(vector.get("id")) + if handler is None: + return None + items = handler(vector) + unknown = sorted(set(vector["expected"]) - {"cases", "validator_cases"}) + if unknown: + items.append(("unhandled", False, "expected members not checked: %s" % shown(unknown))) + if not items: + items.append(("shape", False, "the case states no case this handler reads")) + return checks(items) diff --git a/src/agentic_system_core/areas/frontmatter_area.py b/src/agentic_system_core/areas/frontmatter_area.py index 1594f0c..4612e84 100644 --- a/src/agentic_system_core/areas/frontmatter_area.py +++ b/src/agentic_system_core/areas/frontmatter_area.py @@ -1,5 +1,6 @@ """Area ``frontmatter`` — spec/02: the YAML subset, failsafe scalars, the item -checks, length in code points, task state and adoption. +checks, length in code points, task state and adoption; from 1.1 the 64-level +nesting bound of AGSC-02-02 (fm-0021, fm-0026). Every member of ``expected`` is checked; an unknown member is a failure. """ @@ -40,10 +41,19 @@ def have(name): lines = [one.get("line") for one in errors] items.append(("line", lines == [expected["line"]], shown(lines))) if have("warnings"): - warnings = sorted(({"code": one["code"], "key": one.get("key")} + # Each warning is compared on the members the case states for warnings + # (fm-0006: code and key; fm-0021: code and severity), and the whole list + # must match: no warning the case does not state. + members = sorted(set(name for one in expected["warnings"] for name in one)) \ + or ["code"] + warnings = sorted((dict((name, one.get(name)) for name in members) for one in findings if one["severity"] == "warn"), - key=lambda one: (one["key"] or "", one["code"])) + key=lambda one: (one.get("key") or "", one["code"])) items.append(("warnings", warnings == expected["warnings"], shown(warnings))) + if have("warning_count"): + # fm-0026 (AGSC-02-02, the near miss of fm-0021): the number of warnings. + count = len([one for one in findings if one["severity"] == "warn"]) + items.append(("warning_count", count == expected["warning_count"], shown(count))) elif isinstance(given.get("frontmatter"), dict): data = given["frontmatter"] diff --git a/src/agentic_system_core/areas/graph_area.py b/src/agentic_system_core/areas/graph_area.py index 6969b33..fd3e86e 100644 --- a/src/agentic_system_core/areas/graph_area.py +++ b/src/agentic_system_core/areas/graph_area.py @@ -1,13 +1,19 @@ """Area ``graph`` — spec/05 and AGSC-04-15, AGSC-06-32. -Every member of ``expected`` is checked; a member this handler does not know is -a failure, so a vector can never pass on an assertion nobody made. +From 1.1 also the readings of the Link graph (AGSC-05-33, graph-0029), the ten +questions (AGSC-05-34, graph-0030 to graph-0039), the SKOS view (AGSC-05-36, +graph-0040) and the context address that does not follow the ontology version +(AGSC-05-09, graph-0043). Every member of ``expected`` is checked; a member this handler does not +know is a failure, so a vector can never pass on an assertion nobody made. """ +import re + from .. import context as context_module +from .. import derive, links, questions, skos from .. import graph as graph_module from ..jcs import canonicalize -from ..rdf import Literal, nquads_term, prefix_block, turtle_has_blank_node, turtle_term +from ..rdf import ASC, Literal, nquads_term, prefix_block, turtle_has_blank_node, turtle_term from ._assert import checks, shown @@ -40,6 +46,140 @@ def _export_blocks(markdown_text): return blocks +#: The engine's ``normaliseClause``: a leading subject IRI and a trailing ``;`` or ``.``. +_CLAUSE_SUBJECT = re.compile(r"^<[^>]*>\s+") +_CLAUSE_END = re.compile(r"\s*[;.]$") + + +def _clause_names(turtle): + """The first term of every Turtle clause outside the prefix block, as the engine's + ``clauses`` reads them: the predicate of a clause, after its subject.""" + names = [] + for line in turtle.split("\n"): + if line.strip() == "" or line.startswith("@prefix"): + continue + clause = _CLAUSE_END.sub("", _CLAUSE_SUBJECT.sub("", line.lstrip())).strip() + name = re.split(r"\s", clause)[0] + if name != "": + names.append(name) + return names + + +def _forbidden(entry, given, base, quads, ttl): + """One entry of ``expected.forbidden`` (graph-0018): a prose statement of a form + the rules exclude, checked by its own reading as the engine's ``forbiddenCheck`` + does. An entry no reading knows fails, so a new clause cannot be met by doing + nothing.""" + if entry.endswith("@en^^"): + return ("forbidden-lang-datatype", "@en^^" not in quads and "@en^^" not in ttl, + "a language-tagged literal carries a datatype") + if "^^xsd:string in Turtle" in entry: + return ("forbidden-xsd-string", "^^xsd:string" not in ttl, "^^xsd:string in Turtle") + if "status is not authored" in entry: + stripped = [dict((key, value) for key, value in item.items() if key != "status") + for item in given["items"]] + without = graph_module.to_nquads(stripped, base, given.get("bundle"), + given.get("attachment_bytes")) + return ("forbidden-status", ASC + "status" not in without, shown(without)) + if "ordered by prefixed name" in entry: + # AGSC-05-10(c): predicates sort by IRI code points; the case is chosen so the + # two orders differ. + names = _clause_names(ttl) + return ("forbidden-prefixed-order", names != sorted(names), + "the emitted order %s is also the prefixed-name order" % " ".join(names)) + return ("forbidden " + entry, False, "this handler does not implement that clause") + + +def _jsonld_files(given, expected, base): + """graph-0028 (AGSC-05-09, AGSC-06-02): graph.jsonld and each per-item file, whole, + compared after JCS; the per-item files are exactly one per item.""" + bundle, data, url = given.get("bundle"), given.get("attachment_bytes"), given.get("context_url") + whole = graph_module.to_jsonld(given["items"], base, bundle, data, context_url=url) + out = [("graph.jsonld", canonicalize(whole) == canonicalize(expected.get("graph_jsonld")), + canonicalize(whole))] + wanted = expected.get("per_item", {}) + slugs = sorted(item["slug"] for item in given["items"]) + out.append(("per-item files", slugs == sorted(wanted), shown(slugs))) + for item in given["items"]: + single = graph_module.to_jsonld([item], base, bundle, data, context_url=url) + one = canonicalize(graph_module.restrict_to(whole, single)) + out.append(("pages/%s.jsonld" % item["slug"], + item["slug"] in wanted and one == canonicalize(wanted[item["slug"]]), one)) + return out + + +#: graph-0029 states its readings over items with no base; the dataset it compares with +#: is written at this one (the engine's handler does the same). +_READINGS_BASE = "https://a.example/" + + +def _property_of_key(key): + """The RDF property a reading's key is written with, or None (``derivation-of``).""" + if key in graph_module.LINK_PROPERTIES: + return graph_module.LINK_PROPERTIES[key][0] + owner = [name for name, inverse in links.INVERSE.items() if inverse == key] + return graph_module.LINK_PROPERTIES[owner[0]][1] if owner else None + + +def _stored(readings, items): + """The transitive and closure readings that are a triple of the dataset (none may be).""" + triples = graph_module.dataset(items, _READINGS_BASE) + by_slug = dict((item["slug"], item) for item in items) + + def iri(slug): + return graph_module.IRI(graph_module.item_iri(_READINGS_BASE, by_slug[slug])) + return [one for one in readings + if one["because"][0]["rule"] in ("transitive", "closure") + and _property_of_key(one["key"]) is not None + and (iri(one["source"]), graph_module.IRI(_property_of_key(one["key"])), + iri(one["target"])) in triples] + + +def _readings(given, have, expected): + """graph-0029 (AGSC-05-33): the readings, in order; none is stored in the graph.""" + edges, _ = links.edges(given["items"]) + got = derive.readings(edges) + out = [] + if have("readings"): + out.append(("readings", canonicalize(got) == canonicalize(expected["readings"]), + canonicalize(got))) + if have("graph_files_unchanged"): + stored = _stored(got, given["items"]) + out.append(("graph-files-unchanged", + (stored == []) == expected["graph_files_unchanged"], shown(stored))) + return out + + +def _question(given, have, expected): + """graph-0030 to graph-0039 (AGSC-05-34): one question over the shared fixture.""" + got = questions.answer(given["question"], given["items"], subject=given.get("subject"), + selection=given.get("selection") or [], at=given.get("at")) + have("answer") # a case with no answer stated fails on the comparison below + return [("question %s" % given["question"], + canonicalize(got) == canonicalize(expected.get("answer")), canonicalize(got))] + + +def _context_address(given, have, expected): + """graph-0043 (AGSC-05-09): the Bundle written once per ontology version the case + names, each time with the persistent context address of a Level-0 node: every + document names the one ``CONTEXT_URL`` and all are byte-identical. This writer + reads no ontology version at all, which is the rule's point.""" + base = _base(given) + written = [graph_module.to_jsonld(given["items"], base, context_url=context_module.CONTEXT_URL) + for _ in given["ontology_versions"]] + urls = [one.get("@context") for one in written] + documents = [canonicalize(one) for one in written] + out = [] + if have("context_url"): + out.append(("context_url", bool(urls) and all(url == expected["context_url"] + for url in urls), shown(urls))) + if have("graph_jsonld_identical_across_ontology_versions"): + same = all(one == documents[0] for one in documents) + out.append(("identical", same == expected["graph_jsonld_identical_across_ontology_versions"], + "the documents differ across ontology versions")) + return out + + def run(vector): given = vector["input"] expected = vector["expected"] @@ -47,11 +187,6 @@ def run(vector): # graph-0027 and its kind: the real lint and build over a whole Bundle. return {"status": "not-run", "detail": "needs the real lint and build over a whole Bundle; not implemented by this package"} - if "graph_jsonld" in expected: - # graph-0028: the publisher's JSON-LD files, whole. This package compacts only for - # the context round trip of AGSC-06-32 and writes no graph.jsonld of its own. - return {"status": "not-run", - "detail": "needs the publisher's graph.jsonld writer; not implemented by this package"} items = [] handled = set() @@ -59,7 +194,16 @@ def have(name): handled.add(name) return name in expected - if isinstance(given.get("items"), list): + if isinstance(given.get("question"), int): + items.extend(_question(given, have, expected)) + + elif isinstance(given.get("ontology_versions"), list): + items.extend(_context_address(given, have, expected)) + + elif "readings" in expected: + items.extend(_readings(given, have, expected)) + + elif isinstance(given.get("items"), list): base = _base(given) bundle = given.get("bundle") data = given.get("attachment_bytes") @@ -73,6 +217,8 @@ def have(name): if have("prefix_block_is_constant"): items.append(("prefix-block", ttl.startswith(prefix_block() + "\n") == expected["prefix_block_is_constant"], shown(ttl[:400]))) + if any([have("graph_jsonld"), have("per_item")]): + items.extend(_jsonld_files(given, expected, base)) if have("turtle_never_contains"): items.append(("turtle-never-contains", expected["turtle_never_contains"] not in ttl, expected["turtle_never_contains"])) @@ -85,8 +231,7 @@ def have(name): count = sum(1 for line in lines if "_:" in line) items.append(("blank-nodes", count == expected["blank_nodes"], shown(count))) if have("forbidden"): - present = [one for one in expected["forbidden"] if one in ttl or one in quads] - items.append(("forbidden", present == [], shown(present))) + items.extend(_forbidden(one, given, base, quads, ttl) for one in expected["forbidden"]) if have("contains"): missing = [one for one in expected["contains"] if one not in lines] items.append(("contains", missing == [], shown(missing))) @@ -103,6 +248,11 @@ def have(name): inverse = any((b, a) in pairs for a, b in pairs) items.append(("inverse", inverse == expected["inverse_materialised"], shown(inverse))) + if have("skos"): + # graph-0040 (AGSC-05-36): the SKOS view, the whole file. + view = skos.skos_view(graph_module.dataset(given["items"], base, bundle, data), + skos.scheme_record(given)) + items.append(("skos", view == expected["skos"], shown(view))) if have("whole_file_asserted"): items.append(("whole-file", expected["whole_file_asserted"] is False, "a whole-file assertion needs `nquads`")) diff --git a/src/agentic_system_core/areas/links_area.py b/src/agentic_system_core/areas/links_area.py index 4151831..feeca8e 100644 --- a/src/agentic_system_core/areas/links_area.py +++ b/src/agentic_system_core/areas/links_area.py @@ -3,7 +3,8 @@ Every member of ``expected`` is checked; an unknown member is a failure. ``warnings`` is the whole list of warnings the Link checks report, each -``{code, slug}`` in slug order: at 1.0 these are the orphans of AGSC-03-10. +``{code, slug}`` in slug order: the orphans of AGSC-03-10 (links-0009) and, from 1.1, +the four warnings of AGSC-03-23 to 03-26 (links-0010 to links-0017). """ from .. import links @@ -76,7 +77,10 @@ def have(name): got = first[0].get(member) if first else None items.append((member, got == expected[member], shown(got))) if have("warnings"): - found = orphans(given_items) + found = sorted(orphans(given_items) + [ + {"code": one["code"], "slug": one["slug"]} + for one in links.link_warnings(given_items)], + key=lambda one: (one["slug"], one["code"])) items.append(("warnings", found == expected["warnings"], shown(found))) if "resolved" in expected or "unresolved" in expected: report = links.body_link_report(given_items) diff --git a/src/agentic_system_core/areas/slug_area.py b/src/agentic_system_core/areas/slug_area.py index d608140..c8712a1 100644 --- a/src/agentic_system_core/areas/slug_area.py +++ b/src/agentic_system_core/areas/slug_area.py @@ -6,10 +6,32 @@ strings and the verdicts, or a list of file paths and the collision code. """ +import re + from .. import frontmatter as frontmatter_module from .. import slug as slug_module from ._assert import checks, shown +#: The regular-expression features outside the subset RE2, Go ``regexp``, Rust +#: ``regex`` and PCRE2 share (the porting notes of the engine's +#: ``tests/vectors/README.md``), each with the form that gives it away in a pattern's +#: source, in the engine's order and under its names (``tests/conformance/areas/slug.js``). +NON_PORTABLE_FEATURES = ( + ("lookahead", re.compile(r"\(\?[=!]")), + ("lookbehind", re.compile(r"\(\?<[=!]")), + ("backreference", re.compile(r"\\[1-9]|\\k<")), + ("named group", re.compile(r"\(\?<[A-Za-z]")), + ("atomic group", re.compile(r"\(\?>")), + ("possessive quantifier", re.compile(r"[*+?}]\+")), + ("unicode escape", re.compile(r"\\u")), + ("property escape", re.compile(r"\\[pP]\{")), +) + + +def features_used(source): + """The non-portable features one pattern source uses, by name (slug-0006).""" + return [name for name, form in NON_PORTABLE_FEATURES if form.search(source)] + def run(vector): given = vector["input"] @@ -30,6 +52,10 @@ def run(vector): used = "(?=" in slug_module.SLUG_PATTERN or "(?!" in slug_module.SLUG_PATTERN items.append(("lookahead", used is expected["lookahead"], slug_module.SLUG_PATTERN)) + if isinstance(expected.get("engine_features_used"), list): + found = features_used(slug_module.SLUG_PATTERN) + items.append(("engine-features-used", found == expected["engine_features_used"], + shown(found))) return checks(items) # Uniqueness over a list of paths. diff --git a/src/agentic_system_core/catalogue.py b/src/agentic_system_core/catalogue.py new file mode 100644 index 0000000..b4f94bd --- /dev/null +++ b/src/agentic_system_core/catalogue.py @@ -0,0 +1,113 @@ +"""The two AI-catalogue files a node may write, opt-in (AGSC-06-42). + +The twin of the engine's ``src/distribution/ai-catalog.js``: ``/.well-known/ard.json`` +and ``/.well-known/ai-catalog.json``, written only when ``discovery.ai_catalog`` is +``true``, with one entry for the discovery document and, when the node publishes one, +one for the agent card. Each entry carries the SHA-256 of the exact bytes served at +its ``url``, and its identifier is a ``urn:air`` name built from the host of +``site.base``, which must be a fully qualified domain name (vectors disc-0028, +disc-0029). + +Both formats are proposals (the Agentic Resource Discovery manifest 0.91 and the AI +Catalog draft ``specVersion`` "1.0"); no library on PyPI writes either, as none does on +npm, so the entries are plain data and the bytes are this package's JCS writer. +Pure: data in, text out. Standard library only. +""" + +import hashlib +import re +from urllib.parse import urlsplit + +from . import MEDIA_TYPE, PROFILE_URI, WELLKNOWN_PATH +from .diagnostics import finding +from .jcs import canonicalize +from .signposting import href + +ARD_PATH = "/.well-known/ard.json" +AI_CATALOG_PATH = "/.well-known/ai-catalog.json" +#: AGSC-06-42: the media types the two files are served with. +ARD_MEDIA_TYPE = "application/json" +AI_CATALOG_MEDIA_TYPE = "application/ai-catalog+json" +#: AGSC-06-42: the ``specVersion`` of the AI Catalog draft. +AI_CATALOG_SPEC_VERSION = "1.0" +#: AGSC-06-34: the agent card's route and media type (the engine's ``surfaces.js``). +A2A_CARD_ROUTE = "/.well-known/agent-card.json" +A2A_CARD_MEDIA_TYPE = "application/a2a-agent-card+json" + +#: WHATWG URL: a host whose last label is a number is an IPv4 address (decimal, octal or +#: hexadecimal parts), which the engine's URL parser writes as four decimals. +_NUMERIC_LABEL = re.compile(r"^(?:\d+|0[xX][0-9A-Fa-f]*)$") + + +def hex_digest(text): + """AGSC-06-42: ``sha256:`` and the lowercase hexadecimal SHA-256 of the served bytes.""" + return "sha256:" + hashlib.sha256(str(text).encode("utf-8")).hexdigest() + + +def domain_name(base): + """AGSC-06-42: the host of ``site.base``, lower case and without a port, when it is + a fully qualified domain name (at least one ``.``, not an IP literal, not under + ``.local``); else None.""" + try: + parts = urlsplit(str(base)) + host = (parts.hostname or "").lower() + except ValueError: + return None + if parts.scheme == "" or host == "" or "[" in parts.netloc: + return None + bare = host[:-1] if host.endswith(".") else host + if "." not in bare or _NUMERIC_LABEL.match(bare.rsplit(".", 1)[-1]) or bare.endswith(".local"): + return None + return host + + +def _entry(fields, digest_member): + out = {"displayName": fields["displayName"], "identifier": fields["identifier"], + "type": fields["type"], "url": fields["url"]} + description = fields.get("description") + if isinstance(description, str) and description != "": + out["description"] = description + # AGSC-06-42: `digest` in the AI Catalog draft's form; ARD names it in `metadata`. + if digest_member == "digest": + out["digest"] = fields["digest"] + else: + out["metadata"] = {"digest": fields["digest"]} + return out + + +def _refused(code, message): + return {}, [finding(code, "agsc.config.json", message)] + + +def catalogue_files(config, discovery_bytes, card_bytes=None, description=None): + """The two catalogue files of AGSC-06-42 as (route -> text, findings): none when the + switch is off, and none when a finding refuses them. ``discovery_bytes`` and + ``card_bytes`` are the exact texts served at the two entries' ``url``.""" + if (config.get("discovery") or {}).get("ai_catalog") is not True: + return {}, [] + site = config.get("site") or {} + host = domain_name(site.get("base")) + identifier = (config.get("bundle") or {}).get("id") + if host is None: + return _refused("AGSC-E209", "discovery.ai_catalog is true, but the host of site.base %s " + "is not a fully qualified domain name, which a urn:air " + "identifier needs; no catalogue file is written (AGSC-06-42)" + % canonicalize(str(site.get("base")))) + if not isinstance(identifier, str) or identifier == "": + return _refused("AGSC-E202", "discovery.ai_catalog is true, but bundle.id is not set; no " + "catalogue file is written (AGSC-06-42)") + common = {"description": description, "displayName": site.get("title")} + listed = [dict(common, digest=hex_digest(discovery_bytes), + identifier="urn:air:%s:knowledge:%s" % (host, identifier), + type='%s; profile="%s"' % (MEDIA_TYPE, PROFILE_URI), + url=href(site.get("base"), WELLKNOWN_PATH))] + if isinstance(card_bytes, str): + listed.append(dict(common, digest=hex_digest(card_bytes), + identifier="urn:air:%s:a2a:%s" % (host, identifier), + type=A2A_CARD_MEDIA_TYPE, url=href(site.get("base"), A2A_CARD_ROUTE))) + listed.sort(key=lambda one: one["identifier"]) # code-point order, as the engine sorts + # AGSC-06-42: `representativeQueries` is never written; it would have to be invented. + ard = canonicalize({"entries": [_entry(one, "metadata") for one in listed]}) + "\n" + catalogue = canonicalize({"entries": [_entry(one, "digest") for one in listed], + "specVersion": AI_CATALOG_SPEC_VERSION}) + "\n" + return {ARD_PATH: ard, AI_CATALOG_PATH: catalogue}, [] diff --git a/src/agentic_system_core/cli.py b/src/agentic_system_core/cli.py index 68ca3b4..84dbab2 100644 --- a/src/agentic_system_core/cli.py +++ b/src/agentic_system_core/cli.py @@ -3,7 +3,7 @@ Three verbs run here, in Python, with no Node and no network: agsc validate-wellknown [--level 0|1|2|3] [--peer ] [--json] [--dev] - [--allow-network] + [--allow-network] [--max-requests <1..2000>] agsc validate-vectors [--json] [--quiet] [--spec ] [--root ] agsc run-vectors [--json] [--level 0|1|2|3] [--pending ] @@ -25,7 +25,7 @@ from . import SPEC_VERSION, __version__ from .diagnostics import EXIT_PASS, EXIT_USAGE, envelope, exit_code, finding from .jcs import canonicalize_raw -from .net import fetch +from .net import MAX_REQUESTS, MAX_REQUESTS_RANGE, fetch #: The npm package that carries the engine and every other verb. NPM_PACKAGE = "agentic-system-core" @@ -41,9 +41,10 @@ Runs natively, with no Node and no network: validate-wellknown [--level 0|1|2|3] [--peer ] [--json] [--dev] - [--allow-network] + [--allow-network] [--max-requests <1..2000>] Check one discovery document served at /.well-known/knowledge-linkset. - A file is read always; a URL is read only with --allow-network. + A file is read always; a URL is read only with --allow-network, in at most + --max-requests requests (default 500, redirects counted). validate-vectors [--json] [--quiet] [--spec ] [--root ] Check a conformance-vector set against the file-format rules. run-vectors [--json] [--level 0|1|2|3] [--pending ] @@ -83,10 +84,21 @@ def _usage_envelope(code, message, as_json, out, err, verb): return EXIT_USAGE +def _max_requests(value): + """The request budget a ``--max-requests`` value names (AGSC-11-06), or None when it + is not a whole number in the range: one to five digits, as the engine reads it.""" + if value is None or not (1 <= len(value) <= 5 and value.isascii() and value.isdigit()): + return None + number = int(value) + low, high = MAX_REQUESTS_RANGE + return number if low <= number <= high else None + + def run_validate_wellknown(argv, out, err): """The discovery-file checker.""" as_json = "--json" in argv - options = {"dev": False, "level": 0, "peer": None, "target": None, "allow_network": False} + options = {"dev": False, "level": 0, "peer": None, "target": None, "allow_network": False, + "max_requests": MAX_REQUESTS} index = 0 while index < len(argv): argument = argv[index] @@ -97,6 +109,14 @@ def run_validate_wellknown(argv, out, err): options["dev"] = True elif argument == "--allow-network": options["allow_network"] = True + elif argument == "--max-requests": + value = _max_requests(argv[index] if index < len(argv) else None) + index += 1 + if value is None: + return _usage_envelope("AGSC-E003", "--max-requests needs a whole number from " + "%d to %d" % MAX_REQUESTS_RANGE, + as_json, out, err, "validate-wellknown") + options["max_requests"] = value elif argument == "--level": value = argv[index] if index < len(argv) else None index += 1 @@ -129,7 +149,8 @@ def run_validate_wellknown(argv, out, err): from .wellknown import validate result, reads = validate( options["target"], level=options["level"], peer=options["peer"], - dev=options["dev"], allow_network=options["allow_network"], fetcher=fetch) + dev=options["dev"], allow_network=options["allow_network"], fetcher=fetch, + max_requests=options["max_requests"]) line = ("validate-wellknown %s (level %d): %d input file(s) read, %d error(s), " "%d warning(s)\n" % (result["status"], options["level"], reads, result["counts"]["error"], result["counts"]["warn"])) @@ -172,9 +193,8 @@ def run_validate_vectors(argv, out, err): _write(err, "validate-vectors: a vector directory is required; this package ships no " "vector set of its own (AGSC-E003)\n") return EXIT_USAGE - if not os.path.isdir(directory): - _write(err, "validate-vectors: no such directory: %s (AGSC-E901)\n" % directory) - return EXIT_USAGE + # A missing folder is an AGSC-E901 finding in the envelope, exit 1 (AGSC-09-90), not + # a usage fault: AGSC-09-08 keeps exit 2 for an unknown verb, flag or a missing argument. result, count, empty = validate(directory, spec=spec, root=root) if as_json: _write(out, canonicalize_raw(result) + "\n") diff --git a/src/agentic_system_core/context.py b/src/agentic_system_core/context.py index 8999cc2..2efec38 100644 --- a/src/agentic_system_core/context.py +++ b/src/agentic_system_core/context.py @@ -15,19 +15,42 @@ context can contain (string-valued, typed, ``@id``-typed and untyped terms, with language-tagged values). This is not a JSON-LD processor (AGSC-05-11); it is the part of one that this profile's own documents exercise. + +The context a node publishes at ``/ns/context.jsonld`` ships as +``data/context.jsonld``: the bytes the engine's ``tools/gen-ns`` derives from its +vocabulary file, copied by the command in docs/MAINTAINING.md and compared with +the engine by the suite. ``graph.py`` compacts ``graph.jsonld`` with it. """ import json +import os from .jcs import canonicalize from .rdf import (ASC, DCTERMS, IRI, PREFIXES, PROV, RDF_TYPE, RDFS, SCHEMA, SKOS, XSD, Literal) -#: AGSC-05-09: the specification's persistent versioned context URL. -ONTOLOGY_VERSION = "1.0.0" -CONTEXT_URL = "https://w3id.org/agentic-system-core/ns/%s/context.jsonld" % ONTOLOGY_VERSION +#: AGSC-05-09 (amended for 1.1): the version in the persistent context address, a +#: constant ``1.0.0`` at every version 1.x, never the ontology version of AGSC-05-25, so +#: raising the ontology version changes no byte of any ``graph.jsonld`` (graph-0043; the +#: engine's ``CONTEXT_VERSION`` of ``src/knowledge/jsonld.js``). +CONTEXT_VERSION = "1.0.0" +#: The 1.0 name of ``CONTEXT_VERSION``, kept so that 1.0 code still imports it; deprecated. +ONTOLOGY_VERSION = CONTEXT_VERSION +CONTEXT_URL = "https://w3id.org/agentic-system-core/ns/%s/context.jsonld" % CONTEXT_VERSION _NAMESPACES = dict(PREFIXES) +_PUBLISHED = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "context.jsonld") + + +def published_bytes(): + """The bytes of the published context, ``/ns/context.jsonld`` (AGSC-06-32).""" + with open(_PUBLISHED, "rb") as handle: + return handle.read() + + +def published(): + """The published context as a document ``{"@context": {...}}``.""" + return json.loads(published_bytes().decode("utf-8")) #: External properties a rule of spec/05, 06 or 11 emits, with the @type the #: emitting rule fixes (None: language-tagged, no @type). @@ -234,6 +257,6 @@ def sample_triples(context): return triples -__all__ = ["CONTEXT_URL", "EXTERNAL_PROPERTIES", "build", "compact", "expand", - "roundtrip_bytes", "sample_triples", "term_names", "ASC", "DCTERMS", "PROV", - "RDFS", "SCHEMA", "SKOS"] +__all__ = ["CONTEXT_URL", "EXTERNAL_PROPERTIES", "build", "compact", "expand", "published", + "published_bytes", "roundtrip_bytes", "sample_triples", "term_names", "ASC", + "DCTERMS", "PROV", "RDFS", "SCHEMA", "SKOS"] diff --git a/src/agentic_system_core/data/context.jsonld b/src/agentic_system_core/data/context.jsonld new file mode 100644 index 0000000..45f8f62 --- /dev/null +++ b/src/agentic_system_core/data/context.jsonld @@ -0,0 +1 @@ +{"@context":{"@protected":true,"@version":1.1,"Attachment":{"@id":"asc:Attachment"},"Bundle":{"@id":"asc:Bundle"},"Cluster":{"@id":"asc:Cluster"},"Concept":{"@id":"asc:Concept"},"Episode":{"@id":"asc:Episode"},"Gate":{"@id":"asc:Gate"},"Harness":{"@id":"asc:Harness"},"Lesson":{"@id":"asc:Lesson"},"Procedure":{"@id":"asc:Procedure"},"Proposal":{"@id":"asc:Proposal"},"Review":{"@id":"asc:Review"},"Source":{"@id":"asc:Source"},"altLabel":{"@id":"skos:altLabel"},"asc":"https://w3id.org/agentic-system-core/ns#","blockedBy":{"@id":"asc:blockedBy","@type":"@id"},"blocks":{"@id":"asc:blocks","@type":"@id"},"broader":{"@id":"skos:broader","@type":"@id"},"consumes":{"@id":"asc:consumes","@type":"http://www.w3.org/2001/XMLSchema#string"},"contradicts":{"@id":"asc:contradicts","@type":"@id"},"coveredBy":{"@id":"asc:coveredBy","@type":"@id"},"covers":{"@id":"asc:covers","@type":"@id"},"created":{"@id":"dcterms:created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"creator":{"@id":"dcterms:creator"},"date":{"@id":"dcterms:date"},"dcterms":"http://purl.org/dc/terms/","dcterms:license":{"@id":"dcterms:license"},"dcterms:source":{"@id":"dcterms:source"},"decidedBy":{"@id":"asc:decidedBy","@type":"@id"},"decides":{"@id":"asc:decides","@type":"@id"},"definition":{"@id":"skos:definition"},"excludes":{"@id":"asc:excludes","@type":"@id"},"format":{"@id":"dcterms:format"},"generatedAt":{"@id":"asc:generatedAt","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"generatedBy":{"@id":"asc:generatedBy","@type":"http://www.w3.org/2001/XMLSchema#string"},"grade":{"@id":"asc:grade","@type":"http://www.w3.org/2001/XMLSchema#string"},"hasAttachment":{"@id":"asc:hasAttachment","@type":"@id"},"implementedBy":{"@id":"asc:implementedBy","@type":"@id"},"implements":{"@id":"asc:implements","@type":"@id"},"inScheme":{"@id":"skos:inScheme","@type":"@id"},"isReplacedBy":{"@id":"dcterms:isReplacedBy","@type":"@id"},"isRequiredBy":{"@id":"dcterms:isRequiredBy","@type":"@id"},"isVerifiedBy":{"@id":"asc:isVerifiedBy","@type":"@id"},"kind":{"@id":"asc:kind","@type":"http://www.w3.org/2001/XMLSchema#string"},"level":{"@id":"asc:level","@type":"http://www.w3.org/2001/XMLSchema#string"},"member":{"@id":"skos:member","@type":"@id"},"mentions":{"@id":"asc:mentions","@type":"@id"},"model":{"@id":"asc:model","@type":"http://www.w3.org/2001/XMLSchema#string"},"modified":{"@id":"dcterms:modified","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"narrower":{"@id":"skos:narrower","@type":"@id"},"operator":{"@id":"asc:operator","@type":"http://www.w3.org/2001/XMLSchema#string"},"origin":{"@id":"asc:origin","@type":"http://www.w3.org/2001/XMLSchema#string"},"outcome":{"@id":"asc:outcome","@type":"http://www.w3.org/2001/XMLSchema#string"},"peerOrigin":{"@id":"asc:peerOrigin","@type":"@id"},"prefLabel":{"@id":"skos:prefLabel"},"produces":{"@id":"asc:produces","@type":"http://www.w3.org/2001/XMLSchema#string"},"prov":"http://www.w3.org/ns/prov#","rdfs":"http://www.w3.org/2000/01/rdf-schema#","related":{"@id":"skos:related","@type":"@id"},"replaces":{"@id":"dcterms:replaces","@type":"@id"},"requires":{"@id":"dcterms:requires","@type":"@id"},"retiredAt":{"@id":"asc:retiredAt","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"review":{"@id":"asc:review","@type":"@id"},"schema":"https://schema.org/","schema:license":{"@id":"schema:license"},"seeAlso":{"@id":"rdfs:seeAlso","@type":"@id"},"severity":{"@id":"asc:severity","@type":"http://www.w3.org/2001/XMLSchema#string"},"sha256":{"@id":"asc:sha256","@type":"http://www.w3.org/2001/XMLSchema#string"},"skos":"http://www.w3.org/2004/02/skos/core#","source":{"@id":"asc:source","@type":"@id"},"specVersion":{"@id":"asc:specVersion","@type":"http://www.w3.org/2001/XMLSchema#string"},"staleAfter":{"@id":"asc:staleAfter","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"status":{"@id":"asc:status","@type":"http://www.w3.org/2001/XMLSchema#string"},"taskState":{"@id":"asc:taskState","@type":"http://www.w3.org/2001/XMLSchema#string"},"title":{"@id":"dcterms:title"},"usageInfo":{"@id":"schema:usageInfo"},"usedBy":{"@id":"asc:usedBy","@type":"@id"},"uses":{"@id":"asc:uses","@type":"@id"},"verifiedAt":{"@id":"asc:verifiedAt","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"verifiedBy":{"@id":"asc:verifiedBy","@type":"http://www.w3.org/2001/XMLSchema#string"},"verifiedOn":{"@id":"asc:verifiedOn","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"verifies":{"@id":"asc:verifies","@type":"@id"},"wasDerivedFrom":{"@id":"prov:wasDerivedFrom","@type":"@id"},"xsd":"http://www.w3.org/2001/XMLSchema#"}} diff --git a/src/agentic_system_core/data/relations.json b/src/agentic_system_core/data/relations.json new file mode 100644 index 0000000..ac5598d --- /dev/null +++ b/src/agentic_system_core/data/relations.json @@ -0,0 +1,225 @@ +{ + "relations": [ + { + "key": "related", + "inverse": "related", + "symmetric": true, + "property": "skos:related", + "combiner": "advisory", + "transitive": false, + "selfLink": "warning", + "targets": { + "any": true, + "noCluster": true + }, + "meaning": "The two items are connected in meaning, and neither depends on the other." + }, + { + "key": "broader", + "inverse": "narrower", + "symmetric": false, + "property": "skos:broader", + "inverseProperty": "skos:narrower", + "combiner": "none", + "transitive": true, + "selfLink": "cycle", + "targets": { + "sameFamily": true + }, + "meaning": "The target is a wider subject that this item falls under." + }, + { + "key": "narrower", + "inverse": "broader", + "symmetric": false, + "property": "skos:narrower", + "inverseProperty": "skos:broader", + "combiner": "none", + "transitive": true, + "selfLink": "cycle", + "targets": { + "sameFamily": true + }, + "meaning": "The target is a more specific subject that falls under this item." + }, + { + "key": "uses", + "inverse": "used-by", + "symmetric": false, + "property": "asc:uses", + "inverseProperty": "asc:usedBy", + "combiner": "soft", + "transitive": false, + "selfLink": "warning", + "targets": { + "any": true + }, + "meaning": "This item draws on the target and can still be used when the target is absent." + }, + { + "key": "requires", + "inverse": "required-by", + "symmetric": false, + "property": "dcterms:requires", + "inverseProperty": "dcterms:isRequiredBy", + "combiner": "hard", + "transitive": true, + "selfLink": "cycle", + "targets": { + "any": true + }, + "meaning": "This item cannot be used without the target, so choosing this item also takes the target." + }, + { + "key": "excludes", + "inverse": "excludes", + "symmetric": true, + "property": "asc:excludes", + "combiner": "mutex", + "transitive": false, + "selfLink": "warning", + "targets": { + "any": true + }, + "meaning": "This item and the target cannot be used together." + }, + { + "key": "derived-from", + "inverse": "derivation-of", + "symmetric": false, + "property": "prov:wasDerivedFrom", + "combiner": "none", + "transitive": true, + "selfLink": "warning", + "targets": { + "any": true, + "lessonTarget": { + "type": "episode" + } + }, + "meaning": "This item was produced from the target, which is its origin." + }, + { + "key": "contradicts", + "inverse": "contradicts", + "symmetric": true, + "property": "asc:contradicts", + "combiner": "warn-both", + "transitive": false, + "selfLink": "warning", + "targets": { + "any": true + }, + "meaning": "This item and the target make claims that cannot both be true." + }, + { + "key": "supersedes", + "inverse": "superseded-by", + "symmetric": false, + "property": "dcterms:replaces", + "inverseProperty": "dcterms:isReplacedBy", + "combiner": "hide-superseded", + "transitive": true, + "selfLink": "warning", + "targets": { + "sameType": true + }, + "meaning": "This item replaces the target, which stays published but is no longer the one to use." + }, + { + "key": "implements", + "inverse": "implemented-by", + "symmetric": false, + "property": "asc:implements", + "inverseProperty": "asc:implementedBy", + "combiner": "none", + "transitive": false, + "selfLink": "warning", + "targets": { + "type": "concept", + "kinds": [ + "spec", + "pattern", + "architecture" + ] + }, + "meaning": "This item puts the target into practice, as code or a procedure puts a specification into practice." + }, + { + "key": "verifies", + "inverse": "verified-by", + "symmetric": false, + "property": "asc:verifies", + "inverseProperty": "asc:isVerifiedBy", + "combiner": "none", + "transitive": false, + "selfLink": "warning", + "targets": { + "oneOf": [ + { + "type": "concept", + "kinds": [ + "spec", + "task" + ] + }, + { + "type": "procedure" + }, + { + "type": "gate" + } + ] + }, + "meaning": "This item checks that the target holds." + }, + { + "key": "covers", + "inverse": "covered-by", + "symmetric": false, + "property": "asc:covers", + "inverseProperty": "asc:coveredBy", + "combiner": "none", + "transitive": false, + "selfLink": "warning", + "targets": { + "any": true + }, + "meaning": "This item covers the target, as a test or a document covers a requirement." + }, + { + "key": "blocked-by", + "inverse": "blocks", + "symmetric": false, + "property": "asc:blockedBy", + "inverseProperty": "asc:blocks", + "combiner": "none", + "transitive": true, + "selfLink": "warning", + "targets": { + "type": "concept", + "kinds": [ + "task" + ] + }, + "meaning": "This item cannot go ahead until the target is resolved." + }, + { + "key": "decided-by", + "inverse": "decides", + "symmetric": false, + "property": "asc:decidedBy", + "inverseProperty": "asc:decides", + "combiner": "none", + "transitive": false, + "selfLink": "warning", + "targets": { + "type": "concept", + "kinds": [ + "decision" + ] + }, + "meaning": "The target is the decision record that settled this item." + } + ] +} diff --git a/src/agentic_system_core/data/spec-index.json b/src/agentic_system_core/data/spec-index.json index c69d004..bad8154 100644 --- a/src/agentic_system_core/data/spec-index.json +++ b/src/agentic_system_core/data/spec-index.json @@ -1 +1 @@ -{"error_codes": ["AGSC-E001", "AGSC-E002", "AGSC-E003", "AGSC-E004", "AGSC-E101", "AGSC-E102", "AGSC-E103", "AGSC-E104", "AGSC-E105", "AGSC-E106", "AGSC-E107", "AGSC-E108", "AGSC-E109", "AGSC-E201", "AGSC-E202", "AGSC-E203", "AGSC-E204", "AGSC-E205", "AGSC-E206", "AGSC-E207", "AGSC-E208", "AGSC-E209", "AGSC-E210", "AGSC-E211", "AGSC-E212", "AGSC-E213", "AGSC-E301", "AGSC-E302", "AGSC-E303", "AGSC-E304", "AGSC-E305", "AGSC-E306", "AGSC-E307", "AGSC-E308", "AGSC-E309", "AGSC-E310", "AGSC-E311", "AGSC-E312", "AGSC-E401", "AGSC-E402", "AGSC-E403", "AGSC-E404", "AGSC-E405", "AGSC-E406", "AGSC-E407", "AGSC-E408", "AGSC-E409", "AGSC-E410", "AGSC-E411", "AGSC-E412", "AGSC-E413", "AGSC-E414", "AGSC-E415", "AGSC-E416", "AGSC-E501", "AGSC-E502", "AGSC-E503", "AGSC-E504", "AGSC-E505", "AGSC-E506", "AGSC-E507", "AGSC-E508", "AGSC-E509", "AGSC-E510", "AGSC-E511", "AGSC-E601", "AGSC-E602", "AGSC-E603", "AGSC-E604", "AGSC-E605", "AGSC-E606", "AGSC-E607", "AGSC-E701", "AGSC-E702", "AGSC-E703", "AGSC-E704", "AGSC-E705", "AGSC-E706", "AGSC-E707", "AGSC-E801", "AGSC-E802", "AGSC-E803", "AGSC-E804", "AGSC-E805", "AGSC-E901", "AGSC-E902", "AGSC-E903", "AGSC-E904", "AGSC-E905", "AGSC-E906", "AGSC-E907"], "rule_ids": ["AGSC-00-01", "AGSC-00-02", "AGSC-00-03", "AGSC-00-04", "AGSC-00-05", "AGSC-00-06", "AGSC-00-07", "AGSC-00-08", "AGSC-00-09", "AGSC-00-10", "AGSC-00-11", "AGSC-00-12", "AGSC-00-13", "AGSC-00-14", "AGSC-00-15", "AGSC-00-16", "AGSC-00-17", "AGSC-00-18", "AGSC-00-19", "AGSC-00-20", "AGSC-00-21", "AGSC-00-22", "AGSC-00-23", "AGSC-00-24", "AGSC-00-25", "AGSC-01-01", "AGSC-01-02", "AGSC-01-03", "AGSC-01-04", "AGSC-01-05", "AGSC-01-06", "AGSC-01-07", "AGSC-01-08", "AGSC-01-09", "AGSC-01-10", "AGSC-01-11", "AGSC-01-12", "AGSC-01-13", "AGSC-01-13a", "AGSC-01-14", "AGSC-01-15", "AGSC-01-16", "AGSC-01-17", "AGSC-01-18", "AGSC-01-19", "AGSC-01-20", "AGSC-01-21", "AGSC-01-22", "AGSC-01-23", "AGSC-01-24", "AGSC-01-25", "AGSC-01-26", "AGSC-01-26a", "AGSC-01-27", "AGSC-01-28", "AGSC-01-29", "AGSC-01-30", "AGSC-01-31", "AGSC-01-32", "AGSC-01-33", "AGSC-01-34", "AGSC-01-35", "AGSC-01-36", "AGSC-01-37", "AGSC-01-38", "AGSC-02-01", "AGSC-02-02", "AGSC-02-03", "AGSC-02-04", "AGSC-02-05", "AGSC-02-05a", "AGSC-02-06", "AGSC-02-07", "AGSC-02-08", "AGSC-02-09", "AGSC-02-10", "AGSC-02-11", "AGSC-02-12", "AGSC-02-13", "AGSC-02-14", "AGSC-02-15", "AGSC-02-16", "AGSC-02-17", "AGSC-02-18", "AGSC-02-19", "AGSC-02-20", "AGSC-02-21", "AGSC-02-22", "AGSC-02-23", "AGSC-02-24", "AGSC-02-90", "AGSC-02-91", "AGSC-02-92", "AGSC-02-93", "AGSC-02-94", "AGSC-02-95", "AGSC-02-96", "AGSC-02-97", "AGSC-02-98", "AGSC-02-99", "AGSC-03-01", "AGSC-03-02", "AGSC-03-03", "AGSC-03-04", "AGSC-03-05", "AGSC-03-06", "AGSC-03-07", "AGSC-03-08", "AGSC-03-09", "AGSC-03-10", "AGSC-03-11", "AGSC-03-12", "AGSC-03-13", "AGSC-03-14", "AGSC-03-15", "AGSC-03-16", "AGSC-03-17", "AGSC-03-18", "AGSC-03-19", "AGSC-03-20", "AGSC-03-21", "AGSC-03-22", "AGSC-04-01", "AGSC-04-02", "AGSC-04-03", "AGSC-04-04", "AGSC-04-05", "AGSC-04-06", "AGSC-04-07", "AGSC-04-08", "AGSC-04-09", "AGSC-04-10", "AGSC-04-11", "AGSC-04-12", "AGSC-04-13", "AGSC-04-14", "AGSC-04-15", "AGSC-04-16", "AGSC-04-17", "AGSC-04-18", "AGSC-04-19", "AGSC-04-20", "AGSC-04-21", "AGSC-04-22", "AGSC-04-23", "AGSC-04-24", "AGSC-04-25", "AGSC-05-01", "AGSC-05-02", "AGSC-05-03", "AGSC-05-04", "AGSC-05-04a", "AGSC-05-04b", "AGSC-05-05", "AGSC-05-06", "AGSC-05-07", "AGSC-05-08", "AGSC-05-09", "AGSC-05-10", "AGSC-05-11", "AGSC-05-12", "AGSC-05-13", "AGSC-05-14", "AGSC-05-15", "AGSC-05-16", "AGSC-05-17", "AGSC-05-18", "AGSC-05-19", "AGSC-05-20", "AGSC-05-21", "AGSC-05-22", "AGSC-05-23", "AGSC-05-24", "AGSC-05-25", "AGSC-05-26", "AGSC-05-26a", "AGSC-05-27", "AGSC-05-28", "AGSC-05-29", "AGSC-05-30", "AGSC-05-31", "AGSC-05-32", "AGSC-06-01", "AGSC-06-02", "AGSC-06-03", "AGSC-06-04", "AGSC-06-05", "AGSC-06-06", "AGSC-06-07", "AGSC-06-08", "AGSC-06-08a", "AGSC-06-09", "AGSC-06-10", "AGSC-06-11", "AGSC-06-12", "AGSC-06-13", "AGSC-06-13a", "AGSC-06-14", "AGSC-06-15", "AGSC-06-16", "AGSC-06-17", "AGSC-06-18", "AGSC-06-19", "AGSC-06-20", "AGSC-06-21", "AGSC-06-22", "AGSC-06-23", "AGSC-06-24", "AGSC-06-25", "AGSC-06-26", "AGSC-06-27", "AGSC-06-28", "AGSC-06-29", "AGSC-06-30", "AGSC-06-31", "AGSC-06-32", "AGSC-06-33", "AGSC-06-34", "AGSC-06-35", "AGSC-06-36", "AGSC-07-01", "AGSC-07-02", "AGSC-07-03", "AGSC-07-04", "AGSC-07-05", "AGSC-07-05a", "AGSC-07-06", "AGSC-07-07", "AGSC-07-08", "AGSC-07-09", "AGSC-07-10", "AGSC-07-11", "AGSC-07-12", "AGSC-07-13", "AGSC-07-13a", "AGSC-07-14", "AGSC-07-15", "AGSC-07-16", "AGSC-07-17", "AGSC-07-18", "AGSC-07-19", "AGSC-07-20", "AGSC-07-21", "AGSC-07-22", "AGSC-07-23", "AGSC-07-24", "AGSC-08-01", "AGSC-08-02", "AGSC-08-03", "AGSC-08-04", "AGSC-08-05", "AGSC-08-06", "AGSC-08-07", "AGSC-08-08", "AGSC-08-09", "AGSC-08-10", "AGSC-08-11", "AGSC-08-12", "AGSC-08-13", "AGSC-08-14", "AGSC-08-15", "AGSC-08-16", "AGSC-08-17", "AGSC-08-18", "AGSC-08-19", "AGSC-08-20", "AGSC-08-20a", "AGSC-08-20b", "AGSC-08-21", "AGSC-08-22", "AGSC-08-23", "AGSC-08-24", "AGSC-08-25", "AGSC-08-26", "AGSC-08-27", "AGSC-08-28", "AGSC-08-29", "AGSC-08-30", "AGSC-09-01", "AGSC-09-02", "AGSC-09-03", "AGSC-09-04", "AGSC-09-05", "AGSC-09-06", "AGSC-09-07", "AGSC-09-08", "AGSC-09-09", "AGSC-09-10", "AGSC-09-11", "AGSC-09-12", "AGSC-09-13", "AGSC-09-13a", "AGSC-09-14", "AGSC-09-14a", "AGSC-09-14b", "AGSC-09-15", "AGSC-09-16", "AGSC-09-90", "AGSC-09-91", "AGSC-09-92", "AGSC-09-93", "AGSC-09-94", "AGSC-10-01", "AGSC-10-02", "AGSC-10-03", "AGSC-10-04", "AGSC-10-05", "AGSC-10-06", "AGSC-10-07", "AGSC-10-08", "AGSC-10-09", "AGSC-10-10", "AGSC-10-11", "AGSC-10-12", "AGSC-10-13", "AGSC-10-14", "AGSC-10-15", "AGSC-10-16", "AGSC-10-17", "AGSC-10-18", "AGSC-11-01", "AGSC-11-02", "AGSC-11-03", "AGSC-11-04", "AGSC-11-05", "AGSC-11-06", "AGSC-11-07", "AGSC-11-08", "AGSC-11-09", "AGSC-11-10", "AGSC-11-11", "AGSC-11-12", "AGSC-11-13", "AGSC-11-14", "AGSC-11-15", "AGSC-11-16", "AGSC-11-17", "AGSC-11-18", "AGSC-11-19", "AGSC-11-20", "AGSC-11-21", "AGSC-11-22", "AGSC-11-23"], "spec_version": "1.0.0"} +{"error_codes": ["AGSC-E001", "AGSC-E002", "AGSC-E003", "AGSC-E004", "AGSC-E005", "AGSC-E101", "AGSC-E102", "AGSC-E103", "AGSC-E104", "AGSC-E105", "AGSC-E106", "AGSC-E107", "AGSC-E108", "AGSC-E109", "AGSC-E201", "AGSC-E202", "AGSC-E203", "AGSC-E204", "AGSC-E205", "AGSC-E206", "AGSC-E207", "AGSC-E208", "AGSC-E209", "AGSC-E210", "AGSC-E211", "AGSC-E212", "AGSC-E213", "AGSC-E301", "AGSC-E302", "AGSC-E303", "AGSC-E304", "AGSC-E305", "AGSC-E306", "AGSC-E307", "AGSC-E308", "AGSC-E309", "AGSC-E310", "AGSC-E311", "AGSC-E312", "AGSC-E313", "AGSC-E314", "AGSC-E315", "AGSC-E316", "AGSC-E317", "AGSC-E401", "AGSC-E402", "AGSC-E403", "AGSC-E404", "AGSC-E405", "AGSC-E406", "AGSC-E407", "AGSC-E408", "AGSC-E409", "AGSC-E410", "AGSC-E411", "AGSC-E412", "AGSC-E413", "AGSC-E414", "AGSC-E415", "AGSC-E416", "AGSC-E417", "AGSC-E418", "AGSC-E419", "AGSC-E420", "AGSC-E421", "AGSC-E422", "AGSC-E423", "AGSC-E501", "AGSC-E502", "AGSC-E503", "AGSC-E504", "AGSC-E505", "AGSC-E506", "AGSC-E507", "AGSC-E508", "AGSC-E509", "AGSC-E510", "AGSC-E511", "AGSC-E512", "AGSC-E601", "AGSC-E602", "AGSC-E603", "AGSC-E604", "AGSC-E605", "AGSC-E606", "AGSC-E607", "AGSC-E701", "AGSC-E702", "AGSC-E703", "AGSC-E704", "AGSC-E705", "AGSC-E706", "AGSC-E707", "AGSC-E801", "AGSC-E802", "AGSC-E803", "AGSC-E804", "AGSC-E805", "AGSC-E901", "AGSC-E902", "AGSC-E903", "AGSC-E904", "AGSC-E905", "AGSC-E906", "AGSC-E907"], "rule_ids": ["AGSC-00-01", "AGSC-00-02", "AGSC-00-03", "AGSC-00-04", "AGSC-00-05", "AGSC-00-06", "AGSC-00-07", "AGSC-00-08", "AGSC-00-09", "AGSC-00-10", "AGSC-00-11", "AGSC-00-12", "AGSC-00-13", "AGSC-00-14", "AGSC-00-15", "AGSC-00-16", "AGSC-00-17", "AGSC-00-18", "AGSC-00-19", "AGSC-00-20", "AGSC-00-21", "AGSC-00-22", "AGSC-00-23", "AGSC-00-24", "AGSC-00-25", "AGSC-01-01", "AGSC-01-02", "AGSC-01-03", "AGSC-01-04", "AGSC-01-05", "AGSC-01-06", "AGSC-01-07", "AGSC-01-08", "AGSC-01-09", "AGSC-01-10", "AGSC-01-11", "AGSC-01-12", "AGSC-01-13", "AGSC-01-13a", "AGSC-01-14", "AGSC-01-15", "AGSC-01-16", "AGSC-01-17", "AGSC-01-18", "AGSC-01-19", "AGSC-01-20", "AGSC-01-21", "AGSC-01-22", "AGSC-01-23", "AGSC-01-24", "AGSC-01-25", "AGSC-01-26", "AGSC-01-26a", "AGSC-01-27", "AGSC-01-28", "AGSC-01-29", "AGSC-01-30", "AGSC-01-31", "AGSC-01-32", "AGSC-01-33", "AGSC-01-34", "AGSC-01-35", "AGSC-01-36", "AGSC-01-37", "AGSC-01-38", "AGSC-01-39", "AGSC-01-40", "AGSC-01-41", "AGSC-01-42", "AGSC-02-01", "AGSC-02-02", "AGSC-02-03", "AGSC-02-04", "AGSC-02-05", "AGSC-02-05a", "AGSC-02-06", "AGSC-02-07", "AGSC-02-08", "AGSC-02-09", "AGSC-02-10", "AGSC-02-11", "AGSC-02-12", "AGSC-02-13", "AGSC-02-14", "AGSC-02-15", "AGSC-02-16", "AGSC-02-17", "AGSC-02-18", "AGSC-02-19", "AGSC-02-20", "AGSC-02-21", "AGSC-02-22", "AGSC-02-23", "AGSC-02-24", "AGSC-02-25", "AGSC-02-90", "AGSC-02-91", "AGSC-02-92", "AGSC-02-93", "AGSC-02-94", "AGSC-02-95", "AGSC-02-96", "AGSC-02-97", "AGSC-02-98", "AGSC-02-99", "AGSC-03-01", "AGSC-03-02", "AGSC-03-03", "AGSC-03-04", "AGSC-03-05", "AGSC-03-06", "AGSC-03-07", "AGSC-03-08", "AGSC-03-09", "AGSC-03-10", "AGSC-03-11", "AGSC-03-12", "AGSC-03-13", "AGSC-03-14", "AGSC-03-15", "AGSC-03-16", "AGSC-03-17", "AGSC-03-18", "AGSC-03-19", "AGSC-03-20", "AGSC-03-21", "AGSC-03-22", "AGSC-03-23", "AGSC-03-24", "AGSC-03-25", "AGSC-03-26", "AGSC-03-27", "AGSC-04-01", "AGSC-04-02", "AGSC-04-03", "AGSC-04-04", "AGSC-04-05", "AGSC-04-06", "AGSC-04-07", "AGSC-04-08", "AGSC-04-09", "AGSC-04-10", "AGSC-04-11", "AGSC-04-12", "AGSC-04-13", "AGSC-04-14", "AGSC-04-15", "AGSC-04-16", "AGSC-04-17", "AGSC-04-18", "AGSC-04-19", "AGSC-04-20", "AGSC-04-21", "AGSC-04-22", "AGSC-04-23", "AGSC-04-24", "AGSC-04-25", "AGSC-05-01", "AGSC-05-02", "AGSC-05-03", "AGSC-05-04", "AGSC-05-04a", "AGSC-05-04b", "AGSC-05-05", "AGSC-05-06", "AGSC-05-07", "AGSC-05-08", "AGSC-05-09", "AGSC-05-10", "AGSC-05-11", "AGSC-05-12", "AGSC-05-13", "AGSC-05-14", "AGSC-05-15", "AGSC-05-16", "AGSC-05-17", "AGSC-05-18", "AGSC-05-19", "AGSC-05-20", "AGSC-05-21", "AGSC-05-22", "AGSC-05-23", "AGSC-05-24", "AGSC-05-25", "AGSC-05-26", "AGSC-05-26a", "AGSC-05-27", "AGSC-05-28", "AGSC-05-29", "AGSC-05-30", "AGSC-05-31", "AGSC-05-32", "AGSC-05-33", "AGSC-05-34", "AGSC-05-35", "AGSC-05-36", "AGSC-05-37", "AGSC-05-38", "AGSC-05-39", "AGSC-05-40", "AGSC-05-41", "AGSC-06-01", "AGSC-06-02", "AGSC-06-03", "AGSC-06-04", "AGSC-06-05", "AGSC-06-06", "AGSC-06-07", "AGSC-06-08", "AGSC-06-08a", "AGSC-06-09", "AGSC-06-10", "AGSC-06-11", "AGSC-06-12", "AGSC-06-13", "AGSC-06-13a", "AGSC-06-14", "AGSC-06-15", "AGSC-06-16", "AGSC-06-17", "AGSC-06-18", "AGSC-06-19", "AGSC-06-20", "AGSC-06-21", "AGSC-06-22", "AGSC-06-23", "AGSC-06-24", "AGSC-06-25", "AGSC-06-26", "AGSC-06-27", "AGSC-06-28", "AGSC-06-29", "AGSC-06-30", "AGSC-06-31", "AGSC-06-32", "AGSC-06-33", "AGSC-06-34", "AGSC-06-35", "AGSC-06-36", "AGSC-06-37", "AGSC-06-38", "AGSC-06-39", "AGSC-06-40", "AGSC-06-41", "AGSC-06-42", "AGSC-06-44", "AGSC-06-45", "AGSC-06-46", "AGSC-07-01", "AGSC-07-02", "AGSC-07-03", "AGSC-07-04", "AGSC-07-05", "AGSC-07-05a", "AGSC-07-06", "AGSC-07-07", "AGSC-07-08", "AGSC-07-09", "AGSC-07-10", "AGSC-07-11", "AGSC-07-12", "AGSC-07-13", "AGSC-07-13a", "AGSC-07-14", "AGSC-07-15", "AGSC-07-16", "AGSC-07-17", "AGSC-07-18", "AGSC-07-19", "AGSC-07-20", "AGSC-07-21", "AGSC-07-22", "AGSC-07-23", "AGSC-07-24", "AGSC-07-25", "AGSC-07-26", "AGSC-07-27", "AGSC-07-28", "AGSC-07-29", "AGSC-07-30", "AGSC-08-01", "AGSC-08-02", "AGSC-08-03", "AGSC-08-04", "AGSC-08-05", "AGSC-08-06", "AGSC-08-07", "AGSC-08-08", "AGSC-08-09", "AGSC-08-10", "AGSC-08-11", "AGSC-08-12", "AGSC-08-13", "AGSC-08-14", "AGSC-08-15", "AGSC-08-16", "AGSC-08-17", "AGSC-08-18", "AGSC-08-19", "AGSC-08-20", "AGSC-08-20a", "AGSC-08-20b", "AGSC-08-21", "AGSC-08-22", "AGSC-08-23", "AGSC-08-24", "AGSC-08-25", "AGSC-08-26", "AGSC-08-27", "AGSC-08-28", "AGSC-08-29", "AGSC-08-30", "AGSC-08-31", "AGSC-08-32", "AGSC-09-01", "AGSC-09-02", "AGSC-09-03", "AGSC-09-04", "AGSC-09-05", "AGSC-09-06", "AGSC-09-07", "AGSC-09-08", "AGSC-09-09", "AGSC-09-10", "AGSC-09-11", "AGSC-09-12", "AGSC-09-13", "AGSC-09-13a", "AGSC-09-14", "AGSC-09-14a", "AGSC-09-14b", "AGSC-09-15", "AGSC-09-16", "AGSC-09-17", "AGSC-09-18", "AGSC-09-19", "AGSC-09-20", "AGSC-09-90", "AGSC-09-91", "AGSC-09-92", "AGSC-09-93", "AGSC-09-94", "AGSC-10-01", "AGSC-10-02", "AGSC-10-03", "AGSC-10-04", "AGSC-10-05", "AGSC-10-06", "AGSC-10-07", "AGSC-10-08", "AGSC-10-09", "AGSC-10-10", "AGSC-10-11", "AGSC-10-12", "AGSC-10-13", "AGSC-10-14", "AGSC-10-15", "AGSC-10-16", "AGSC-10-17", "AGSC-10-18", "AGSC-10-19", "AGSC-11-01", "AGSC-11-02", "AGSC-11-03", "AGSC-11-04", "AGSC-11-05", "AGSC-11-06", "AGSC-11-07", "AGSC-11-08", "AGSC-11-09", "AGSC-11-10", "AGSC-11-11", "AGSC-11-12", "AGSC-11-13", "AGSC-11-14", "AGSC-11-15", "AGSC-11-16", "AGSC-11-17", "AGSC-11-18", "AGSC-11-19", "AGSC-11-20", "AGSC-11-21", "AGSC-11-22", "AGSC-11-23", "AGSC-11-24"], "spec_version": "1.1.0"} diff --git a/src/agentic_system_core/derive.py b/src/agentic_system_core/derive.py new file mode 100644 index 0000000..69c4b0b --- /dev/null +++ b/src/agentic_system_core/derive.py @@ -0,0 +1,102 @@ +"""The readings of the Link graph, each with its reasons (AGSC-05-33). + +What: from the edges ``links.edges`` returns, the relations the graph holds without +anyone having authored them. A reading is ``{source, key, target, because}``; +``because`` is a list of steps ``{rule, from}``, ``from`` being the edges +``[source, key, target]`` the step used: + +* ``inverse`` — the computed inverse of an authored edge (a); +* ``symmetric`` — the other direction of ``related``, ``excludes``, ``contradicts`` (b); +* ``transitive`` — a chain of two or more edges of one transitive key (c); +* ``closure`` — the same chain for ``requires`` and ``required-by`` (d). + +Why: the engine's ``check``, ``explain`` and composition brief read these readings, and +``graph-0029`` pins them; a port that answers "why is this so" must give the same +reasons. Nothing here is written to a graph file: readings are computed on demand. +The engine's ``src/knowledge/derive.js`` is the reference; the transitive column and +the inverse names come from the relation table (``relations.py``). + +Standard library only. +""" + +from .relations import INVERSE, RELATIONS, SYMMETRIC + +#: Every name an edge can carry -> the name of the edge it was computed from. +PARTNER = dict(pair for row in RELATIONS + for pair in ((row["key"], row["inverse"]), (row["inverse"], row["key"]))) + +#: AGSC-05-33 (c): each transitive key and its computed inverse, in code-point order. +CHAIN_KEYS = tuple(sorted(set(name for row in RELATIONS if row["transitive"] + for name in (row["key"], row["inverse"])))) +#: AGSC-05-33 (d): the chains read as a closure. +CLOSURE_KEYS = ("requires", INVERSE["requires"]) + + +def _direct(edges): + """(a) and (b): each computed edge that is the inverse or the swap of an authored one.""" + out = [] + for edge in edges: + if not edge["computed"] or edge["key"] not in PARTNER: + continue + out.append({ + "because": [{ + "from": [[edge["target"], PARTNER[edge["key"]], edge["source"]]], + "rule": "symmetric" if edge["key"] in SYMMETRIC else "inverse", + }], + "key": edge["key"], "source": edge["source"], "target": edge["target"]}) + return out + + +def _walk(adjacency, start): + """Breadth first from ``start``, each frontier in code-point order: every item reached, + with the item it was first reached from and its depth (the shortest chain).""" + reached = {start: (None, 0)} + frontier = [start] + depth = 0 + while frontier: + depth += 1 + following = [] + for node in frontier: + for target in sorted(adjacency.get(node, ())): + if target not in reached: + reached[target] = (node, depth) + following.append(target) + frontier = sorted(following) + return reached + + +def _chain_to(reached, key, target): + chain = [] + node = target + while reached[node][0] is not None: + chain.insert(0, [reached[node][0], key, node]) + node = reached[node][0] + return chain + + +def _chains(edges): + """(c) and (d): one reading for each pair joined by a chain of two or more edges.""" + out = [] + for key in CHAIN_KEYS: + adjacency = {} + for edge in edges: + if edge["key"] == key: + adjacency.setdefault(edge["source"], set()).add(edge["target"]) + for source in adjacency: + reached = _walk(adjacency, source) + for target, (_, depth) in reached.items(): + if depth < 2: + continue + rule = "closure" if key in CLOSURE_KEYS else "transitive" + out.append({"because": [{"from": _chain_to(reached, key, target), "rule": rule}], + "key": key, "source": source, "target": target}) + return out + + +def readings(edges): + """AGSC-05-33: the readings of a Link graph, ordered by source, key, target. + + ``edges`` are the edges of ``links.edges``, authored and computed, in any order. + """ + return sorted(_direct(edges) + _chains(edges), + key=lambda one: (one["source"], one["key"], one["target"])) diff --git a/src/agentic_system_core/discovery.py b/src/agentic_system_core/discovery.py index e33ead2..30661c0 100644 --- a/src/agentic_system_core/discovery.py +++ b/src/agentic_system_core/discovery.py @@ -4,7 +4,10 @@ Derived from the rule text: * AGSC-06-13a / 06-15 — the byte layout of both agent-facing files, the - provenance header and the ``-->`` neutralisation. + provenance header and the ``-->`` neutralisation; as amended for 1.1, the + blockquote summary straight after the H1 and the provenance comment after it, the + backslash, ``[``, ``]`` and ``(`` of a link line escaped, and no ``bundle_version`` + line on a restricted node (AGSC-11-20). * AGSC-06-14 — every published item is reachable from ``/llms.txt``. * AGSC-06-19 — ``sitemap.xml``: every published route, by URL, ``lastmod`` the build instant. @@ -78,14 +81,15 @@ def sections(items, clusters=None): return out -def _header(bundle, spec_version, bundle_version, generated_at): +def _header(bundle, spec_version, bundle_version, generated_at, restricted): + version = [] if restricted else ["bundle_version: %s" % _neutral(bundle_version)] lines = [ "", @@ -93,33 +97,41 @@ def _header(bundle, spec_version, bundle_version, generated_at): return "\n".join(lines) -def _index_blocks(bundle, items, clusters, spec_version, bundle_version, generated_at): +def escape_link(text): + """AGSC-06-13a: one backslash before each backslash, ``[``, ``]`` and ``(``, in one pass.""" + return "".join("\\" + char if char in "\\[](" else char for char in text) + + +def _index_blocks(bundle, items, clusters, facts): blocks = ["# %s" % _one_line(bundle["title"]), - _header(bundle, spec_version, bundle_version, generated_at), - "> %s" % _one_line(bundle.get("description", ""))] + "> %s" % _one_line(bundle.get("description", "")), + _header(bundle, *facts)] order = [] for title, members in sections(items, clusters): lines = ["## %s" % _one_line(title), ""] for item in members: order.append(item) label = _one_line(item.get("description") or item.get("title", "")) - lines.append("- [%s](%s): %s" % (_one_line(item.get("title", "")), - item_iri(bundle["base"], item), label)) + lines.append("- [%s](%s): %s" % (escape_link(_one_line(item.get("title", ""))), + item_iri(bundle["base"], item), + escape_link(label))) blocks.append("\n".join(lines)) return blocks, order def llms_txt(bundle, items, clusters=None, spec_version="", bundle_version="", - generated_at=""): - blocks, _ = _index_blocks(bundle, items, clusters, spec_version, bundle_version, - generated_at) + generated_at="", visibility=None): + """``/llms.txt``; ``visibility`` is the node's (``restricted`` drops one header line).""" + facts = (spec_version, bundle_version, generated_at, visibility == "restricted") + blocks, _ = _index_blocks(bundle, items, clusters, facts) return "\n\n".join(blocks) + "\n" def llms_full_txt(bundle, items, clusters=None, spec_version="", bundle_version="", - generated_at=""): - blocks, order = _index_blocks(bundle, items, clusters, spec_version, bundle_version, - generated_at) + generated_at="", visibility=None): + """``/llms-full.txt``: ``/llms.txt`` through the sections, then one block per item.""" + facts = (spec_version, bundle_version, generated_at, visibility == "restricted") + blocks, order = _index_blocks(bundle, items, clusters, facts) for item in order: body = (item.get("body") or "").rstrip("\n") + "\n" blocks.append("## %s\n\n```text agsc-content\n%s```" diff --git a/src/agentic_system_core/frontmatter.py b/src/agentic_system_core/frontmatter.py index 4e501aa..a6a7451 100644 --- a/src/agentic_system_core/frontmatter.py +++ b/src/agentic_system_core/frontmatter.py @@ -5,7 +5,8 @@ package stays standard-library only: * AGSC-02-01 / 02-02 / 02-03 — the block, the closed YAML subset, failsafe - scalars (:mod:`yamlsubset`). + scalars (:mod:`yamlsubset`); from 1.1 a frontmatter nested deeper than 64 levels + is the warning ``AGSC-E105`` and is still read. * AGSC-02-05 / 02-05a — key-name pattern (``AGSC-E204``), unknown keys preserved and warned (``AGSC-E207``), the ``x-`` vendor namespace never warned. * AGSC-02-06 — dates and instants. @@ -166,6 +167,9 @@ def check(data, lines=None, slug=None): continue elif key in links_module.AUTHORED_INVERSE_FORBIDDEN: c.add("AGSC-E306", "%s is a computed inverse and is never authored" % key, key) + elif key in links_module.LINK_SHAPED_UNKNOWN: + c.add("AGSC-E304", "%s is not one of the fourteen Link keys and is preserved " + "(AGSC-03-03)" % key, key, severity="warn") else: c.add("AGSC-E207", "unknown key %s is preserved" % key, key, severity="warn") @@ -362,6 +366,14 @@ def read(markdown, slug=None): except yamlsubset.YamlError as error: return None, body, [finding(error.code, error.message, line=error.line)] findings = check(mapping, lines=mapping.lines, slug=slug) + nesting = yamlsubset.depth(mapping) + if nesting > yamlsubset.NESTING_BOUND: + # AGSC-02-02 (1.1): deeper than the bound but still read is a warning, and the + # frontmatter is processed as authored; what cannot be read stays an error. + findings.append(finding( + "AGSC-E105", "the frontmatter is nested %d levels deep; AGSC-02-02 bounds it at " + "%d and it is processed as authored" % (nesting, yamlsubset.NESTING_BOUND), + line=1, severity="warn")) return typed(plain(mapping)), body, findings diff --git a/src/agentic_system_core/graph.py b/src/agentic_system_core/graph.py index e902785..29a6b0a 100644 --- a/src/agentic_system_core/graph.py +++ b/src/agentic_system_core/graph.py @@ -18,14 +18,25 @@ The Bundle node and the two licence rows are emitted when the Bundle's configuration is given (``bundle``). Every line of ``graph.nq`` is a quad whose graph name is the Bundle IRI (AGSC-04-15). + +``graph.jsonld`` (AGSC-05-09) is written from the same triples, so the views +cannot drift (AGSC-05-06): one node per subject in code-point order of ``@id``, +each predicate under the term name of the published context (AGSC-06-32), one +value bare and several as a sorted array. ``/pages/.jsonld`` (AGSC-06-02) +is the one-item view with each node taken from the whole graph. The writer +follows the engine's ``src/knowledge/jsonld.js`` (``toJsonLd``, ``restrictTo``); +it is a JSON writer, not a JSON-LD processor (AGSC-05-11). """ import hashlib import re +from . import context as context_module from . import links as links_module -from .rdf import (ASC, DCTERMS, IRI, PROV, RDF_TYPE, SCHEMA, SKOS, XSD_DATETIME, Literal, - nquads, turtle) +from . import relations +from .jcs import canonicalize +from .rdf import (ASC, DCTERMS, IRI, RDF_TYPE, SCHEMA, SKOS, XSD_DATETIME, XSD_STRING, + Literal, nquads, turtle) TYPE_CLASS = { "concept": ASC + "Concept", "lesson": ASC + "Lesson", "episode": ASC + "Episode", @@ -44,23 +55,9 @@ def terms_for(license_prose): return CONTENT_USE_TERMS return str(license_prose) -#: Link key -> (forward property, inverse property or None). AGSC-03-01 table, AGSC-05-16. -LINK_PROPERTIES = { - "related": (SKOS + "related", SKOS + "related"), - "broader": (SKOS + "broader", SKOS + "narrower"), - "narrower": (SKOS + "narrower", SKOS + "broader"), - "uses": (ASC + "uses", ASC + "usedBy"), - "requires": (DCTERMS + "requires", DCTERMS + "isRequiredBy"), - "excludes": (ASC + "excludes", ASC + "excludes"), - "derived-from": (PROV + "wasDerivedFrom", None), - "contradicts": (ASC + "contradicts", ASC + "contradicts"), - "supersedes": (DCTERMS + "replaces", DCTERMS + "isReplacedBy"), - "implements": (ASC + "implements", ASC + "implementedBy"), - "verifies": (ASC + "verifies", ASC + "isVerifiedBy"), - "covers": (ASC + "covers", ASC + "coveredBy"), - "blocked-by": (ASC + "blockedBy", ASC + "blocks"), - "decided-by": (ASC + "decidedBy", ASC + "decides"), -} +#: Link key -> (forward property, inverse property or None): the relation table of +#: AGSC-03-01 (AGSC-05-16, AGSC-05-23), read from ``relations.py``. +LINK_PROPERTIES = relations.LINK_PROPERTIES _SEMANTIC = (SKOS + "related", SKOS + "broader", SKOS + "narrower") #: AGSC-05-26 rows read straight from an item key: key -> (property, types or None, datatype). @@ -250,3 +247,108 @@ def to_nquads(items, site_base, bundle=None, attachment_bytes=None): def to_turtle(items, site_base, bundle=None, attachment_bytes=None): return turtle(dataset(items, site_base, bundle, attachment_bytes)) + + +# --- graph.jsonld (AGSC-05-09) ------------------------------------------------------ + +def compaction_table(context_document): + """What the writer compacts with: ``terms``, IRI -> {"name", "type"} of its term + definition, and ``prefixes``, the (name, namespace) pairs of the plain string + definitions (``asc``, ``dcterms``, ... in a context of AGSC-06-32).""" + terms, prefixes = {}, [] + for name, definition in context_document.get("@context", {}).items(): + if isinstance(definition, str) and not name.startswith("@"): + prefixes.append((name, definition)) + elif isinstance(definition, dict) and definition.get("@id"): + terms[context_module.expand_curie(definition["@id"])] = { + "name": name, "type": definition.get("@type")} + return {"terms": terms, "prefixes": prefixes} + + +def prefixed(value, table): + """An IRI under a prefix of the context as its compact IRI (``asc:warrant``), else + itself: the form a JSON-LD processor's re-compaction writes (AGSC-06-32).""" + for prefix, namespace in table["prefixes"]: + if len(value) > len(namespace) and value.startswith(namespace): + return "%s:%s" % (prefix, value[len(namespace):]) + return value + + +def compact_name(value, table): + """A member name, a class or a datatype: its term name, else :func:`prefixed`.""" + term = table["terms"].get(value) + return term["name"] if term else prefixed(value, table) + + +def json_value(obj, definition, table): + """One object in the most compact form its term definition allows (AGSC-05-31).""" + selects_iris = definition is not None and definition["type"] == "@id" + if isinstance(obj, IRI): + value = prefixed(obj.value, table) + return value if selects_iris else {"@id": value} + if obj.lang is not None: + return {"@language": obj.lang, "@value": obj.value} + datatype = obj.datatype or XSD_STRING + if selects_iris: + # A bare string under an @id term would be read as an IRI. + return {"@type": compact_name(datatype, table), "@value": obj.value} + if (definition is not None and definition["type"] == datatype) or datatype == XSD_STRING: + return obj.value + return {"@type": compact_name(datatype, table), "@value": obj.value} + + +def _value_key(value): + if isinstance(value, str): + return value + return value.get("@id") or value.get("@value") or "" + + +def _members(objects, definition, table): + """The values of one predicate: sorted, one per key, bare when there is one.""" + values = sorted((json_value(obj, definition, table) for obj in objects), + key=lambda value: (_value_key(value), canonicalize(value))) + unique, seen = [], set() + for value in values: + if _value_key(value) not in seen: + seen.add(_value_key(value)) + unique.append(value) + return unique[0] if len(unique) == 1 else unique + + +def to_jsonld(items, site_base, bundle=None, attachment_bytes=None, context_document=None, + context_url=None): + """``graph.jsonld`` as a document (serialise it with JCS and one LF, AGSC-04-04). + + ``context_document`` fixes the term names (default: the published context); + ``context_url`` is the ``@context`` the document names, none when it is None. + """ + table = compaction_table(context_document or context_module.published()) + by_subject = {} + for subject, predicate, obj in dataset(items, site_base, bundle, attachment_bytes): + by_subject.setdefault(subject.value, {}).setdefault(predicate.value, []).append(obj) + nodes = [] + for subject in sorted(by_subject): + properties = by_subject[subject] + node = {"@id": prefixed(subject, table)} + types = [compact_name(value, table) + for value in sorted(obj.value for obj in properties.pop(RDF_TYPE, []))] + if types: + node["@type"] = types[0] if len(types) == 1 else types + for predicate, objects in properties.items(): + node[compact_name(predicate, table)] = _members( + objects, table["terms"].get(predicate), table) + nodes.append(node) + document = {} + if context_url: + document["@context"] = context_url + document["@graph"] = nodes + return document + + +def restrict_to(whole, single): + """``/pages/.jsonld`` (AGSC-06-02): the nodes of the one-item document + ``single``, each replaced by its node in the whole graph's document.""" + by_id = dict((node["@id"], node) for node in whole.get("@graph", [])) + restricted = dict(single) + restricted["@graph"] = [by_id.get(node["@id"], node) for node in single.get("@graph", [])] + return restricted diff --git a/src/agentic_system_core/links.py b/src/agentic_system_core/links.py index 5d3278e..a95304e 100644 --- a/src/agentic_system_core/links.py +++ b/src/agentic_system_core/links.py @@ -16,30 +16,38 @@ that carries it, to an item, an asset or an anchor of one; otherwise ``AGSC-E310``, and ``AGSC-E902`` when it escapes the Bundle root. * AGSC-03-13 — the heading-anchor algorithm. +* AGSC-03-23 to 03-26 (1.1) — four warnings about what an authored Link says, each + carried by the item that authors it: a self-link (``AGSC-E313``), two relations a + pair cannot both hold (``AGSC-E314``), a target of a kind the key does not expect + (``AGSC-E315``), a ``supersedes`` target still stable (``AGSC-E316``). + +The key list, the inverses and each key's self-link reading and Expected target kinds +are the relation table of AGSC-03-01, read from ``relations.py``. """ import unicodedata from . import markdown +from .relations import COMPUTED_KEYS, INVERSE, KEYS, ROW +# Re-exported, as this module has always named them (the relation table is their source). +from .relations import CORE_KEYS as CORE_KEYS +from .relations import MODE2_KEYS as MODE2_KEYS +from .relations import SYMMETRIC as SYMMETRIC -CORE_KEYS = ("related", "broader", "narrower", "uses", "requires", "excludes", - "derived-from", "contradicts", "supersedes") -MODE2_KEYS = ("implements", "verifies", "covers", "blocked-by", "decided-by") -KEYS = CORE_KEYS + MODE2_KEYS - -#: authored key -> computed inverse key (AGSC-03-01 table). -INVERSE = { - "related": "related", "broader": "narrower", "narrower": "broader", "uses": "used-by", - "requires": "required-by", "excludes": "excludes", "derived-from": "derivation-of", - "contradicts": "contradicts", "supersedes": "superseded-by", - "implements": "implemented-by", "verifies": "verified-by", "covers": "covered-by", - "blocked-by": "blocks", "decided-by": "decides", -} -SYMMETRIC = ("related", "excludes", "contradicts") #: AGSC-03-04: the inverse names that may never be authored. -AUTHORED_INVERSE_FORBIDDEN = ("used-by", "required-by", "derivation-of", "superseded-by", - "implemented-by", "verified-by", "covered-by", "blocks", - "decides") +AUTHORED_INVERSE_FORBIDDEN = COMPUTED_KEYS +#: AGSC-03-03: the link-shaped names outside the fourteen, each the warning ``AGSC-E304`` +#: (every other unknown key is ``AGSC-E207``, so one key never carries two codes): the +#: reserved ``peer-ref``, the untyped ``mentions`` and the foreign names of AGSC-03-19/03-20. +#: The engine's ``LINK_SHAPED_UNKNOWN`` (``src/knowledge/relations.js``); a test compares them. +LINK_SHAPED_UNKNOWN = ("peer-ref", "mentions", "refines", "alternative-to", "conflicts-with", + "composed-of", "mitigates", "recommends", "blockedBy", "decidedBy", + "tests", "traces-to") +#: AGSC-03-24: the combinations a pair (A, B) must not hold. A authors the first key; +#: the second may be authored by either side, as AGSC-03-05 runs ``excludes`` and +#: ``contradicts`` both ways. +INCOMPATIBLE = (("requires", "excludes"), ("requires", "supersedes"), + ("requires", "contradicts"), ("uses", "excludes")) TYPE_PLURAL = { "concept": "concepts", "lesson": "lessons", "episode": "episodes", @@ -99,6 +107,84 @@ def edges(items): return out, findings +def warn(code, message, slug, key): + return {"code": code, "key": key, "message": message, "severity": "warn", "slug": slug} + + +def _family(kind): + """AGSC-03-25: ``concept`` and ``lesson`` are one family; every other type is its own.""" + return "concept" if kind == "lesson" else kind + + +def _is_kind(spec, target): + """One alternative of a cell: the target's type, and its ``kind`` where the cell names kinds.""" + return target.get("type") == spec["type"] and ( + "kinds" not in spec or target.get("kind") in spec["kinds"]) + + +def matches_expected(cell, owner, target): + """AGSC-03-25: does ``target`` fit the Expected target kinds cell of a key ``owner`` authors? + + A cell reading ``any`` never fails, except that the narrower cell of ``derived-from`` + binds when the owner is a lesson, and the cell of ``related`` refuses a cluster at either + end, which AGSC-05-20 keeps out of ``skos:related``. + """ + if cell.get("noCluster") and "cluster" in (owner.get("type"), target.get("type")): + return False + if cell.get("any"): + lesson = cell.get("lessonTarget") + return lesson is None or owner.get("type") != "lesson" or _is_kind(lesson, target) + if cell.get("sameFamily"): + return _family(owner.get("type")) == _family(target.get("type")) + if cell.get("sameType"): + return owner.get("type") == target.get("type") + if "oneOf" in cell: + return any(_is_kind(spec, target) for spec in cell["oneOf"]) + return _is_kind(cell, target) + + +def _about_link(owner, key, target): + """AGSC-03-23, 03-25, 03-26: the warnings about one authored, resolved Link.""" + out = [] + slug = owner["slug"] + if slug == target["slug"] and ROW[key]["selfLink"] == "warning": + out.append(warn("AGSC-E313", "%s lists itself under %s" % (slug, key), slug, key)) + if not matches_expected(ROW[key]["targets"], owner, target): + out.append(warn("AGSC-E315", "%s of %s names %s, a %s not of the kind the key expects" + % (key, slug, target["slug"], target.get("type")), slug, key)) + if key == "supersedes" and target.get("status", "stable") == "stable": + out.append(warn("AGSC-E316", "%s supersedes %s, whose status is still stable" + % (slug, target["slug"]), slug, key)) + return out + + +def link_warnings(items): + """AGSC-03-23 to 03-26: the warnings about what the authored Links say. + + Each authored Link that resolves is judged once per (item, key, target); the pairs + of AGSC-03-24 are read over the edges after the symmetric keys run both ways. + """ + by_slug = dict((item["slug"], item) for item in items) + judged = set() + out = [] + for item in sorted(items, key=lambda one: one["slug"]): + for key, values in authored_links(item): + for value in values: + target = by_slug.get(target_slug(value)[0]) + if target is None or (item["slug"], key, target["slug"]) in judged: + continue + judged.add((item["slug"], key, target["slug"])) + out.extend(_about_link(item, key, target)) + found, _ = edges(items) + held = set((one["source"], one["key"], one["target"]) for one in found) + for first, second in INCOMPATIBLE: + for source, key, target in sorted(held): + if key == first and source != target and (source, second, target) in held: + out.append(warn("AGSC-E314", "%s holds %s and %s toward %s, which cannot both " + "hold" % (source, first, second, target), source, first)) + return out + + def requires_cycle(items): """The first ``requires`` cycle found by a depth-first walk in slug order, or None.""" graph = {} diff --git a/src/agentic_system_core/net.py b/src/agentic_system_core/net.py index ad9d6b9..25d43e2 100644 --- a/src/agentic_system_core/net.py +++ b/src/agentic_system_core/net.py @@ -11,6 +11,9 @@ resolve to one address for the check and another for the request; * at most three redirects, and one ten-second deadline per response, from the request to the last byte (AGSC-11-10(e, f)); +* a budget of requests for one run, every request counted, redirects included: + ``federation.max_requests``' default of 500, settable from 1 to 2000, and the + request past it is AGSC-E906 (AGSC-11-06, AGSC-11-10(c)); * a cap of one mebibyte on a discovery document and of ``federation.max_bytes``' default on any other artefact; a fetch aborted at a cap or at the deadline is AGSC-E907. The deadline is not an idle timeout, which a slow server could keep @@ -38,6 +41,9 @@ #: The federation defaults of AGSC-11-06. REDIRECT_LIMIT = 3 TIMEOUT_SECONDS = 10 +#: ``federation.max_requests`` (AGSC-11-06): the default and the range a run may set. +MAX_REQUESTS = 500 +MAX_REQUESTS_RANGE = (1, 2000) _BLOCKED_V4 = [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "169.254.0.0/16", "172.16.0.0/12", @@ -64,6 +70,22 @@ def __init__(self, code, message): self.message = message +class RequestBudget(object): + """The requests one run may still send (AGSC-11-10(c)); the engine's checker keeps the + same count, over the document, its targets and its peer.""" + + def __init__(self, limit=MAX_REQUESTS): + self.limit = limit + self.spent = 0 + + def spend(self): + """Count one request, or refuse it with AGSC-E906 when the budget is spent.""" + if self.spent >= self.limit: + raise TransportError("AGSC-E906", "request budget of %d spent (federation.max_requests, " + "AGSC-11-10(c))" % self.limit) + self.spent += 1 + + def is_loopback(address): """True for 127.0.0.0/8 and ::1.""" parsed = ipaddress.ip_address(address) @@ -190,8 +212,7 @@ def fetch_once(href, dev=False, cap=MAX_BYTES): ) response = connection.getresponse() body = _read_within(response, deadline, cap) - headers = {name.lower(): value for name, value in response.getheaders()} - return response.status, headers, body + return response.status, _header_fields(response.getheaders()), body except TransportError: raise except socket.timeout: @@ -203,11 +224,54 @@ def fetch_once(href, dev=False, cap=MAX_BYTES): connection.close() -def fetch(href, dev=False, cap=MAX_BYTES): - """Follow up to three redirects and return the final URL, headers and bytes.""" +#: The fields of which Node's HTTP reader keeps the first line and drops a repeat +#: (``IncomingMessage``; measured on Node 24.18.0), so the engine's checker reads +#: the first ``Content-Type``, ``ETag`` or ``Location`` a response sends. +FIRST_LINE_ONLY = frozenset(( + "age", "authorization", "content-length", "content-type", "etag", "expires", "from", + "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", + "max-forwards", "proxy-authorization", "referer", "retry-after", "server", "user-agent")) + + +def _header_fields(pairs): + """The response header fields by lower-case name, as Node's reader gives them to + the engine's checker: a field of ``FIRST_LINE_ONLY`` sent more than once is its + first line; any other is one value, its lines joined with ", " (RFC 9110 section + 5.3), so a ``Link`` split over two lines is read whole. (Node joins ``Cookie`` + with "; " and lists ``Set-Cookie``; the checker reads neither.)""" + out = {} + for name, value in pairs: + key = name.lower() + if key not in out: + out[key] = value + elif key not in FIRST_LINE_ONLY: + out[key] = out[key] + ", " + value + return out + + +def counted(fetcher, href, dev, cap, budget): + """One read through ``fetcher`` within the run's request budget. + + The built-in ``fetch`` is handed the budget and spends it on every request, + redirects included. A fetcher a caller injects keeps its documented call, + ``fetcher(url, dev, cap=n)``: the budget is spent once for the call, before it, + since its redirects, if any, are its own.""" + if fetcher is fetch: + return fetch(href, dev, cap=cap, budget=budget) + budget.spend() + return fetcher(href, dev, cap=cap) + + +def fetch(href, dev=False, cap=MAX_BYTES, budget=None): + """Follow up to three redirects and return the final URL, headers and bytes. + + ``budget`` (a ``RequestBudget``), when given, is spent once per request, + redirects included (AGSC-11-10(c)).""" current = href hop = 0 while True: + if budget is not None: + budget.spend() status, headers, body = fetch_once(current, dev, cap) if status in (301, 302, 303, 307, 308) and headers.get("location"): if hop >= REDIRECT_LIMIT: diff --git a/src/agentic_system_core/questions.py b/src/agentic_system_core/questions.py new file mode 100644 index 0000000..909585f --- /dev/null +++ b/src/agentic_system_core/questions.py @@ -0,0 +1,188 @@ +"""The ten questions of the graph (AGSC-05-34, the competency questions of AGSC-05-13). + +What: each question is a function of the items of the published projection +(AGSC-06-30), the subject, and for questions 4 and 9 a selection and an instant. The +answer has the shape of the table in the rule; every list is sorted by code point, has +no repeats and never holds the subject. + +Why: ``graph-0030`` to ``graph-0039`` pin one answer each, and a port that answers the +same questions must give the same lists. The engine's ``src/knowledge/questions.js`` is +the reference. The SPARQL text of the questions is informative and is not run here, +as the engine does not run it. Edges come from ``links.edges``, the key names from the +relation table, and instants are read without a clock. + +Standard library only. +""" + +import re + +from . import links +from .relations import INVERSE + +_INSTANT = re.compile(r"^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?" + r"(Z|[+-]\d{2}:?\d{2})?)?$") + + +def _sorted(values): + return sorted(set(values)) + + +def _list(item, key): + value = item.get(key) + return value if isinstance(value, list) else [] + + +def days_from_civil(year, month, day): + """Days since 1970-01-01 of a proleptic Gregorian date.""" + year = year - 1 if month <= 2 else year + era = year // 400 + yoe = year - era * 400 + doy = (153 * (month + (-3 if month > 2 else 9)) + 2) // 5 + day - 1 + return era * 146097 + yoe * 365 + yoe // 4 - yoe // 100 + doy - 719468 + + +def instant_of(value): + """Milliseconds since the epoch of an ISO date or date-time (a date is its midnight, + UTC), or None when it does not parse.""" + match = _INSTANT.match(str(value)) + if match is None: + return None + year, month, day, hour, minute, second = (int(part or 0) for part in match.groups()[:6]) + zone = match.group(8) + offset = 0 + if zone and zone != "Z": + offset = (-1 if zone[0] == "-" else 1) * (int(zone[1:3]) * 60 + int(zone[-2:])) + fraction = float("0." + match.group(7)) * 1000 if match.group(7) else 0 + minutes = (days_from_civil(year, month, day) * 24 + hour) * 60 + minute - offset + return minutes * 60000 + second * 1000 + fraction + + +def is_stale(stale_after, at): + """AGSC-02-11: stale means ``stale_after`` is earlier than the instant, both read as + instants; text order where either does not parse.""" + if stale_after is None: + return False + first, second = instant_of(stale_after), instant_of(at) + if first is None or second is None: + return str(stale_after) < str(at) + return first < second + + +def _neighbours(items, key): + edges, _ = links.edges(items) + adjacency = {} + for edge in edges: + if edge["key"] == key: + adjacency.setdefault(edge["source"], []).append(edge["target"]) + return adjacency + + +def _reach(adjacency, start): + """The items reached from ``start`` by one or more steps, never ``start`` itself.""" + seen = {start} + queue = [start] + while queue: + for following in adjacency.get(queue.pop(0), []): + if following not in seen: + seen.add(following) + queue.append(following) + seen.discard(start) + return sorted(seen) + + +def _reached_by(items, subject, key): + return _reach(_neighbours(items, key), subject) + + +def _never_with(items, subject): + return _sorted(one for one in _neighbours(items, "excludes").get(subject, []) + if one != subject) + + +def _missing_ports(items, subject, selection): + provided = set() + for item in items: + if item["slug"] == subject or item["slug"] in selection: + provided.update(_list(item, "produces")) + own = [one for one in items if one["slug"] == subject] + return _sorted(name for name in (_list(own[0], "consumes") if own else []) + if name not in provided) + + +def _verification(items, subject): + def adjacent(key): + return _sorted(_neighbours(items, key).get(subject, [])) + return {"verified_by": adjacent(INVERSE["verifies"]), "verifies": adjacent("verifies")} + + +def _lineage(items, subject): + origin = _reached_by(items, subject, "derived-from") + episodes = set(item["slug"] for item in items if item.get("type") == "episode") + return {"episodes": [slug for slug in origin if slug in episodes], "lineage": origin} + + +def _under_cluster(items, subject): + """Nesting is ``broader`` of a cluster (AGSC-05-19).""" + clusters = set(item["slug"] for item in items if item.get("type") == "cluster") + children = {} + edges, _ = links.edges(items) + for edge in edges: + if edge["key"] == "broader" and edge["source"] in clusters: + children.setdefault(edge["target"], []).append(edge["source"]) + below = _reach(children, subject) + inside = set([subject] + below) + members = [item["slug"] for item in items if item["slug"] not in clusters + and any(name in inside for name in _list(item, "clusters"))] + return {"clusters": below, "items": _sorted(members)} + + +def _unhealthy(items, selection, at): + by_slug = dict((item["slug"], item) for item in items) + out = [] + for slug in _sorted(selection): + if slug not in by_slug: + continue + item = by_slug[slug] + reasons = [status for status in ("deprecated", "draft", "retired") + if item.get("status") == status] + if is_stale(item.get("stale_after"), at): + reasons.append("stale") + if reasons: + out.append({"reasons": reasons, "slug": slug}) + return out + + +def _sources_and_sharers(items, subject): + def resources(item): + return [one.get("resource") for one in _list(item, "sources") + if isinstance(one, dict) and isinstance(one.get("resource"), str)] + own = [one for one in items if one["slug"] == subject] + sources = _sorted(resources(own[0]) if own else []) + others = [item for item in items if item["slug"] != subject] + shared = [] + for resource in sources: + sharers = _sorted(item["slug"] for item in others if resource in resources(item)) + if sharers: + shared.append({"items": sharers, "resource": resource}) + return {"shared": shared, "sources": sources} + + +def answer(number, items, subject=None, selection=(), at=None): + """Question ``number`` (1 to 10) of AGSC-05-34, by its number in the table.""" + selection = list(selection) + table = { + 1: lambda: _reached_by(items, subject, "requires"), + 2: lambda: _never_with(items, subject), + 3: lambda: _reached_by(items, subject, INVERSE["supersedes"]), + 4: lambda: _missing_ports(items, subject, selection), + 5: lambda: _verification(items, subject), + 6: lambda: _reached_by(items, subject, "blocked-by"), + 7: lambda: _lineage(items, subject), + 8: lambda: _under_cluster(items, subject), + 9: lambda: _unhealthy(items, selection, at), + 10: lambda: _sources_and_sharers(items, subject), + } + if number not in table: + raise ValueError("AGSC-05-34: there are ten questions, numbered 1 to 10, not %r" + % (number,)) + return table[number]() diff --git a/src/agentic_system_core/rdf.py b/src/agentic_system_core/rdf.py index 9fe7adb..261179a 100644 --- a/src/agentic_system_core/rdf.py +++ b/src/agentic_system_core/rdf.py @@ -206,45 +206,50 @@ def is_pn_local(text): return text[-1] != "." -def turtle_iri(value): +def turtle_iri(value, prefixes=PREFIXES): """A prefixed name where AGSC-05-10(d) allows one, else ````.""" - for prefix, namespace in PREFIXES: + for prefix, namespace in prefixes: if value.startswith(namespace) and is_pn_local(value[len(namespace):]): return "%s:%s" % (prefix, value[len(namespace):]) return _iri_text(value) -def turtle_term(term): +def turtle_term(term, prefixes=PREFIXES): if isinstance(term, IRI): - return turtle_iri(term.value) + return turtle_iri(term.value, prefixes) text = '"%s"' % escape(term.value) if term.lang is not None: return "%s@%s" % (text, term.lang) if term.datatype is None: return text - return "%s^^%s" % (text, turtle_iri(term.datatype)) + return "%s^^%s" % (text, turtle_iri(term.datatype, prefixes)) -def prefix_block(): - return "".join("@prefix %s: <%s> .\n" % pair for pair in PREFIXES) +def prefix_block(prefixes=PREFIXES): + return "".join("@prefix %s: <%s> .\n" % pair for pair in prefixes) -def turtle(triples): - """The whole of ``graph.ttl`` under the AGSC-05-10 profile.""" +def turtle(triples, prefixes=PREFIXES): + """The whole of ``graph.ttl`` under the AGSC-05-10 profile. + + ``prefixes`` is the prefix block, in order: the constant block of AGSC-05-10(a) for + ``graph.ttl``, the two lines of AGSC-05-36 for the SKOS view. The rest of the + profile, (c) to (e), is the same for every file. + """ by_subject = {} for subject, predicate, obj in triples: _check_subject(subject) by_subject.setdefault(subject.value, {}).setdefault(predicate.value, set()).add( - turtle_term(obj)) + turtle_term(obj, prefixes)) blocks = [] for subject in sorted(by_subject): clauses = [] predicates = by_subject[subject] for predicate in sorted(predicates): - verb = "a" if predicate == RDF_TYPE else turtle_iri(predicate) + verb = "a" if predicate == RDF_TYPE else turtle_iri(predicate, prefixes) clauses.append("%s %s" % (verb, " , ".join(sorted(predicates[predicate])))) - blocks.append("%s %s .\n" % (turtle_iri(subject), " ;\n ".join(clauses))) - return prefix_block() + "".join("\n" + block for block in blocks) + blocks.append("%s %s .\n" % (turtle_iri(subject, prefixes), " ;\n ".join(clauses))) + return prefix_block(prefixes) + "".join("\n" + block for block in blocks) _BLANK_TOKEN = re.compile(r"_:|\[|\(") diff --git a/src/agentic_system_core/relations.py b/src/agentic_system_core/relations.py new file mode 100644 index 0000000..e0b937f --- /dev/null +++ b/src/agentic_system_core/relations.py @@ -0,0 +1,60 @@ +"""The relation table of AGSC-03-01: the fourteen Link keys and what is known about each. + +What: one row per key — its computed inverse, whether it is symmetric, its RDF property +and inverse property, its combiner, whether it reads transitively, what a self-link to +it is (AGSC-03-23), its Expected target kinds cell (AGSC-03-25) and its plain meaning. + +Why a data file: the table is a fact of the frozen specification, and the engine keeps +it once, in ``src/knowledge/relations.js``. ``data/relations.json`` is that table as the +command in docs/MAINTAINING.md derives it, never typed, and the suite fails when it +drifts. ``links.py``, ``graph.py``, ``derive.py`` and ``questions.py`` take their key +lists, inverses and properties from here, so the package holds one copy, not two. + +Standard library only. +""" + +import json +import os + +from .rdf import PREFIXES + +_DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "relations.json") +_NAMESPACES = dict(PREFIXES) + + +def data_bytes(): + """The bytes of ``data/relations.json`` as shipped.""" + with open(_DATA, "rb") as handle: + return handle.read() + + +def expand(curie): + """``skos:related`` -> its full IRI over the constant prefix block (AGSC-05-10).""" + prefix, _, local = curie.partition(":") + if prefix not in _NAMESPACES or local == "": + raise ValueError("%s is not a compact IRI over the constant prefixes" % curie) + return _NAMESPACES[prefix] + local + + +#: AGSC-03-01, the section 3.1 table: the nine core keys, then the five Mode-2 keys. +RELATIONS = tuple(json.loads(data_bytes().decode("utf-8"))["relations"]) +#: key -> its row. +ROW = dict((row["key"], row) for row in RELATIONS) +#: AGSC-03-01: the nine core keys and the five Mode-2 keys (AGSC-03-18), in table order. +CORE_KEYS = tuple(row["key"] for row in RELATIONS[:9]) +MODE2_KEYS = tuple(row["key"] for row in RELATIONS[9:]) +KEYS = CORE_KEYS + MODE2_KEYS +#: AGSC-03-02: authored key -> computed inverse name. +INVERSE = dict((row["key"], row["inverse"]) for row in RELATIONS) +#: AGSC-03-05: the keys materialised in both directions. +SYMMETRIC = tuple(row["key"] for row in RELATIONS if row["symmetric"]) +#: AGSC-03-04: the computed names that are never authored (``narrower`` is a key). +COMPUTED_KEYS = tuple(row["inverse"] for row in RELATIONS + if not row["symmetric"] and row["inverse"] not in KEYS) +#: AGSC-05-16 / AGSC-05-23: key -> (property IRI, inverse property IRI or None). A +#: symmetric key's inverse is its own property; ``derived-from`` has no inverse property. +LINK_PROPERTIES = dict( + (row["key"], (expand(row["property"]), + expand(row["property"]) if row["symmetric"] + else (expand(row["inverseProperty"]) if "inverseProperty" in row else None))) + for row in RELATIONS) diff --git a/src/agentic_system_core/signposting.py b/src/agentic_system_core/signposting.py new file mode 100644 index 0000000..4962b97 --- /dev/null +++ b/src/agentic_system_core/signposting.py @@ -0,0 +1,178 @@ +"""The home page's machine-readable parts: its Signposting links and its Dataset block. + +The twin of the engine's ``headers.homeLinks`` (``src/distribution/headers.js``), its +``licenseUrl`` (``src/knowledge/chunks.js``) and its ``datasetBlock`` and +``creatorOf`` (``src/distribution/front-page.js``): + +* ``home_links`` — the typed links FAIR Signposting Level 1 asks of a landing page, in + the ``Link`` field of ``/`` after the ``describedby`` link of AGSC-11-05 (AGSC-06-40; + vector disc-0026); +* ``license_url`` — the licence URL of a node (AGSC-06-44); +* ``dataset_block`` — the Schema.org ``Dataset`` of the home page with the licence URL, + the creator, free access, one ``DataDownload`` per machine file served and the two + PROV-O terms (AGSC-06-19, AGSC-06-41; vector disc-0027). + +This package writes no HTML page and no ``_headers`` file; these functions give the +data those files carry, so that the vectors that pin it are run here and compared with +the engine. Pure: data in, data out. Standard library only. +""" + +from . import MEDIA_TYPE, WELLKNOWN_PATH + +#: AGSC-06-18: the identifier of the Content Use Terms, the default prose licence. +CONTENT_USE_TERMS = "LicenseRef-AgenticSystemCore-Content-Use-1.0" +#: AGSC-06-40: the files an ``item`` link names, in order, with the type each is served with. +SIGNPOSTED_ITEMS = ( + ("/graph.nq", "application/n-quads"), + ("/graph.ttl", "text/turtle"), + ("/chunks.jsonl", "application/jsonl"), +) +#: AGSC-06-41: the PROV-O namespace (W3C Recommendation, 30 April 2013), prefix ``prov``. +PROV = "http://www.w3.org/ns/prov#" +XSD_DATE_TIME = "http://www.w3.org/2001/XMLSchema#dateTime" +#: AGSC-06-41: the machine files a ``DataDownload`` names, in order, with their types. +DOWNLOADS = ( + ("/graph.jsonld", "application/ld+json"), + ("/graph.ttl", "text/turtle"), + ("/graph.nq", "application/n-quads"), + ("/chunks.jsonl", "application/jsonl"), + (WELLKNOWN_PATH, MEDIA_TYPE), +) + + +def href(base, route): + """A route on the node: its base without trailing slashes, then the route.""" + return str(base).rstrip("/") + route + + +def license_url(config, legal=False): + """AGSC-06-44: ``bundle.license_url``; else, when the prose licence is the Content Use + Terms (or absent, which defaults to them) and the build writes ``/legal/``, the + node's ``/legal/`` page; else None.""" + bundle = config.get("bundle") or {} + named = bundle.get("license_url") + if isinstance(named, str) and named != "": + return named + prose = bundle.get("license_prose") + if not legal or (prose is not None and str(prose) != CONTENT_USE_TERMS): + return None + return href((config.get("site") or {}).get("base") or "", "/legal/") + + +def _cite_as(config): + """The first ``related[]`` entry of relation ``cite-as`` in ``href`` order, or None. + The entries are taken as the configuration schema admitted them.""" + hrefs = sorted(str(one["href"]) for one in config.get("related") or [] + if one.get("rel") == "cite-as") + return hrefs[0] if hrefs else None + + +def home_links(config, routes): + """AGSC-06-40: the links of the ``Link`` field of ``/`` as ``{href, rel[, type]}``, the + ``describedby`` link of AGSC-11-05 first. Only a node that writes a home page sends + the Signposting links: ``cite-as`` (else the Bundle IRI), the two ``type`` links, + ``describedby`` for ``/graph.jsonld``, an ``item`` for each graph file and the chunks + it serves (none on a restricted node), ``license`` when it has a licence URL, and + ``linkset``. Targets on the node are root-relative; ``cite-as`` and ``license`` are + absolute.""" + emitted = set(routes) + out = [{"href": WELLKNOWN_PATH, "rel": "describedby", "type": MEDIA_TYPE}] + if "/index.html" not in emitted: + return out + base = str((config.get("site") or {}).get("base") or "").rstrip("/") + cite = _cite_as(config) + out.append({"href": base + "/" if cite is None else cite, "rel": "cite-as"}) + out.append({"href": "https://schema.org/Dataset", "rel": "type"}) + out.append({"href": "https://schema.org/AboutPage", "rel": "type"}) + if "/graph.jsonld" in emitted: + out.append({"href": "/graph.jsonld", "rel": "describedby", "type": "application/ld+json"}) + if config.get("visibility") != "restricted": + out.extend({"href": route, "rel": "item", "type": kind} + for route, kind in SIGNPOSTED_ITEMS if route in emitted) + licence = license_url(config, legal="/legal/index.html" in emitted) + if licence is not None: + out.append({"href": licence, "rel": "license"}) + out.append({"href": WELLKNOWN_PATH, "rel": "linkset", "type": MEDIA_TYPE}) + return out + + +def creator_of(config, base): + """AGSC-06-41: the creator, a ``Person`` with a ``name`` and, where an ORCID iD is + configured, a ``sameAs`` naming it: from ``bundle.creator`` (name, optional orcid), + else from ``site.author`` with ``site.author_orcid`` (AGSC-01-18); None when + neither is configured. As amended 2026-11-10 the Person is a named node: ``@id`` + is the ORCID iD URL, else ``#creator``.""" + creator = (config.get("bundle") or {}).get("creator") + site = config.get("site") or {} + if isinstance(creator, dict) and isinstance(creator.get("name"), str): + name, orcid = creator["name"], creator.get("orcid") + elif isinstance(site.get("author"), str) and site["author"] != "": + name, orcid = site["author"], site.get("author_orcid") + else: + return None + iri = "https://orcid.org/" + orcid if isinstance(orcid, str) and orcid != "" else None + person = {"@id": base + "#creator" if iri is None else iri, "@type": "Person", "name": name} + if iri is not None: + person["sameAs"] = iri + return person + + +def dataset_block(config, instant, served, description=None, name=None, legal=False): + """AGSC-06-19 with AGSC-06-41: the ``Dataset`` block of the home page, as data. + + ``served``: the routes the build emits; ``legal``: it emits ``/legal/``. The files + of a restricted node are gated, so it names none and claims no free access.""" + base = (config.get("site") or {}).get("base") or "" + block = { + "@context": ["https://schema.org", {"prov": PROV}], "@id": href(base, "/"), + "@type": "Dataset", + "description": "" if description is None else description, + "name": "" if name is None else name, + "prov:generatedAtTime": {"@type": XSD_DATE_TIME, "@value": str(instant)}, + "url": href(base, "/"), + } + licence = license_url(config, legal=legal) + if licence is not None: + block["license"] = licence + creator = creator_of(config, href(base, "/")) + if creator is not None: + block["creator"] = creator + block["prov:wasAttributedTo"] = {"@id": creator["@id"]} + if config.get("visibility") != "restricted": + block["isAccessibleForFree"] = True + downloads = [{"@type": "DataDownload", "contentUrl": href(base, route), + "encodingFormat": kind} for route, kind in DOWNLOADS if route in served] + if downloads: + block["distribution"] = downloads + return block + + +#: AGSC-06-41: the namespaces of the DCAT 3 catalogue block, and the IANA media type registry. +DCAT = "http://www.w3.org/ns/dcat#" +DCTERMS = "http://purl.org/dc/terms/" +IANA_MEDIA_TYPES = "https://www.iana.org/assignments/media-types/" + + +def catalog_block(config, instant, served, description=None, name=None, legal=False): + """AGSC-06-41 as amended 2026-11-10: the DCAT 3 catalogue block a node writes beside + the Dataset block when ``discovery.dcat`` is true, or None (the engine's + ``front-page.js#catalogBlock``).""" + if (config.get("discovery") or {}).get("dcat") is not True: + return None + dataset = dataset_block(config, instant, served, description, name, legal) + described = {"@id": dataset["@id"], "@type": "dcat:Dataset", + "dcterms:description": dataset["description"], + "dcterms:modified": dataset["prov:generatedAtTime"], + "dcterms:title": dataset["name"]} + if "license" in dataset: + described["dcterms:license"] = {"@id": dataset["license"]} + if "creator" in dataset: + described["dcterms:creator"] = {"@id": dataset["creator"]["@id"]} + if "distribution" in dataset: + described["dcat:distribution"] = [dict( + {"@type": "dcat:Distribution", "dcat:downloadURL": {"@id": one["contentUrl"]}}, + **({"dcterms:format": kind} if kind == "application/jsonl" + else {"dcat:mediaType": {"@id": IANA_MEDIA_TYPES + kind}})) + for one in dataset["distribution"] for kind in [one["encodingFormat"].split(";")[0]]] + return {"@context": {"dcat": DCAT, "dcterms": DCTERMS}, "@id": dataset["@id"] + "#catalog", + "@type": "dcat:Catalog", "dcat:dataset": described, "dcterms:title": dataset["name"]} diff --git a/src/agentic_system_core/site.py b/src/agentic_system_core/site.py index ee4d28c..fb93428 100644 --- a/src/agentic_system_core/site.py +++ b/src/agentic_system_core/site.py @@ -167,7 +167,11 @@ def fragments(nquads_text, generated_at): def header_set(routes): - """The normative header facts for a route set: {pattern: {header: value}}.""" + """The normative header facts for a route set: {pattern: {header: value}}. + + No ``/query/*`` block: the query page and its WebAssembly policy belong to the + engine's Level-3 build, whose cases (build-0029, build-0030) this package does not + run, and no case this package runs reads that block.""" headers = {"/*": {"Content-Security-Policy": CSP}} if any(route.startswith("/pages/") and route.endswith(".md") for route in routes): headers["/pages/*.md"] = {"Content-Type": MARKDOWN_CONTENT_TYPE} @@ -202,8 +206,13 @@ def _finding(code, message, severity="error"): return {"code": code, "message": message, "severity": severity} -def security_txt(authored, instant, base, legal): - """(text or None, findings). ``authored`` is the Bundle root's file or None.""" +def security_txt(authored, instant, base, legal, policy=None): + """(text or None, findings). ``authored`` is the Bundle root's file or None. + + ``policy`` is ``site.security_policy``: where the authored file states no + ``Policy``, the declared disclosure page is used, else ``/legal/`` where that route + is emitted (``legal``), else none (AGSC-06-36 as amended for 1.1). + """ route = base.rstrip("/") + "/.well-known/security.txt" if authored is None: return None, [_finding("AGSC-E901", "the Bundle root carries no .well-known/security.txt")] @@ -244,7 +253,9 @@ def security_txt(authored, instant, base, legal): fields.append(("Expires", render_instant(build + datetime.timedelta(days=364)))) if "Canonical" not in names: fields.append(("Canonical", route)) - if "Policy" not in names and legal: + if "Policy" not in names and policy: + fields.append(("Policy", " ".join(str(policy).split()))) + elif "Policy" not in names and legal: fields.append(("Policy", base.rstrip("/") + "/legal/")) if any(one["severity"] == "error" for one in findings): return None, findings @@ -305,7 +316,13 @@ def stale_items(items, instant): return sorted(stale) -def now_line(bundle_version, generated_at, bundle_hash, spec_version): - """AGSC-06-22: the four values, in order, with the fixed separators.""" +def now_line(bundle_version, generated_at, bundle_hash, spec_version, visibility="public"): + """AGSC-06-22: the four values, in order, with the fixed separators. + + A ``restricted`` node's page is readable by anyone, so its line states neither the + content version nor the fingerprint (AGSC-11-20). + """ + if visibility == "restricted": + return "built at %s, specification %s" % (generated_at, spec_version) return "content version %s, built at %s, fingerprint %s, specification %s" % ( bundle_version, generated_at, bundle_hash, spec_version) diff --git a/src/agentic_system_core/skos.py b/src/agentic_system_core/skos.py new file mode 100644 index 0000000..34326fd --- /dev/null +++ b/src/agentic_system_core/skos.py @@ -0,0 +1,101 @@ +"""The SKOS view of the graph, the file ``export --skos`` writes (AGSC-05-36). + +What: one Turtle file, with its own two-line prefix block (``dcterms``, ``skos``), that +states the SKOS structure the graph leaves implicit: the Bundle as a +``skos:ConceptScheme`` with its record (``site.title``, ``site.tagline``, +``site.author`` and the Bundle's licence), ``a skos:Concept`` for each concept and +lesson, ``a skos:Collection`` for each cluster, and ``skos:hasTopConcept`` / +``skos:topConceptOf`` for each concept with no ``skos:broader``. It copies the SKOS +triples of the graph whose two ends are in the view; an episode, a procedure and a gate +are not SKOS concepts, so they and every triple that names one are left out. + +Why it reads the triples of ``graph.nq``: the view is "the triples of ``graph.nq`` +whose predicate is ...", so it agrees with the graph by construction — the published +projection, the labels, the language tags and the escaping are the graph's own. The +engine reads the text of ``graph.nq``; this package hands over the same triples from +``graph.dataset`` (no N-Quads parser is needed for its own output). The file is written +by the one stable-Turtle writer the graph uses (``rdf.turtle``, AGSC-05-10 (c) to (e)). +The engine's ``src/knowledge/skos-export.js`` is the reference; ``graph-0040`` pins the +whole file. + +Standard library only. +""" + +from .rdf import ASC, DCTERMS, IRI, RDF_TYPE, SCHEMA, SKOS, Literal, turtle + +#: The prefix block of the file: exactly these two lines, in this order (AGSC-05-36). +PREFIXES = (("dcterms", DCTERMS), ("skos", SKOS)) +#: The predicates of ``graph.nq`` the view copies. +COPIED = frozenset(SKOS + name for name in ("prefLabel", "altLabel", "definition", "inScheme", + "broader", "narrower", "related", "member")) +#: The SKOS class of each item class the view keeps (the axioms of AGSC-05-12). +SKOS_CLASS_OF = {ASC + "Concept": "Concept", ASC + "Lesson": "Concept", + ASC + "Cluster": "Collection"} +#: The scheme record: the dcterms property each value is written as, in this order. +RECORD_PROPERTIES = (("creator", DCTERMS + "creator"), ("description", DCTERMS + "description"), + ("title", DCTERMS + "title"), ("license", DCTERMS + "license")) + + +def scheme_record(config): + """``site.title``, ``site.tagline`` and ``site.author`` where present (AGSC-05-36).""" + site = (config or {}).get("site") or {} + record = {"creator": site.get("author"), "description": site.get("tagline"), + "title": site.get("title")} + return dict((name, value) for name, value in record.items() if value is not None) + + +def _kinds(triples): + """{subject IRI: "Concept" or "Collection"} for the items the view keeps.""" + return dict((subject.value, SKOS_CLASS_OF[obj.value]) for subject, predicate, obj in triples + if predicate.value == RDF_TYPE and isinstance(obj, IRI) + and obj.value in SKOS_CLASS_OF) + + +def _scheme(triples): + """(Bundle IRI, its licence or None), or None when the graph has no Bundle node.""" + bundles = sorted(subject.value for subject, predicate, obj in triples + if predicate.value == RDF_TYPE and obj == IRI(ASC + "Bundle")) + if not bundles: + return None + licences = sorted(obj.value for subject, predicate, obj in triples + if subject.value == bundles[0] and predicate.value == SCHEMA + "license") + return bundles[0], (licences[0] if licences else None) + + +def _copied(triples, kinds, scheme): + def belongs(term): + return not isinstance(term, IRI) or term.value in kinds or ( + scheme is not None and term.value == scheme[0]) + return [(subject, predicate, Literal(obj.value, lang=obj.lang) if isinstance(obj, Literal) + else obj) + for subject, predicate, obj in triples + if predicate.value in COPIED and subject.value in kinds and belongs(obj)] + + +def _scheme_triples(scheme, record, kinds, copied): + iri, licence = scheme + node = IRI(iri) + out = [(node, IRI(RDF_TYPE), IRI(SKOS + "ConceptScheme"))] + values = dict(record, license=licence) + for name, prop in RECORD_PROPERTIES: + if values.get(name) is not None: + out.append((node, IRI(prop), Literal(str(values[name])))) + if values.get("title") is not None: + out.append((node, IRI(SKOS + "prefLabel"), Literal(str(values["title"])))) + narrower = set(subject.value for subject, predicate, _ in copied + if predicate.value == SKOS + "broader") + for top in sorted(subject for subject, kind in kinds.items() + if kind == "Concept" and subject not in narrower): + out.append((node, IRI(SKOS + "hasTopConcept"), IRI(top))) + out.append((IRI(top), IRI(SKOS + "topConceptOf"), node)) + return out + + +def skos_view(triples, record=None): + """The Turtle text of ``skos.ttl`` for the triples of ``graph.nq`` and a scheme record.""" + kinds = _kinds(triples) + scheme = _scheme(triples) + copied = _copied(triples, kinds, scheme) + types = [(IRI(subject), IRI(RDF_TYPE), IRI(SKOS + kind)) for subject, kind in kinds.items()] + own = [] if scheme is None else _scheme_triples(scheme, record or {}, kinds, copied) + return turtle(copied + types + own, PREFIXES) diff --git a/src/agentic_system_core/vectors.py b/src/agentic_system_core/vectors.py index fa8e168..6bfb69c 100644 --- a/src/agentic_system_core/vectors.py +++ b/src/agentic_system_core/vectors.py @@ -32,7 +32,7 @@ import unicodedata from . import SPEC_VERSION, __version__ -from .areas import AREA_RUNNERS, NOT_RUN_REASONS +from .areas import AREA_RUNNERS, CASES_NOT_RUN, NOT_RUN_REASONS from .diagnostics import EXIT_FAIL, EXIT_PASS, envelope, finding from .jcs import canonicalize, nfc, utf16_key @@ -61,18 +61,28 @@ 3: AREAS, } -#: AGSC-10-15 (amended for 1.0.0): the cases of a Level's areas that exercise a higher +#: AGSC-10-15 (amended for 1.1.0): the cases of a Level's areas that exercise a higher #: Level's behaviour, each with the Level it belongs to; a claim at a lower Level neither -#: runs them nor fails for them. The engine and the specification carry the same table. +#: runs them nor fails for them. The engine and the specification carry the same table +#: (spec/10, the AGSC-10-15 table, read by the suite), here grouped by Level. HIGHER_LEVEL_CASES = { "bundle-0001": 1, "bundle-0006": 1, "bundle-0007": 1, "bundle-0009": 1, "bundle-0010": 1, - "disc-0005": 1, "disc-0019": 1, + "disc-0005": 1, "disc-0019": 1, "bundle-0012": 1, "bundle-0013": 1, "bundle-0014": 1, + "bundle-0015": 1, "bundle-0016": 1, "bundle-0017": 1, "bundle-0020": 1, "bundle-0021": 1, + "fm-0021": 1, "fm-0022": 1, "fm-0023": 1, "fm-0024": 1, "fm-0025": 1, "disc-0023": 1, + "fm-0026": 1, "fm-0027": 1, "bundle-0008": 2, "disc-0009": 2, "disc-0012": 2, "disc-0015": 2, "disc-0016": 2, "disc-0017": 2, "disc-0018": 2, "disc-0020": 2, "disc-0021": 2, "lint-0026": 2, - "bundle-0003": 3, "bundle-0004": 3, "bundle-0005": 3, - "lint-0001": 3, "lint-0002": 3, "lint-0003": 3, "lint-0028": 3, "lint-0029": 3, - "lint-0032": 3, "lint-0033": 3, - "adopt-0007": 3, "adopt-0008": 3, "adopt-0009": 3, + "bundle-0011": 2, "disc-0026": 2, "disc-0027": 2, "disc-0028": 2, "disc-0029": 2, + "disc-0030": 2, "disc-0031": 2, "disc-0032": 2, "disc-0033": 2, "disc-0035": 2, + "disc-0036": 2, "disc-0037": 2, "disc-0038": 2, + "bundle-0003": 3, "bundle-0004": 3, "bundle-0005": 3, "lint-0001": 3, "lint-0002": 3, + "lint-0003": 3, "lint-0028": 3, "lint-0029": 3, "lint-0032": 3, "lint-0033": 3, + "adopt-0007": 3, "adopt-0008": 3, "adopt-0009": 3, "bundle-0018": 3, "bundle-0019": 3, + "imp-0006": 3, "imp-0007": 3, "imp-0008": 3, "bnd-0046": 3, "bnd-0047": 3, "bnd-0048": 3, + "bnd-0050": 3, "lint-0046": 3, "lint-0047": 3, "lint-0048": 3, "lint-0049": 3, + "lint-0050": 3, "lint-0057": 3, "lint-0058": 3, "lint-0059": 3, "lint-0063": 3, + "lint-0065": 3, } _ID = re.compile(r"^[a-z]+-\d{4}$") @@ -127,6 +137,57 @@ def _walk(directory): return sorted(out) +#: AGSC-09-04: the path of a vector inside its tree, ``/-[-words].json``. +_VECTOR_NAME = re.compile(r"^[a-z]+-\d{4}(-[A-Za-z0-9-]+)?\.json$") + + +def _is_vector_path(absolute, directory): + parts = os.path.relpath(absolute, directory).split(os.sep) + return len(parts) == 2 and parts[0] in AREAS and _VECTOR_NAME.match(parts[1]) is not None + + +def _files_to_judge(directory, label): + """The files of a vector tree, and the AGSC-E901 finding when there is none. + + As the engine's ``validate-vectors`` reads AGSC-09-90: a missing folder and a folder + with no JSON file carry nothing to validate; a folder where not one JSON file sits at + a vector's path (one area folder, or a published site's ``/skills/index.json``) is + not a vector tree, and none of its files is judged. Inside a vector tree every JSON + file is judged, so a misnamed vector is still reported. + """ + if not os.path.isdir(directory): + return [], [finding("AGSC-E901", label, "no such directory: %s: there is nothing " + "to validate (AGSC-09-90)" % directory)] + files = _walk(directory) + if not files: + return [], [finding("AGSC-E901", label, "no vector file under %s: there is nothing " + "to validate (AGSC-09-90)" % directory)] + if not any(_is_vector_path(one, directory) for one in files): + return [], [finding( + "AGSC-E901", label, + "%s is not a vector directory: none of its %d JSON file(s) is an " + "/-.json vector, so none was judged (AGSC-09-04, AGSC-09-90)" + % (directory, len(files)))] + return files, [] + + +def _supersession_findings(links, seen): + """AGSC-09-04: a ``superseded_by`` link sits on a withdrawn vector and names a + vector of the same set; checked once every identifier is known.""" + out = [] + for name, level, target in links: + if level != "withdrawn": + out.append(finding("AGSC-E201", name, + "only a withdrawn vector may carry `superseded_by` (AGSC-09-04)")) + if not isinstance(target, str) or _ID.match(target) is None: + out.append(finding("AGSC-E204", name, 'superseded_by "%s" is not a vector id ' + "(AGSC-09-04)" % (target,))) + elif target not in seen: + out.append(finding("AGSC-E201", name, 'superseded_by "%s" names no vector of ' + "this set (AGSC-09-04)" % target)) + return out + + def _relative(path, root): return os.path.relpath(path, root).replace(os.sep, "/") @@ -176,12 +237,7 @@ def validate(directory, spec=None, root=None): else os.path.dirname(directory) root = os.path.abspath(root) - findings = [] - files = _walk(directory) - if not files: - findings.append(finding( - "AGSC-E901", _relative(directory, root), - "no vector file under %s: there is nothing to validate (AGSC-09-90)" % directory)) + files, findings = _files_to_judge(directory, _relative(directory, root)) if not rule_ids: findings.append(finding( "AGSC-E901", "spec/", @@ -189,6 +245,7 @@ def validate(directory, spec=None, root=None): seen = {} present = set() + links = [] for absolute in files: name = _relative(absolute, root) with open(absolute, "rb") as handle: @@ -253,6 +310,8 @@ def validate(directory, spec=None, root=None): findings.append(finding( "AGSC-E201", name, 'rule "%s" is defined nowhere in spec/ (AGSC-09-05)' % vector["rule"])) + if "superseded_by" in vector: + links.append((name, vector.get("level"), vector["superseded_by"])) if vector.get("level") == "withdrawn": if not isinstance(vector.get("reason"), str) or vector["reason"] == "": findings.append(finding( @@ -284,6 +343,7 @@ def validate(directory, spec=None, root=None): "AGSC-E203", name, "error code %s is not registered in spec/09 section 9.4 (AGSC-09-15)" % code)) + findings.extend(_supersession_findings(links, seen)) empty = [area for area in AREAS if area not in present] return envelope(findings, VALIDATE_VERB, spec_version=declared), len(files), empty @@ -314,6 +374,10 @@ def load_vectors(directory): return sorted(out, key=lambda one: str(one.get("id"))) +def _area_reason(area): + return NOT_RUN_REASONS.get(area, "area %s is not implemented by this package" % area) + + def run_one(vector, pending, reason, surfaces): """Classify and, where this package implements the area, execute one vector.""" if vector.get("level") == "withdrawn": @@ -326,10 +390,8 @@ def run_one(vector, pending, reason, surfaces): return {"status": "pass", "detail": "skipped as passed: surface not declared (AGSC-09-04)"} runner = AREA_RUNNERS.get(vector.get("area")) if runner is None: - return {"status": "not-run", - "detail": NOT_RUN_REASONS.get( - vector.get("area"), - "area %s is not implemented by this package" % vector.get("area"))} + return {"status": "not-run", "detail": CASES_NOT_RUN.get(vector.get("id")) + or _area_reason(vector.get("area"))} try: return runner(vector) except Exception as error: # the handler itself is a fault, never a silent pass @@ -364,7 +426,7 @@ def run(directory, level=None, pending_path=None, surfaces=("mcp", "webmcp")): if vector.get("area") in AREA_RUNNERS: not_run_vectors[vector.get("id")] = outcome["detail"] else: - not_run_areas[vector.get("area")] = outcome["detail"] + not_run_areas[vector.get("area")] = _area_reason(vector.get("area")) else: tally["fail"] += 1 results.append({ diff --git a/src/agentic_system_core/wellknown.py b/src/agentic_system_core/wellknown.py index bd823ca..ef7a43e 100644 --- a/src/agentic_system_core/wellknown.py +++ b/src/agentic_system_core/wellknown.py @@ -17,7 +17,18 @@ Given a URL, the response headers of the rules on cross-origin reading (AGSC-11-03) and caching (AGSC-11-05) are also checked, on the document and on every same-origin public artefact the run fetches: errors at Level 2 and above, -warnings below (AGSC-09-93, amended 2026-10-06 for 1.0.0). +warnings below (AGSC-09-93, amended 2026-10-06 for 1.0.0); and the ``Link`` header +of the node's home page ``/`` is read for the ``describedby`` link to the discovery +document, whose absence is a warning (AGSC-06-25, AGSC-06-40). Every request of a +run counts against one budget, redirects included (``--max-requests``, AGSC-11-10(c)). + +From 1.1, at Level 2 and above, the ``digest``, ``agsc-chunk-count`` and +``agsc-chunk-set`` of the chunks surface link are required of a document of 1.1.0 or +later and recomputed over the chunk lines read, and an ``agsc-ledger-length`` is +compared with the ledger read (AGSC-09-93 (b) and (c), AGSC-06-44); at every Level an +``a2a-card`` declared on the node's own origin is resolved, and a card the node does +not serve is the warning AGSC-E210 (AGSC-11-16). Those checks live in +``wellknown_facts.py``. Error codes. Section 9.4 of the specification names no dedicated code for these shape checks, so this checker uses the same code for the same fault as the @@ -38,6 +49,7 @@ """ import base64 +import calendar import hashlib import json import os @@ -46,8 +58,10 @@ from . import MEDIA_TYPE, PROFILE_URI, REL_BASE, SPEC_VERSION, WELLKNOWN_SUFFIX from .diagnostics import envelope, finding from .jcs import canonicalize_raw, compare_utf16, parse_ijson, utf16_key -from .net import MAX_BYTES, TARGET_MAX_BYTES, TransportError +from .net import MAX_BYTES, TARGET_MAX_BYTES, RequestBudget, TransportError, counted from .urls import Url, decoded_path, is_url_argument, resolve +from .wellknown_facts import (card_target_findings, check_home_link, chunk_facts_findings, + chunk_facts_missing, ledger_length_findings) VERB = "validate-wellknown" @@ -69,10 +83,11 @@ #: a newer MINOR may carry others; they are ignored with a warning (AGSC-00-21, #: AGSC-09-93). KNOWN_ATTRIBUTES = frozenset([ - "agsc-access", "agsc-bundle-hash", "agsc-bundle-version", "agsc-contribute-mode", - "agsc-counts", "agsc-generated-at", "agsc-ledger-head", "agsc-spec-version", - "agsc-surface", "agsc-surface-version", "agsc-tombstone", "agsc-visibility", "digest", - "hreflang", "media", "profile", "title", "title*", "type", + "agsc-access", "agsc-bundle-hash", "agsc-bundle-version", "agsc-chunk-count", + "agsc-chunk-set", "agsc-contribute-mode", "agsc-counts", "agsc-generated-at", + "agsc-ledger-head", "agsc-ledger-length", "agsc-spec-version", "agsc-surface", + "agsc-surface-version", "agsc-tombstone", "agsc-visibility", "digest", "hreflang", + "media", "profile", "title", "title*", "type", ]) #: RFC 9264 section 4.2.4.1: the target attributes whose value is a plain string. STRING_ATTRIBUTES = frozenset(["type", "title", "media"]) @@ -106,6 +121,8 @@ NO_CACHE = ("/.well-known/knowledge-linkset", "/now.md", "/ledger.jsonl") #: AGSC-11-03: the response headers a public artefact exposes to another origin. EXPOSED = ("Link", "ETag", "Content-Type") +#: AGSC-06-06, AGSC-11-05: the versioned copies, the only routes that may be immutable. +VERSIONED = re.compile(r"^/ns/\d+\.\d+\.\d+/") _PRIVATE_SURFACE = re.compile(r"^x-[a-z0-9]+(-[a-z0-9]+)+$") _DIGEST = re.compile(r"^sha-256=:[A-Za-z0-9+/]{43}=:$") @@ -122,7 +139,7 @@ class Source(object): """One document to check, with the way its targets are resolved.""" def __init__(self, kind, name, data, headers=None, site_root=None, fetcher=None, dev=False, - retrieved_from=None): + retrieved_from=None, budget=None, site_files=None): self.kind = kind self.name = name #: the URL the document was finally read from, after redirects (AGSC-06-08) @@ -133,20 +150,32 @@ def __init__(self, kind, name, data, headers=None, site_root=None, fetcher=None, self.fetcher = fetcher self.dev = dev self.reads = 1 - #: (final URL, response headers) of every target this run fetched + #: the requests the run may still send (AGSC-11-10(c)), shared with its peer + self.budget = budget if budget is not None else RequestBudget() + #: route -> bytes of a build output held in memory instead of on disk + self.site_files = site_files + #: (final URL, response headers) of every target whose headers are checked self.fetched = [] - def resolve_target(self, href, anchor): - """The bytes of one target, or None when it cannot be checked offline.""" + def resolve_target(self, href, anchor, checked=True): + """The bytes of one target, or None when it cannot be checked offline. + + ``checked``: the response headers of a target read from a URL are checked + (AGSC-09-93); the engine reads the card, the ledger length and the chunk + shards without that check, so those reads pass False.""" if self.kind == "memory": # An in-memory document has no site beside it: every digest target is # "not checkable offline", never an I/O error. return None if self.kind == "url": self.reads += 1 - final, headers, body = self.fetcher(href, self.dev, cap=TARGET_MAX_BYTES) - self.fetched.append((final, headers)) + final, headers, body = counted(self.fetcher, href, self.dev, TARGET_MAX_BYTES, + self.budget) + if checked: + self.fetched.append((final, headers)) return body + if self.site_files is not None: + return self._resolve_in_memory(href, anchor) if self.site_root is None: raise TransportError( "AGSC-E901", @@ -162,12 +191,27 @@ def resolve_target(self, href, anchor): candidate = os.path.normpath(os.path.join(self.site_root, "." + path)) if not candidate.startswith(self.site_root + os.sep): raise TransportError("AGSC-E902", "path escapes the site root: %s" % href) - if not os.path.exists(candidate): + # A directory is not a target: the engine reads it as a target it cannot + # read, and a document path that names one is AGSC-E901 in both tools. + if not os.path.isfile(candidate): raise TransportError("AGSC-E901", "target not found on disk: %s" % path) self.reads += 1 with open(candidate, "rb") as handle: return handle.read() + def _resolve_in_memory(self, href, anchor): + """A target of a build output held as route -> bytes, read as from disk.""" + target = Url(href) + if target.origin != Url(anchor).origin: + return None + path = decoded_path(target) + if path.endswith("/"): + path += "index.html" + if path not in self.site_files: + raise TransportError("AGSC-E901", "target not found on disk: %s" % path) + self.reads += 1 + return self.site_files[path] + def from_value(document, name="(memory)"): """An in-memory source; a value is written in its canonical form plus one LF.""" @@ -178,7 +222,16 @@ def from_value(document, name="(memory)"): return Source("memory", name, data) -def load(target, allow_network=False, fetcher=None, dev=False): +def from_build(document, files, name="(build)"): + """A build output held in memory: the discovery document and the files it links + (route -> bytes or text), checked exactly as the same files on disk would be.""" + held = dict((route, text.encode("utf-8") if isinstance(text, str) else bytes(text)) + for route, text in files.items()) + source = from_value(document, name) + return Source("file", name, source.data, site_files=held) + + +def load(target, allow_network=False, fetcher=None, dev=False, budget=None): """Open a document, from a file always and from a URL only when allowed.""" if is_url_argument(target): if not allow_network: @@ -189,9 +242,10 @@ def load(target, allow_network=False, fetcher=None, dev=False): ) if fetcher is None: # pragma: no cover - the CLI always supplies one from .net import fetch as fetcher # noqa: F811 - final, headers, body = fetcher(target, dev, cap=MAX_BYTES) + budget = budget if budget is not None else RequestBudget() + final, headers, body = counted(fetcher, target, dev, MAX_BYTES, budget) return Source("url", target, body, headers=headers, fetcher=fetcher, dev=dev, - retrieved_from=final) + retrieved_from=final, budget=budget) path = os.path.abspath(target) if not os.path.isfile(path): raise TransportError("AGSC-E901", "file not found: %s" % target) @@ -265,8 +319,9 @@ def _tokens(value): return [one.strip().lower() for one in (value or "").split(",") if one.strip()] -def header_shortfalls(headers, cors, no_cache): - """One response's shortfalls against AGSC-11-03 (when ``cors``) and AGSC-11-05.""" +def header_shortfalls(headers, cors, no_cache, versioned=False): + """One response's shortfalls against AGSC-11-03 (when ``cors``) and AGSC-11-05; + ``versioned``: the route is a copy under ``/ns//`` (AGSC-06-06).""" out = [] if cors: origin = _header_values(headers, "access-control-allow-origin") @@ -293,8 +348,8 @@ def header_shortfalls(headers, cors, no_cache): if no_cache and "no-cache" not in _tokens(cache): out.append(("AGSC-E202", "Cache-Control is %s, not no-cache (AGSC-11-05)" % _compact(cache or ""))) - if "immutable" in _tokens(cache): - out.append(("AGSC-E201", "Cache-Control carries immutable, which no 1.0 route may " + if "immutable" in _tokens(cache) and not versioned: + out.append(("AGSC-E201", "Cache-Control carries immutable, which only /ns// may " "(AGSC-11-05)")) return out @@ -319,12 +374,25 @@ def _check_headers(source, anchor, restricted, level, report): lowered = {str(name).lower(): value for name, value in headers.items()} for code, message in header_shortfalls( lowered, cors=is_document or not restricted, - no_cache=is_document or url.pathname in NO_CACHE): + no_cache=is_document or url.pathname in NO_CACHE, + versioned=VERSIONED.match(url.pathname) is not None): report(code, "%s: %s" % (final, message), severity=severity) -def check(source, level, findings, dev=False): - """Check one document, appending findings. Returns the anchor and the peers.""" +def _is_date(text): + """AGSC-11-16: a ``YYYY-MM-DD`` value that names a day of the calendar (not ``2026-13-45``).""" + if re.match(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}\Z", text) is None: + return False + # calendar, not datetime: the engine accepts year 0000 (a leap year), and datetime has no year 0. + year, month, day = (int(part) for part in text.split("-")) + return 1 <= month <= 12 and 1 <= day <= calendar.monthrange(year, month)[1] + + +def check(source, level, findings, dev=False, spec_version=SPEC_VERSION): + """Check one document, appending findings. Returns the anchor and the peers. + + ``spec_version`` is the specification version the reader implements, the one + constant ``SPEC_VERSION`` unless a case states its reader (disc-0023).""" def report(code, message, severity="error"): findings.append(finding(code, source.name, message, severity=severity)) @@ -456,7 +524,7 @@ def report(code, message, severity="error"): # node claiming it publishes /ledger.jsonl and links it. report("AGSC-E202", "no rel#ledger link: a Level >= 2 node publishes /ledger.jsonl " "and links it (AGSC-10-04, AGSC-09-93)") - declared, newer = _declared_version(context) + declared, newer = _declared_version(context, spec_version) bundle_version = graph_link.get("agsc-bundle-version") if isinstance(bundle_version, list): if len(bundle_version) != 1: @@ -593,17 +661,21 @@ def report(code, message, severity="error"): and "agsc-ledger-head" not in target: report("AGSC-E202", "rel#ledger: agsc-ledger-head is required at Level >= 2 (AGSC-06-08)") + if extension == "ledger": + ledger_length_findings(target, href, raw_anchor, source, level, report) if relation in RELATED_ONLY and not isinstance(target.get("type"), str): report("AGSC-E209", "related-system link %s %s must carry type (AGSC-06-35)" % (relation, href)) if extension == "peer": peers.append(href) if extension == "surface": - _check_surface(target, href, parsed, raw_anchor, source, report) + _check_surface(target, href, parsed, raw_anchor, source, report, + (declared, level)) if extension == "access" and restricted: _check_access_target(target, href, report) _check_headers(source, anchor, restricted, level, report) + check_home_link(source, raw_anchor, findings) return {"anchor": raw_anchor, "peers": peers} @@ -644,16 +716,16 @@ def _graph_link(context): return {} -def _declared_version(context): +def _declared_version(context, own=SPEC_VERSION): """AGSC-00-21 / AGSC-09-93: the ``agsc-spec-version`` the document declares on the - describedby link to its graph, and whether it is this checker's MAJOR with a newer - MINOR. Only then are unknown relations and attributes ignored; a document of - another MAJOR has no such tolerance.""" + describedby link to its graph, and whether it is the reader's (``own``) MAJOR with + a newer MINOR. Only then are unknown relations and attributes ignored; a document + of another MAJOR has no such tolerance.""" value = _graph_link(context).get("agsc-spec-version") if not isinstance(value, list) or not value: return None, False declared = str(value[0]) - theirs, mine = _major_minor(declared), _major_minor(SPEC_VERSION) + theirs, mine = _major_minor(declared), _major_minor(own) newer = theirs is not None and mine is not None and theirs[0] == mine[0] \ and theirs[1] > mine[1] return declared, newer @@ -661,12 +733,17 @@ def _declared_version(context): -def _check_surface(target, href, parsed, anchor, source, report): - """The AGSC-11-16 declaration checks for one rel#surface target.""" - declared = target.get("agsc-surface") +def _check_surface(target, href, parsed, anchor, source, report, document): + """The AGSC-11-16 declaration checks for one rel#surface target; ``document`` is + the (declared version, Level) of the document it belongs to. An ``llms-txt`` + target and the target of public ``chunks`` must resolve; the ``chunks`` of a + restricted node declare ``credential`` and are not served unauthenticated + (AGSC-11-20), so they are not read.""" + surface_values = target.get("agsc-surface") access = target.get("agsc-access") version = target.get("agsc-surface-version") - name = declared[0] if isinstance(declared, list) and len(declared) == 1 else None + name = surface_values[0] if isinstance(surface_values, list) and len(surface_values) == 1 \ + else None if name is None: report("AGSC-E210", "rel#surface %s: agsc-surface must carry exactly one value (AGSC-11-16)" % href) @@ -688,15 +765,29 @@ def _check_surface(target, href, parsed, anchor, source, report): report("AGSC-E210", "rel#surface %s: agsc-surface-version must be absent for %s (AGSC-11-16)" % (href, name)) + if name == "webmcp" and isinstance(version, list) and len(version) == 1 \ + and not _is_date(str(version[0])): + report("AGSC-E210", + "rel#surface %s: the agsc-surface-version of webmcp is a date YYYY-MM-DD, not %s " + "(AGSC-11-16)" % (href, _compact(version[0]))) if name == "llms-txt" and parsed.pathname != "/llms.txt" \ and not parsed.pathname.endswith("/llms.txt"): report("AGSC-E210", "rel#surface llms-txt must target /llms.txt (AGSC-11-16)") - if name in ("llms-txt", "chunks"): + declared_version, level = document + public_chunks = name == "chunks" and not (isinstance(access, list) and access + and access[0] == "credential") + if public_chunks: + chunk_facts_missing(target, href, declared_version, level, report) + if name == "llms-txt" or public_chunks: try: - source.resolve_target(href, anchor) + data = source.resolve_target(href, anchor) + if public_chunks and data is not None: + chunk_facts_findings(target, href, data, anchor, source, level, report) except TransportError as error: - report("AGSC-E210", + report("AGSC-E906" if error.code == "AGSC-E906" else "AGSC-E210", "rel#surface %s: target does not resolve: %s" % (name, error.message)) + if name == "a2a-card": + card_target_findings(href, parsed, anchor, source, report) def canonical_wellknown(result): @@ -720,14 +811,20 @@ def mutual_findings(first_name, first, second_name, second): return out -def validate(target, level=0, peer=None, dev=False, allow_network=False, fetcher=None): - """Check one document, and a peer when given. Returns (envelope, files read).""" +def validate(target, level=0, peer=None, dev=False, allow_network=False, fetcher=None, + max_requests=None): + """Check one document, and a peer when given. Returns (envelope, files read). + + ``max_requests``: the run's request budget (default ``federation.max_requests``' + 500, AGSC-11-06), shared by the document, its targets and the peer.""" findings = [] reads = [0] + budget = RequestBudget() if max_requests is None else RequestBudget(max_requests) def run(name): try: - source = load(name, allow_network=allow_network, fetcher=fetcher, dev=dev) + source = load(name, allow_network=allow_network, fetcher=fetcher, dev=dev, + budget=budget) except TransportError as error: reads[0] += 1 findings.append(finding(error.code, name, error.message)) diff --git a/src/agentic_system_core/wellknown_facts.py b/src/agentic_system_core/wellknown_facts.py new file mode 100644 index 0000000..d424fa6 --- /dev/null +++ b/src/agentic_system_core/wellknown_facts.py @@ -0,0 +1,213 @@ +"""What a discovery document states about the files it links, checked against them. + +The 1.1 checks of the discovery-file checker (``wellknown.py``) that read a linked file +rather than the document alone, each the twin of a function of the engine's +``tools/validate-wellknown``: + +* ``chunk_facts_missing`` and ``chunk_facts_findings`` — at Level 2 and above, the + chunks surface link of a document of 1.1.0 or later states ``digest``, + ``agsc-chunk-count`` and ``agsc-chunk-set``, and the count and the set commitment are + recomputed over the chunk lines read (AGSC-06-44, AGSC-09-93 (b)); + ``requireChunkFacts`` and ``recomputeChunkFacts`` in the engine; +* ``ledger_length_findings`` — an ``agsc-ledger-length`` is the number of entries of + the ledger read (AGSC-06-44, AGSC-09-93 (c)); ``checkLedgerLength``; +* ``card_target_findings`` — an ``a2a-card`` declared on the node's own origin names a + card the node serves, else the warning AGSC-E210 (AGSC-11-16); ``checkCardTarget``; +* ``home_link_findings`` — given a URL, the ``Link`` header of the node's home page + carries the ``describedby`` link to the discovery document, else the warning + AGSC-E202, because AGSC-06-25 makes that header a SHOULD (AGSC-06-40); + ``homeLinkFindings`` and ``checkHomeLink``. + +Each takes the ``report`` callable of one run and the ``Source`` the targets are read +through, so the codes, severities and the reads counted are the engine's. Standard +library only; the ``Link`` values are split as RFC 8288 section 3 writes them, with no +parser library, as the engine's standalone tool does (AGSC-09-90). +""" + +import base64 +import hashlib +import json +import re + +from . import WELLKNOWN_SUFFIX +from .diagnostics import finding +from .net import TARGET_MAX_BYTES, TransportError, counted +from .urls import Url, resolve + +#: AGSC-06-44: what the chunks surface link of a public node states from 1.1 on. +CHUNK_ATTRIBUTES = ("digest", "agsc-chunk-count", "agsc-chunk-set") + +_MAJOR_MINOR = re.compile(r"^(\d+)\.(\d+)(?:\.|$)") +_FIELD_VALUES = re.compile(r",(?=\s*<)") +_LINK_VALUE = re.compile(r"^\s*<([^>]*)>(.*)$", re.DOTALL) +_REL = re.compile(r';\s*rel\s*=\s*(?:"([^"]*)"|([^;,\s]+))', re.IGNORECASE) + + +def from_one_one(declared): + """True when ``declared`` (an ``agsc-spec-version``) is 1.1.0 or later.""" + match = _MAJOR_MINOR.match(str(declared)) + return match is not None and (int(match.group(1)), int(match.group(2))) >= (1, 1) + + +def _stated(target, name): + value = target.get(name) + return value[0] if isinstance(value, list) and len(value) == 1 else None + + +def chunk_facts_missing(target, href, declared, level, report): + """AGSC-09-93 (b), AGSC-06-44: at Level 2 and above a document of 1.1.0 or later + states the three facts on its public chunks link; each one absent is AGSC-E202.""" + if level < 2 or not from_one_one(declared): + return + for name in CHUNK_ATTRIBUTES: + if name not in target: + report("AGSC-E202", "rel#surface %s: the chunks surface link of a %s document carries " + "no %s (required at Level >= 2, AGSC-06-44)" % (href, declared, name)) + + +def _js_string(value): + """The text JavaScript's ``String()`` gives a value a JSON line can hold, as the + engine joins each chunk ``id`` into the set commitment.""" + if isinstance(value, bool): + return "true" if value else "false" + if value is None: + return "null" + if isinstance(value, float) and value.is_integer(): + return str(int(value)) + if isinstance(value, list): + return ",".join("" if one is None else _js_string(one) for one in value) + if isinstance(value, dict): + return "[object Object]" + return str(value) + + +def _refuse_constant(name): + raise ValueError("%s is not JSON" % name) + + +def _lines(data): + """The JSON lines of a file, read as the engine reads them (``JSON.parse`` of each + non-empty line of the UTF-8 text, so ``NaN`` is refused).""" + text = data.decode("utf-8", "replace") + return [json.loads(line, parse_constant=_refuse_constant) + for line in text.split("\n") if line != ""] + + +def _chunk_lines(data, href, anchor, source): + """The chunk lines a chunks file holds: its own lines or, when it is the manifest of + AGSC-06-31 (one object with ``shards`` and no ``id``), the lines of every shard in + manifest order. A shard on another origin is not read from disk.""" + lines = _lines(data) + manifest = lines[0] if len(lines) == 1 else None + if not (isinstance(manifest, dict) and isinstance(manifest.get("shards"), list) + and "id" not in manifest): + return lines + out = [] + for shard in manifest["shards"]: + part = source.resolve_target(resolve(href, _js_string(shard)), anchor, checked=False) + if part is not None: + out.extend(_lines(part)) + return out + + +def _chunk_id(line): + if not isinstance(line, dict): + if line is None: + raise ValueError("a chunk line is null") + return "undefined" + return _js_string(line["id"]) if "id" in line else "undefined" + + +def chunk_facts_findings(target, href, data, anchor, source, level, report): + """AGSC-09-93 (b), AGSC-06-44: the count and the set commitment, recomputed over the + lines read: the commitment is the SHA-256 over each ``id`` and one LF, in file + order. (The ``digest`` is recomputed with every other digest.)""" + if level < 2 or ("agsc-chunk-count" not in target and "agsc-chunk-set" not in target): + return + try: + lines = _chunk_lines(data, href, anchor, source) + joined = "".join(_chunk_id(line) + "\n" for line in lines) + except (ValueError, TransportError) as error: + report("AGSC-E201", "rel#surface %s: the chunk lines cannot be read to recompute " + "agsc-chunk-count and agsc-chunk-set: %s" % (href, error)) + return + commitment = "sha-256=:%s:" % base64.b64encode( + hashlib.sha256(joined.encode("utf-8")).digest()).decode("ascii") + if "agsc-chunk-count" in target and _stated(target, "agsc-chunk-count") != str(len(lines)): + report("AGSC-E201", "rel#surface %s: agsc-chunk-count %s is not the %d lines of the " + "fetched file (AGSC-06-44)" + % (href, json.dumps(target["agsc-chunk-count"]), len(lines))) + if "agsc-chunk-set" in target and _stated(target, "agsc-chunk-set") != commitment: + report("AGSC-E201", "rel#surface %s: agsc-chunk-set does not match the ids of the " + "fetched lines (AGSC-06-44)" % href) + + +def ledger_length_findings(target, href, anchor, source, level, report): + """AGSC-09-93 (c), AGSC-06-44: an ``agsc-ledger-length``, when present, is the number + of entries of the ledger read: from a file at every Level, from a URL at Level 2 + and above.""" + if "agsc-ledger-length" not in target or (level < 2 and source.kind != "file"): + return + try: + data = source.resolve_target(href, anchor, checked=False) + except TransportError as error: + report(error.code, "rel#ledger: %s" % error.message) + return + if data is None: + return + entries = len([line for line in data.decode("utf-8", "replace").split("\n") if line != ""]) + value = target["agsc-ledger-length"] + if not (isinstance(value, list) and len(value) == 1 and value[0] == str(entries)): + report("AGSC-E201", "rel#ledger %s: agsc-ledger-length %s is not the %d entries of the " + "fetched ledger (AGSC-06-44)" % (href, json.dumps(value), entries)) + + +def card_target_findings(href, parsed, anchor, source, report): + """AGSC-11-16: an ``a2a-card`` declared on the node's own origin names a card the node + serves. A warning, not an error: a 1.0 node declared the surface and served no card + (decision D-15). A card on another origin is not read, the surface being + declaration-only (AGSC-11-17).""" + if parsed.origin != Url(anchor).origin: + return + try: + source.resolve_target(href, anchor, checked=False) + except TransportError as error: + if error.code == "AGSC-E906": + report("AGSC-E906", "rel#surface a2a-card: %s" % error.message) + return + report("AGSC-E210", "rel#surface a2a-card: the declared card %s is not served by this " + "node: %s (AGSC-11-16)" % (href, error.message), severity="warn") + + +def home_link_findings(values, anchor="https://invalid.example/", file="/"): + """AGSC-06-40 with AGSC-06-25: the values of the ``Link`` header of ``/`` carry a + ``describedby`` link whose target, resolved against the anchor, is the discovery + document. Its absence is the warning AGSC-E202: the header is a SHOULD.""" + wellknown = resolve(anchor, ".well-known/" + WELLKNOWN_SUFFIX) + listed = values if isinstance(values, (list, tuple)) else ([] if values is None else [values]) + for one in _FIELD_VALUES.split(",".join(str(value) for value in listed)): + match = _LINK_VALUE.match(one) + relation = _REL.search(match.group(2)) if match is not None else None + if relation is None or resolve(anchor, match.group(1)) != wellknown: + continue + if "describedby" in (relation.group(1) or relation.group(2)).lower().split(): + return [] + return [finding("AGSC-E202", file, "the Link header of / carries no describedby link to %s " + "(AGSC-06-25, AGSC-06-40: a SHOULD)" % wellknown, + severity="warn")] + + +def check_home_link(source, anchor, findings): + """AGSC-06-40: given a URL, the ``Link`` header of the node's home page, the anchor. + The request counts against the run's budget but is not one of the files read.""" + if source.kind != "url": + return + try: + _, headers, _ = counted(source.fetcher, anchor, source.dev, TARGET_MAX_BYTES, + source.budget) + except TransportError as error: + findings.append(finding("AGSC-E202", anchor, "the Link header of / could not be read: %s " + "(AGSC-06-25, AGSC-06-40)" % error.message, + severity="warn")) + return + findings.extend(home_link_findings(headers.get("link"), anchor=anchor, file=anchor)) diff --git a/src/agentic_system_core/yamlsubset.py b/src/agentic_system_core/yamlsubset.py index cf8954c..a869316 100644 --- a/src/agentic_system_core/yamlsubset.py +++ b/src/agentic_system_core/yamlsubset.py @@ -13,7 +13,9 @@ Every error carries the 1-based line of the file it was found on. Each mapping records the line of each of its keys in ``lines`` so a later check can point at -the key it faults. Standard library only; no general YAML library is involved, +the key it faults. A block sequence is a :class:`Sequence`, so :func:`depth` can +count block nesting (the 64-level bound of AGSC-02-02, 1.1) apart from flow +sequences. Standard library only; no general YAML library is involved, so nothing outside the subset can be accepted by accident. """ @@ -36,6 +38,27 @@ def __init__(self): self.lines = {} +class Sequence(list): + """A block sequence; a flow sequence of scalars is a plain list, a value.""" + + +#: AGSC-02-02 (1.1): the deepest nesting of block collections a tool must handle. +NESTING_BOUND = 64 + + +def depth(value): + """The deepest nesting of block mappings and block sequences in ``value``: the + frontmatter mapping is level 1, each block collection inside a value adds one, and + a flow sequence of scalars adds none (AGSC-02-02, 1.1).""" + if isinstance(value, Mapping): + children = value.values() + elif isinstance(value, Sequence): + children = value + else: + return 0 + return 1 + max([depth(child) for child in children] + [0]) + + _KEY = re.compile(r"^([^\s'\"#][^:#]*?|'[^']*'|\"(?:[^\"\\]|\\.)*\")[ \t]*:(?:[ \t]+|$)(.*)$") _ESCAPES = {"0": "\0", "a": "\a", "b": "\b", "t": "\t", "\t": "\t", "n": "\n", "v": "\v", "f": "\f", "r": "\r", "e": "\x1b", " ": " ", '"': '"', "/": "/", "\\": "\\", @@ -244,7 +267,7 @@ def mapping(self, indent): out[key] = self.value(rest, indent, line, in_sequence=False) def sequence(self, indent): - out = [] + out = Sequence() while True: text = self.peek() if text is None or _indent(text) != indent: diff --git a/tests/README.md b/tests/README.md index dc4c60d..408257a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -3,9 +3,11 @@ **Summary.** The tests of the package: each module on fixed data, the command line, the seven vector areas over byte-identical copies of the engine's vectors, the equivalence of the discovery-file checker with the engine's own, and the two CI workflows. -Deterministic: no clock, no network. The subprocesses are the engine's Node checker and -vector runner in the two equivalence tests, skipped with a message when Node or the -engine checkout is absent, and the workflow steps that `test_ci_workflows.py` runs as +Deterministic: no clock, no network. The subprocesses are the engine's Node checker, +vector runner, JSON-LD writer, relation table, Link readings and build in the +equivalence, parity and cross-check tests, +skipped with a message when Node or the engine checkout is absent (the checkout is +`../agentic-system-core`, or the one `AGSC_ENGINE_DIR` names), and the workflow steps that `test_ci_workflows.py` runs as written on scratch input (Python, bash, and git on a scratch repository with fixed dates). @@ -18,6 +20,6 @@ python -m venv .venv && .venv/bin/pip install -e ".[test]" | Path | What it holds | |---|---| -| `test_*.py` | one file per module or concern; `test_equivalence.py` compares the two checkers, `test_area_handlers.py` runs the vector areas, `test_ci_workflows.py` checks the test and release workflows | +| `test_*.py` | one file per module or concern; `test_equivalence.py` compares the two checkers (on the fixture cases and on the minimal fixture and the demonstration node built by the engine), `test_wellknown_facts.py` states the checker's 1.1 checks (chunk facts, ledger length, agent card, the `Link` header of `/`, the request budget), `test_web_connection.py` the Signposting links, Dataset block, catalogue files and agent card, `test_area_handlers.py` runs the vector areas, `test_graph_jsonld.py` compares the `graph.jsonld` writer with the engine's, `test_build_cross_check.py` checks the engine's build of `build-0020` to `build-0028`, `test_relations.py` checks the relation table against the engine's, `test_link_parity.py` compares the Link warnings, readings and ten questions with the engine's on 120 seeded generated graphs, `test_architecture.py` holds the package's shape (standard library only, one process starter, one source for the relation table, one module that opens a connection), `test_ci_workflows.py` checks the test and release workflows | | `fixtures/vectors/` | copies of the engine's vectors for the seven areas; a test fails if they drift from the engine beside this repository | | `fixtures/wellknown/`, `fixtures/conformance/` | discovery documents and conformance inputs | diff --git a/tests/conftest.py b/tests/conftest.py index ff83f30..ed64904 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,7 +14,22 @@ #: needs the engine; the two site tests need the built sites. Every other test #: runs without any of them, and each one says so when it is skipped. NEIGHBOURS = HERE.parent.parent -ENGINE = NEIGHBOURS / "agentic-system-core" + +#: The environment variable that names another engine checkout (a second worktree +#: of a release branch, say). Unset or empty: the sibling ``../agentic-system-core``. +ENGINE_DIR_VARIABLE = "AGSC_ENGINE_DIR" + + +def engine_dir(environ): + """The engine checkout the suite compares with: ``AGSC_ENGINE_DIR`` when it is set + (a relative value is read from the working directory), else the sibling checkout.""" + value = environ.get(ENGINE_DIR_VARIABLE) + if value: + return pathlib.Path(value).resolve() + return NEIGHBOURS / "agentic-system-core" + + +ENGINE = engine_dir(os.environ) #: The built discovery files of the two nodes, when their checkouts are here. SITE_DOCUMENTS = [ diff --git a/tests/fixtures/vectors/build/build-0001-search-tokenizer.json b/tests/fixtures/vectors/build/build-0001-search-tokenizer.json index 349d441..604458c 100644 --- a/tests/fixtures/vectors/build/build-0001-search-tokenizer.json +++ b/tests/fixtures/vectors/build/build-0001-search-tokenizer.json @@ -126,7 +126,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-23" } diff --git a/tests/fixtures/vectors/build/build-0002-tokenizer-non-latin.json b/tests/fixtures/vectors/build/build-0002-tokenizer-non-latin.json index a6238ba..df7e167 100644 --- a/tests/fixtures/vectors/build/build-0002-tokenizer-non-latin.json +++ b/tests/fixtures/vectors/build/build-0002-tokenizer-non-latin.json @@ -54,7 +54,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0", + "spec_version": "1.1.0", "unicode_version": "16.0.0" }, "rule": "AGSC-06-23" diff --git a/tests/fixtures/vectors/build/build-0003-search-astral-member-order.json b/tests/fixtures/vectors/build/build-0003-search-astral-member-order.json index 05406dc..670c5da 100644 --- a/tests/fixtures/vectors/build/build-0003-search-astral-member-order.json +++ b/tests/fixtures/vectors/build/build-0003-search-astral-member-order.json @@ -50,7 +50,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-16" } diff --git a/tests/fixtures/vectors/build/build-0011-static-fragment-index-arrays.json b/tests/fixtures/vectors/build/build-0011-static-fragment-index-arrays.json index 6a2c1e6..ef9783e 100644 --- a/tests/fixtures/vectors/build/build-0011-static-fragment-index-arrays.json +++ b/tests/fixtures/vectors/build/build-0011-static-fragment-index-arrays.json @@ -21,7 +21,7 @@ }, "level": "optional", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-33" } diff --git a/tests/fixtures/vectors/build/build-0012-headers-and-redirect.json b/tests/fixtures/vectors/build/build-0012-headers-and-redirect.json index b705463..ee71062 100644 --- a/tests/fixtures/vectors/build/build-0012-headers-and-redirect.json +++ b/tests/fixtures/vectors/build/build-0012-headers-and-redirect.json @@ -15,7 +15,7 @@ }, "level": "withdrawn", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "reason": "Withdrawn for 1.0.0 (2026-10-10). The case asserted only two of the five Content-Security-Policy directives AGSC-06-17 requires: the rule, amended on 2026-10-02 for 1.0.0, also requires style-src 'self', img-src 'self' and connect-src 'self', and says that the policy admits no inline script. It also asserted the legacy redirect, which the same rule makes a SHOULD. Superseded by build-0018, which asserts all five directives and that no inline script is admitted.", "rule": "AGSC-06-17", diff --git a/tests/fixtures/vectors/build/build-0013-security-txt-fields.json b/tests/fixtures/vectors/build/build-0013-security-txt-fields.json index 45ffbe4..199bc3c 100644 --- a/tests/fixtures/vectors/build/build-0013-security-txt-fields.json +++ b/tests/fixtures/vectors/build/build-0013-security-txt-fields.json @@ -99,7 +99,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-36" } diff --git a/tests/fixtures/vectors/build/build-0014-content-version-derivation.json b/tests/fixtures/vectors/build/build-0014-content-version-derivation.json index aaa3422..24bd7ee 100644 --- a/tests/fixtures/vectors/build/build-0014-content-version-derivation.json +++ b/tests/fixtures/vectors/build/build-0014-content-version-derivation.json @@ -167,7 +167,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-25" } diff --git a/tests/fixtures/vectors/build/build-0015-every-text-file-ends-with-one-lf.json b/tests/fixtures/vectors/build/build-0015-every-text-file-ends-with-one-lf.json index 844eee0..ca38e7a 100644 --- a/tests/fixtures/vectors/build/build-0015-every-text-file-ends-with-one-lf.json +++ b/tests/fixtures/vectors/build/build-0015-every-text-file-ends-with-one-lf.json @@ -18,7 +18,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-07" } diff --git a/tests/fixtures/vectors/build/build-0016-stale-by-instant-comparison.json b/tests/fixtures/vectors/build/build-0016-stale-by-instant-comparison.json index 5735401..9f22544 100644 --- a/tests/fixtures/vectors/build/build-0016-stale-by-instant-comparison.json +++ b/tests/fixtures/vectors/build/build-0016-stale-by-instant-comparison.json @@ -33,7 +33,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-11" } diff --git a/tests/fixtures/vectors/build/build-0017-asset-references-build-byte-identically.json b/tests/fixtures/vectors/build/build-0017-asset-references-build-byte-identically.json index e7bdc6f..7e25613 100644 --- a/tests/fixtures/vectors/build/build-0017-asset-references-build-byte-identically.json +++ b/tests/fixtures/vectors/build/build-0017-asset-references-build-byte-identically.json @@ -27,7 +27,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-02" } diff --git a/tests/fixtures/vectors/build/build-0018-page-policy-contains-five-directives.json b/tests/fixtures/vectors/build/build-0018-page-policy-contains-five-directives.json index 9cfa3cc..c821619 100644 --- a/tests/fixtures/vectors/build/build-0018-page-policy-contains-five-directives.json +++ b/tests/fixtures/vectors/build/build-0018-page-policy-contains-five-directives.json @@ -36,7 +36,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-17" } diff --git a/tests/fixtures/vectors/build/build-0019-search-index-above-500-items.json b/tests/fixtures/vectors/build/build-0019-search-index-above-500-items.json index 47b8f79..609f680 100644 --- a/tests/fixtures/vectors/build/build-0019-search-index-above-500-items.json +++ b/tests/fixtures/vectors/build/build-0019-search-index-above-500-items.json @@ -2034,7 +2034,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-21" } diff --git a/tests/fixtures/vectors/build/build-0020-retired-and-draft-items-on-each-surface.json b/tests/fixtures/vectors/build/build-0020-retired-and-draft-items-on-each-surface.json index 31c4d0e..901ff8e 100644 --- a/tests/fixtures/vectors/build/build-0020-retired-and-draft-items-on-each-surface.json +++ b/tests/fixtures/vectors/build/build-0020-retired-and-draft-items-on-each-surface.json @@ -104,7 +104,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-00-05" } diff --git a/tests/fixtures/vectors/build/build-0021-build-out-naming-content-or-dist-is-refused.json b/tests/fixtures/vectors/build/build-0021-build-out-naming-content-or-dist-is-refused.json index 479ddf1..12bbc39 100644 --- a/tests/fixtures/vectors/build/build-0021-build-out-naming-content-or-dist-is-refused.json +++ b/tests/fixtures/vectors/build/build-0021-build-out-naming-content-or-dist-is-refused.json @@ -129,7 +129,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-19" } diff --git a/tests/fixtures/vectors/build/build-0022-release-switchboard-holds-an-item-back-everywhere.json b/tests/fixtures/vectors/build/build-0022-release-switchboard-holds-an-item-back-everywhere.json index 1cf377b..6c8bf57 100644 --- a/tests/fixtures/vectors/build/build-0022-release-switchboard-holds-an-item-back-everywhere.json +++ b/tests/fixtures/vectors/build/build-0022-release-switchboard-holds-an-item-back-everywhere.json @@ -48,7 +48,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-20" } diff --git a/tests/fixtures/vectors/build/build-0023-page-copy-drops-a-link-to-a-draft.json b/tests/fixtures/vectors/build/build-0023-page-copy-drops-a-link-to-a-draft.json index 4f9b3b7..af682cb 100644 --- a/tests/fixtures/vectors/build/build-0023-page-copy-drops-a-link-to-a-draft.json +++ b/tests/fixtures/vectors/build/build-0023-page-copy-drops-a-link-to-a-draft.json @@ -22,7 +22,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-07" } diff --git a/tests/fixtures/vectors/build/build-0024-the-whole-route-set-of-the-minimal-fixture.json b/tests/fixtures/vectors/build/build-0024-the-whole-route-set-of-the-minimal-fixture.json index 98085cf..253acc3 100644 --- a/tests/fixtures/vectors/build/build-0024-the-whole-route-set-of-the-minimal-fixture.json +++ b/tests/fixtures/vectors/build/build-0024-the-whole-route-set-of-the-minimal-fixture.json @@ -2,57 +2,7 @@ "area": "build", "description": "AGSC-06-01: a writer MUST emit exactly the route set the rule lists, with the conditional routes only under their conditions. Derivation, by hand from the rule, over the minimal fixture (two concepts, handoff and supervisor; one cluster, agent-patterns; the tags agents and patterns; an authored .well-known/security.txt with a Contact field; no LICENSE-CONTENT, no authored /about/, no task item, no asset) built with SOURCE_DATE_EPOCH set and no git history, for the Cloudflare Pages deployment profile: the home page, the five type indexes, the two concept pages, the cluster index and page, the two tag pages, /search/ with /search.json, /now/ and /now.md, /compose/, /skills/ with its index and the one pack, the two context routes of /ns/ (the second named by the vocabulary version 1.0.0), the three graph exports, the six per-item copies, /llms.txt and /llms-full.txt, /sitemap.xml, /robots.txt, /.well-known/tdmrep.json, /chunks.jsonl, the discovery document, /.well-known/security.txt, /404.html, _headers and _redirects: 42 routes. Absent by their conditions: /legal/, /about/, /changelog/ and /ledger.jsonl (no git-log file), /boards/**, /conformance/, the agent card, the VoID description, /assets/, /specs/**, shards and index pages and /graph/fragments/**. A route ending in / is served as its index.html. The route set does not bound the same-origin presentation and script files a page of the set loads: the three the specification names (page_assets_required) are emitted, and every other emitted file is a .js or .css file that some emitted page loads by a script src or a stylesheet link (other_files_are_page_assets).", "expected": { - "no_error_finding": true, - "other_files_are_page_assets": true, - "page_assets_required": [ - "/assets/site.css", - "/assets/theme.js", - "/search/agsc-search.js" - ], - "routes": [ - "/", - "/.well-known/knowledge-linkset", - "/.well-known/security.txt", - "/.well-known/tdmrep.json", - "/404.html", - "/_headers", - "/_redirects", - "/chunks.jsonl", - "/clusters/", - "/clusters/agent-patterns/", - "/compose/", - "/concepts/", - "/concepts/handoff/", - "/concepts/supervisor/", - "/episodes/", - "/gates/", - "/graph.jsonld", - "/graph.nq", - "/graph.ttl", - "/lessons/", - "/llms-full.txt", - "/llms.txt", - "/now.md", - "/now/", - "/ns/1.0.0/context.jsonld", - "/ns/context.jsonld", - "/pages/agent-patterns.jsonld", - "/pages/agent-patterns.md", - "/pages/handoff.jsonld", - "/pages/handoff.md", - "/pages/supervisor.jsonld", - "/pages/supervisor.md", - "/procedures/", - "/robots.txt", - "/search.json", - "/search/", - "/sitemap.xml", - "/skills/", - "/skills/agent-patterns/SKILL.md", - "/skills/index.json", - "/tags/agents/", - "/tags/patterns/" - ] + "withdrawn": true }, "id": "build-0024", "input": { @@ -60,10 +10,12 @@ "deployment_profile": "cloudflare-pages", "git_history": false }, - "level": "required", + "level": "withdrawn", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, - "rule": "AGSC-06-01" + "reason": "Withdrawn for 1.1.0 (2026-10-29). AGSC-06-01 and AGSC-06-39 add /query/ to the route set a writer emits by default (site.query_page defaults to true), so the list of 42 routes is 43 for the same fixture. Superseded by build-0029.", + "rule": "AGSC-06-01", + "superseded_by": "build-0029" } diff --git a/tests/fixtures/vectors/build/build-0025-skills-index-shape.json b/tests/fixtures/vectors/build/build-0025-skills-index-shape.json index 24ae362..f09bcea 100644 --- a/tests/fixtures/vectors/build/build-0025-skills-index-shape.json +++ b/tests/fixtures/vectors/build/build-0025-skills-index-shape.json @@ -33,7 +33,7 @@ "path": "/skills/agent-patterns/SKILL.md" } ], - "spec_version": "1.0.0", + "spec_version": "1.1.0", "terms": "LicenseRef-AgenticSystemCore-Content-Use-1.0" }, { @@ -66,7 +66,7 @@ "path": "/skills/agent-patterns/SKILL.md" } ], - "spec_version": "1.0.0", + "spec_version": "1.1.0", "terms": "CC-BY-4.0" } ] @@ -97,7 +97,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-07-19" } diff --git a/tests/fixtures/vectors/build/build-0026-skills-index-lock-is-the-hash-of-skill-md.json b/tests/fixtures/vectors/build/build-0026-skills-index-lock-is-the-hash-of-skill-md.json index d6bd7cc..d63348c 100644 --- a/tests/fixtures/vectors/build/build-0026-skills-index-lock-is-the-hash-of-skill-md.json +++ b/tests/fixtures/vectors/build/build-0026-skills-index-lock-is-the-hash-of-skill-md.json @@ -17,7 +17,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-07-20" } diff --git a/tests/fixtures/vectors/build/build-0027-tdm-reservation-file-and-its-robots-groups.json b/tests/fixtures/vectors/build/build-0027-tdm-reservation-file-and-its-robots-groups.json index da34762..6fcfd20 100644 --- a/tests/fixtures/vectors/build/build-0027-tdm-reservation-file-and-its-robots-groups.json +++ b/tests/fixtures/vectors/build/build-0027-tdm-reservation-file-and-its-robots-groups.json @@ -60,7 +60,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-18" } diff --git a/tests/fixtures/vectors/build/build-0028-undeclared-release-key-holds-an-item-back.json b/tests/fixtures/vectors/build/build-0028-undeclared-release-key-holds-an-item-back.json index 84290c4..7a77aa6 100644 --- a/tests/fixtures/vectors/build/build-0028-undeclared-release-key-holds-an-item-back.json +++ b/tests/fixtures/vectors/build/build-0028-undeclared-release-key-holds-an-item-back.json @@ -48,7 +48,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-20" } diff --git a/tests/fixtures/vectors/build/build-0029-the-whole-route-set-of-the-minimal-fixture-1-1.json b/tests/fixtures/vectors/build/build-0029-the-whole-route-set-of-the-minimal-fixture-1-1.json new file mode 100644 index 0000000..6e99fb2 --- /dev/null +++ b/tests/fixtures/vectors/build/build-0029-the-whole-route-set-of-the-minimal-fixture-1-1.json @@ -0,0 +1,78 @@ +{ + "area": "build", + "description": "AGSC-06-01: a writer MUST emit exactly the route set the rule lists, with the conditional routes only under their conditions. Derivation, by hand from the rule, over the minimal fixture (two concepts, handoff and supervisor; one cluster, agent-patterns; the tags agents and patterns; an authored .well-known/security.txt with a Contact field; no LICENSE-CONTENT, no authored /about/, no task item, no asset) built with SOURCE_DATE_EPOCH set and no git history, for the Cloudflare Pages deployment profile: the home page, the five type indexes, the two concept pages, the cluster index and page, the two tag pages, /search/ with /search.json, /now/ and /now.md, /compose/, /skills/ with its index and the one pack, the two context routes of /ns/ (the second named by the vocabulary version 1.0.0), the three graph exports, the six per-item copies, /llms.txt and /llms-full.txt, /sitemap.xml, /robots.txt, /.well-known/tdmrep.json, /chunks.jsonl, the discovery document, /.well-known/security.txt, /404.html, _headers and _redirects: 43 routes. Absent by their conditions: /legal/, /about/, /changelog/ and /ledger.jsonl (no git-log file), /boards/**, /conformance/, the agent card, the VoID description, /assets/, /specs/**, shards and index pages and /graph/fragments/**. A route ending in / is served as its index.html. The route set does not bound the same-origin presentation and script files a page of the set loads: the three the specification names (page_assets_required) are emitted, and every other emitted file is a .js or .css file that some emitted page loads by a script src or a stylesheet link (other_files_are_page_assets). Successor of build-0024 at 1.1: /query/ (AGSC-06-39) is emitted by default, site.query_page being true unless set to false, and the files under it other than its index page (the page script, the query engine, its licence text) are page assets like /assets/site.css, so the list is 43 routes. /chunks-index.toon (AGSC-06-37) is optional and may or may not be present (optional_routes); the two catalogue files (AGSC-06-42) and the agent card (AGSC-06-34) are absent because their switches and declarations are absent (absent_routes). The context routes are /ns/context.jsonld and /ns//context.jsonld, the version staying 1.0.0 at 1.1 (AGSC-06-01).", + "expected": { + "absent_routes": [ + "/.well-known/agent-card.json", + "/.well-known/ai-catalog.json", + "/.well-known/ard.json" + ], + "no_error_finding": true, + "optional_routes": [ + "/chunks-index.toon" + ], + "other_files_are_page_assets": true, + "page_assets_required": [ + "/assets/site.css", + "/assets/theme.js", + "/search/agsc-search.js" + ], + "routes": [ + "/", + "/.well-known/knowledge-linkset", + "/.well-known/security.txt", + "/.well-known/tdmrep.json", + "/404.html", + "/_headers", + "/_redirects", + "/chunks.jsonl", + "/clusters/", + "/clusters/agent-patterns/", + "/compose/", + "/concepts/", + "/concepts/handoff/", + "/concepts/supervisor/", + "/episodes/", + "/gates/", + "/graph.jsonld", + "/graph.nq", + "/graph.ttl", + "/lessons/", + "/llms-full.txt", + "/llms.txt", + "/now.md", + "/now/", + "/ns/1.0.0/context.jsonld", + "/ns/context.jsonld", + "/pages/agent-patterns.jsonld", + "/pages/agent-patterns.md", + "/pages/handoff.jsonld", + "/pages/handoff.md", + "/pages/supervisor.jsonld", + "/pages/supervisor.md", + "/procedures/", + "/query/", + "/robots.txt", + "/search.json", + "/search/", + "/sitemap.xml", + "/skills/", + "/skills/agent-patterns/SKILL.md", + "/skills/index.json", + "/tags/agents/", + "/tags/patterns/" + ] + }, + "id": "build-0029", + "input": { + "bundle": "fixtures/minimal", + "deployment_profile": "cloudflare-pages", + "git_history": false + }, + "level": "required", + "options": { + "source_date_epoch": 1767225600, + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-01" +} diff --git a/tests/fixtures/vectors/build/build-0030-query-page-default-and-switched-off.json b/tests/fixtures/vectors/build/build-0030-query-page-default-and-switched-off.json new file mode 100644 index 0000000..9ad385b --- /dev/null +++ b/tests/fixtures/vectors/build/build-0030-query-page-default-and-switched-off.json @@ -0,0 +1,76 @@ +{ + "area": "build", + "description": "AGSC-06-39: a writer that serves /graph.nq emits /query/ unless site.query_page is false. Two sub-cases over the minimal fixture, built with SOURCE_DATE_EPOCH set and no git history, for the Cloudflare Pages profile. (1) default: /query/ exists, is listed in /sitemap.xml (AGSC-06-19), is linked from every generated page, its HTML is at most 100000 bytes (AGSC-06-21; the query engine and its licence text are page assets outside that budget), it requests nothing outside the node's origin, its policy contains the five directives of AGSC-06-17 and none of 'unsafe-eval', 'unsafe-inline' or a host source, with 'wasm-unsafe-eval' admitted in script-src of this route only, and it carries exactly one Content-Security-Policy. The page answers SELECT, ASK, CONSTRUCT and DESCRIBE, refuses an update and a SERVICE clause, offers the ten questions of the graph as examples, results as a table (and a graph picture for CONSTRUCT, DESCRIBE or three-column results), CSV and JSON downloads, a share link whose query is in the fragment, and a vocabulary explorer; it stores nothing (AGSC-06-05). (2) switched off: no /query/, no file under it, no link to it from any page, no entry in the sitemap. The facts are asserted as such, not as bytes: HTML is not byte-pinned (AGSC-04-24). Derived by hand from the rule.", + "expected": { + "cases": [ + { + "answers": [ + "SELECT", + "ASK", + "CONSTRUCT", + "DESCRIBE" + ], + "csp_contains": [ + "default-src 'none'", + "script-src 'self'", + "style-src 'self'", + "img-src 'self'", + "connect-src 'self'" + ], + "csp_count_on_route": 1, + "csp_forbids": [ + "'unsafe-eval'", + "'unsafe-inline'" + ], + "downloads": [ + "csv", + "json" + ], + "examples_include_the_ten_questions": true, + "html_bytes_at_most": 100000, + "in_sitemap": true, + "linked_from_every_generated_page": true, + "name": "default", + "origins_outside_the_node": [], + "refuses": [ + "SERVICE", + "update" + ], + "route_present": true, + "share_link_holds_query_in": "fragment", + "stores_nothing": true, + "vocabulary_explorer": true + }, + { + "files_under_route": [], + "in_sitemap": false, + "linked_from_any_page": false, + "name": "switched-off", + "route_present": false + } + ] + }, + "id": "build-0030", + "input": { + "bundle": "fixtures/minimal", + "cases": [ + { + "name": "default" + }, + { + "add_files": { + "agsc.config.json": "{\n \"build\": {\n \"out\": \"www\"\n },\n \"bundle\": {\n \"id\": \"minimal\",\n \"license_prose\": \"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\n \"license_schema\": \"CC0-1.0\",\n \"operator\": \"human:andreibesleaga\"\n },\n \"site\": {\n \"base\": \"https://minimal.example/\",\n \"query_page\": false,\n \"tagline\": \"The smallest Bundle that conforms.\",\n \"tdm_crawlers\": [\n \"Applebot-Extended\",\n \"CCBot\",\n \"ClaudeBot\",\n \"GPTBot\",\n \"Google-Extended\",\n \"meta-externalagent\"\n ],\n \"title\": \"Minimal Bundle\"\n },\n \"spec_version\": \"1.0.0\",\n \"tags\": {\n \"allowed\": [\n \"agents\",\n \"patterns\"\n ]\n }\n}\n" + }, + "name": "switched-off" + } + ], + "deployment_profile": "cloudflare-pages", + "git_history": false + }, + "level": "required", + "options": { + "source_date_epoch": 1767225600, + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-39" +} diff --git a/tests/fixtures/vectors/build/build-0031-domain-layer-shown-on-item-pages.json b/tests/fixtures/vectors/build/build-0031-domain-layer-shown-on-item-pages.json new file mode 100644 index 0000000..bdfd15f --- /dev/null +++ b/tests/fixtures/vectors/build/build-0031-domain-layer-shown-on-item-pages.json @@ -0,0 +1,110 @@ +{ + "area": "build", + "description": "AGSC-06-38 for a node that uses the domain layer: the relations table of an item page shows, in each row, the other item's domain type and context, and the page shows the item's own domain type, role, context and warrant in a definition list under the table, each with the label the site vocabulary gives it. Two nodes of two items each, engine requires fuel-pump. (1) with the layer: the page of engine has a definition list of four entries (Domain type: Aircraft engine; Domain role: aggregate root; Domain context: Propulsion; Warrant: literary, with its source) and a table row for requires -> fuel-pump showing Fuel pump and Propulsion. (2) without the layer (no site vocabulary file, no domain key): the page has no definition list of these terms and the table has no domain column — the page differs from a 1.0 page only by the figure, the table and the backlinks. The facts are asserted as such, not as bytes. The key names (domain_type, domain_role, domain_context, warrant) and the vocabulary labels are those of the domain-layer rules of sections 02 and 05; this case states only what the PAGE shows.", + "expected": { + "cases": [ + { + "definition_list_of_engine": [ + { + "term": "Domain type", + "value": "Aircraft engine" + }, + { + "term": "Domain role", + "value": "aggregate root" + }, + { + "term": "Domain context", + "value": "Propulsion" + }, + { + "term": "Warrant", + "value": "literary: https://example.org/standards/engine-handbook" + } + ], + "name": "with-the-layer", + "table_row_of_engine": { + "direction": "outgoing", + "key": "requires", + "other": "fuel-pump", + "other_context": "Propulsion", + "other_domain_type": "Fuel pump" + } + }, + { + "definition_list_of_engine": [], + "name": "without-the-layer", + "table_has_domain_columns": false + } + ] + }, + "id": "build-0031", + "input": { + "cases": [ + { + "items": [ + { + "body": "An engine.\n", + "domain_context": "propulsion", + "domain_role": "aggregate-root", + "domain_type": "aircraft-engine", + "kind": "explainer", + "requires": [ + "fuel-pump" + ], + "slug": "engine", + "title": "Engine", + "type": "concept", + "warrant": { + "source": "https://example.org/standards/engine-handbook", + "type": "literary" + } + }, + { + "body": "A pump.\n", + "domain_context": "propulsion", + "domain_type": "fuel-pump", + "kind": "explainer", + "slug": "fuel-pump", + "title": "Fuel Pump", + "type": "concept" + } + ], + "labels": { + "aggregate-root": "aggregate root", + "aircraft-engine": "Aircraft engine", + "fuel-pump": "Fuel pump", + "propulsion": "Propulsion" + }, + "name": "with-the-layer" + }, + { + "items": [ + { + "body": "An engine.\n", + "kind": "explainer", + "requires": [ + "fuel-pump" + ], + "slug": "engine", + "title": "Engine", + "type": "concept" + }, + { + "body": "A pump.\n", + "kind": "explainer", + "slug": "fuel-pump", + "title": "Fuel Pump", + "type": "concept" + } + ], + "name": "without-the-layer" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-38" +} diff --git a/tests/fixtures/vectors/build/build-0032-graph-view-table-and-backlinks.json b/tests/fixtures/vectors/build/build-0032-graph-view-table-and-backlinks.json new file mode 100644 index 0000000..e137447 --- /dev/null +++ b/tests/fixtures/vectors/build/build-0032-graph-view-table-and-backlinks.json @@ -0,0 +1,112 @@ +{ + "area": "build", + "description": "AGSC-06-38 (a SHOULD, so the case is optional): an item page shows its neighbourhood as a figure with a relations table as the text equivalent; the table has one row for each relation key that links the item and another published item, in either direction, with the key, the direction, the other item and the plain meaning of the key (from the Meaning column of AGSC-03-01); the incoming rows are the backlinks. Items: a requires b; c uses a; a also requires d, a draft; e is held back by the releases switchboard and uses a. The page of a therefore has two rows — requires -> b, and uses <- c — and names neither d nor e anywhere (not in the figure, not in the table, not as a backlink). The figure draws at most 24 neighbours and the table says how many more exist (the second case: 30 items link to a, 24 are drawn, the table says 6 more). A writer that draws a figure also writes the table. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "figure_has_text_equivalent": true, + "meaning_in_every_row": true, + "name": "rows-and-exclusions", + "not_named_on_the_page_of_a": [ + "d", + "e" + ], + "rows_of_a": [ + { + "direction": "incoming", + "key": "uses", + "other": "c" + }, + { + "direction": "outgoing", + "key": "requires", + "other": "b" + } + ] + }, + { + "figure_neighbours": 24, + "more_neighbours_stated": 6, + "name": "cap-at-24" + } + ] + }, + "id": "build-0032", + "input": { + "cases": [ + { + "items": [ + { + "body": "A.\n", + "kind": "explainer", + "requires": [ + "b", + "d" + ], + "slug": "a", + "title": "A", + "type": "concept" + }, + { + "body": "B.\n", + "kind": "explainer", + "slug": "b", + "title": "B", + "type": "concept" + }, + { + "body": "C.\n", + "kind": "explainer", + "slug": "c", + "title": "C", + "type": "concept", + "uses": [ + "a" + ] + }, + { + "body": "D.\n", + "kind": "explainer", + "slug": "d", + "status": "draft", + "title": "D", + "type": "concept" + }, + { + "body": "E.\n", + "kind": "explainer", + "release": "later", + "slug": "e", + "title": "E", + "type": "concept", + "uses": [ + "a" + ] + } + ], + "name": "rows-and-exclusions", + "releases": { + "later": false + } + }, + { + "items_template": { + "body": "N.\n", + "kind": "explainer", + "type": "concept", + "uses": [ + "a" + ] + }, + "linking_items": 30, + "name": "cap-at-24", + "target": "a" + } + ] + }, + "level": "optional", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-38" +} diff --git a/tests/fixtures/vectors/build/build-0033-page-links-to-llms-txt-and-the-markdown-copy.json b/tests/fixtures/vectors/build/build-0033-page-links-to-llms-txt-and-the-markdown-copy.json new file mode 100644 index 0000000..c0c7313 --- /dev/null +++ b/tests/fixtures/vectors/build/build-0033-page-links-to-llms-txt-and-the-markdown-copy.json @@ -0,0 +1,63 @@ +{ + "area": "build", + "description": "AGSC-06-46: every generated HTML page carries in its head a describedby link to /llms.txt with type text/plain, and every item page also an alternate link with type text/markdown to its /pages/.md — the two relations llms.txt v2 (modified 2026-08-10, llmstxt.org, read 2026-10-29) defines for a page. The minimal fixture, built with SOURCE_DATE_EPOCH set and no git history: the home page and /clusters/ carry the describedby link only, the concept page /concepts/handoff/ carries both. The discovery document is still reached by its own describedby link, selected by its type (AGSC-06-25). Derived by hand.", + "expected": { + "pages": { + "/": { + "head_links_exclude": [ + { + "rel": "alternate", + "type": "text/markdown" + } + ], + "head_links_include": [ + { + "href": "/llms.txt", + "rel": "describedby", + "type": "text/plain" + } + ] + }, + "/clusters/": { + "head_links_include": [ + { + "href": "/llms.txt", + "rel": "describedby", + "type": "text/plain" + } + ] + }, + "/concepts/handoff/": { + "head_links_include": [ + { + "href": "/llms.txt", + "rel": "describedby", + "type": "text/plain" + }, + { + "href": "/pages/handoff.md", + "rel": "alternate", + "type": "text/markdown" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "describedby", + "type": "application/linkset+json" + } + ] + } + } + }, + "id": "build-0033", + "input": { + "bundle": "fixtures/minimal", + "deployment_profile": "cloudflare-pages", + "git_history": false + }, + "level": "required", + "options": { + "source_date_epoch": 1767225600, + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-46" +} diff --git a/tests/fixtures/vectors/build/build-0034-versioned-ns-copies-are-immutable-and-blocks-are-single.json b/tests/fixtures/vectors/build/build-0034-versioned-ns-copies-are-immutable-and-blocks-are-single.json new file mode 100644 index 0000000..b8969d3 --- /dev/null +++ b/tests/fixtures/vectors/build/build-0034-versioned-ns-copies-are-immutable-and-blocks-are-single.json @@ -0,0 +1,45 @@ +{ + "area": "build", + "description": "AGSC-06-06 with AGSC-06-17: every file under a version directory /ns/../ is served with Cache-Control: public, max-age=31536000, immutable, and no other address is (the unversioned /ns/context.jsonld, the namespace site's /ns/agsc.ttl, /ns/agsc.rdf, /ns/schema/** and the /ns/ index change with a release); in _headers each address pattern is written once, with the Link values of AGSC-06-40 in the one block of / and one Content-Security-Policy for /query/. The case is stated on the header set of the Cloudflare Pages profile, not on file bytes (AGSC-06-01): for each address, the headers served; for the patterns, how many blocks name each. Derived by hand from the rules.", + "expected": { + "cache_control_immutable_not_on": [ + "/", + "/.well-known/knowledge-linkset", + "/ns/context.jsonld", + "/query/" + ], + "cache_control_immutable_on": [ + "/ns/1.0.0/context.jsonld" + ], + "cache_control_value_on_versioned_copies": "public, max-age=31536000, immutable", + "content_security_policy_count": { + "/query/": 1 + }, + "every_address_pattern_written_once": true, + "link_header_on_home_block": true, + "namespace_site_addresses_not_immutable": [ + "/ns/", + "/ns/agsc.rdf", + "/ns/agsc.ttl", + "/ns/schema/item.schema.json" + ] + }, + "id": "build-0034", + "input": { + "bundle": "fixtures/minimal", + "deployment_profile": "cloudflare-pages", + "git_history": false, + "routes": [ + "/", + "/ns/1.0.0/context.jsonld", + "/ns/context.jsonld", + "/query/" + ] + }, + "level": "required", + "options": { + "source_date_epoch": 1767225600, + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-06" +} diff --git a/tests/fixtures/vectors/build/build-0035-security-txt-policy-from-a-declared-disclosure-page.json b/tests/fixtures/vectors/build/build-0035-security-txt-policy-from-a-declared-disclosure-page.json new file mode 100644 index 0000000..97daa8d --- /dev/null +++ b/tests/fixtures/vectors/build/build-0035-security-txt-policy-from-a-declared-disclosure-page.json @@ -0,0 +1,77 @@ +{ + "area": "build", + "description": "AGSC-06-36 as amended for 1.1: Policy is derived, where the authored file states none, as the absolute URL of the disclosure page that site.security_policy declares and otherwise, as in 1.0, of /legal/ where that route is emitted. Derivation, case by case, with the clause structure of build-0013 (Expires is the build instant plus 364 days: 2026-01-01T00:00:00Z + 364 d = 2026-12-31T00:00:00Z; derived fields follow the authored ones, in the order Expires, Canonical, Policy). (1) declared: the declared page wins over /legal/ even though /legal/ is emitted. (2) default: no declared page, /legal/ emitted: the 1.0 bytes of build-0013. (3) declared-without-legal: the declared page is used although /legal/ is not emitted. (4) authored-policy-kept: the authored file states Policy, which is published verbatim in the authored order, and no Policy is derived. (5) neither: no declared page and no /legal/: no Policy line.", + "expected": { + "cases": [ + { + "findings": [], + "name": "declared", + "text": "Contact: mailto:security@a.example\nExpires: 2026-12-31T00:00:00Z\nCanonical: https://a.example/.well-known/security.txt\nPolicy: https://a.example/disclosure/\n" + }, + { + "findings": [], + "name": "default", + "text": "Contact: mailto:security@a.example\nExpires: 2026-12-31T00:00:00Z\nCanonical: https://a.example/.well-known/security.txt\nPolicy: https://a.example/legal/\n" + }, + { + "findings": [], + "name": "declared-without-legal", + "text": "Contact: mailto:security@a.example\nExpires: 2026-12-31T00:00:00Z\nCanonical: https://a.example/.well-known/security.txt\nPolicy: https://a.example/disclosure/\n" + }, + { + "findings": [], + "name": "authored-policy-kept", + "text": "Contact: mailto:security@a.example\nPolicy: https://a.example/own-policy/\nExpires: 2026-12-31T00:00:00Z\nCanonical: https://a.example/.well-known/security.txt\n" + }, + { + "findings": [], + "name": "neither", + "text": "Contact: mailto:security@a.example\nExpires: 2026-12-31T00:00:00Z\nCanonical: https://a.example/.well-known/security.txt\n" + } + ] + }, + "id": "build-0035", + "input": { + "base": "https://a.example/", + "cases": [ + { + "authored": "Contact: mailto:security@a.example\n", + "instant": "2026-01-01T00:00:00Z", + "legal": true, + "name": "declared", + "security_policy": "https://a.example/disclosure/" + }, + { + "authored": "Contact: mailto:security@a.example\n", + "instant": "2026-01-01T00:00:00Z", + "legal": true, + "name": "default" + }, + { + "authored": "Contact: mailto:security@a.example\n", + "instant": "2026-01-01T00:00:00Z", + "legal": false, + "name": "declared-without-legal", + "security_policy": "https://a.example/disclosure/" + }, + { + "authored": "Contact: mailto:security@a.example\nPolicy: https://a.example/own-policy/\n", + "instant": "2026-01-01T00:00:00Z", + "legal": true, + "name": "authored-policy-kept", + "security_policy": "https://a.example/disclosure/" + }, + { + "authored": "Contact: mailto:security@a.example\n", + "instant": "2026-01-01T00:00:00Z", + "legal": false, + "name": "neither" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-36" +} diff --git a/tests/fixtures/vectors/build/build-0036-now-line-of-a-restricted-node.json b/tests/fixtures/vectors/build/build-0036-now-line-of-a-restricted-node.json new file mode 100644 index 0000000..541b760 --- /dev/null +++ b/tests/fixtures/vectors/build/build-0036-now-line-of-a-restricted-node.json @@ -0,0 +1,42 @@ +{ + "area": "build", + "description": "AGSC-06-22 with AGSC-11-20: the line that /now/ and /now.md carry is `content version , built at , fingerprint , specification ` on a public node; on a restricted node it is `built at , specification `, because the content version and the fingerprint are facts that AGSC-11-20 keeps out of the discovery document and no file anyone may read can carry them. Two nodes with the same facts, public and restricted. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "line": "content version v1.4.0, built at 2026-09-16T00:00:00Z, fingerprint bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, specification 1.0.0", + "name": "public" + }, + { + "line": "built at 2026-09-16T00:00:00Z, specification 1.0.0", + "name": "restricted" + } + ] + }, + "id": "build-0036", + "input": { + "cases": [ + { + "bundle_version": "v1.4.0", + "fingerprint": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "instant": "2026-09-16T00:00:00Z", + "name": "public", + "spec_version": "1.0.0", + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "fingerprint": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "instant": "2026-09-16T00:00:00Z", + "name": "restricted", + "spec_version": "1.0.0", + "visibility": "restricted" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-22" +} diff --git a/tests/fixtures/vectors/build/build-0037-chunk-index-is-not-emitted-above-500-items.json b/tests/fixtures/vectors/build/build-0037-chunk-index-is-not-emitted-above-500-items.json new file mode 100644 index 0000000..c0c63fa --- /dev/null +++ b/tests/fixtures/vectors/build/build-0037-chunk-index-is-not-emitted-above-500-items.json @@ -0,0 +1,57 @@ +{ + "area": "build", + "description": "AGSC-06-37: /chunks-index.toon is emitted only when the published set holds at most 500 items; above that it is not emitted, because /chunks.jsonl is sharded and the index has no shard. Two Bundles built as in chk-0008: 501 items (the index is not emitted and /chunks.jsonl is the manifest) and 3 items (the index may be emitted; when it is, its header counts the same number of lines as /chunks.jsonl and its rows follow the same order). Its absence is never a fault. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "index_emitted": false, + "name": "above-500" + }, + { + "header_if_emitted": "chunks[3]{id,item,kind,section,ordinal,title,digest}:", + "index_may_be_emitted": true, + "name": "three-items" + } + ] + }, + "id": "build-0037", + "input": { + "cases": [ + { + "chunks": { + "max_bytes": 4096 + }, + "item_count": 501, + "item_template": { + "body": "One line.\n", + "kind": "explainer", + "type": "concept" + }, + "name": "above-500", + "site": { + "base": "https://a.example/" + } + }, + { + "chunks": { + "max_bytes": 4096 + }, + "item_count": 3, + "item_template": { + "body": "One line.\n", + "kind": "explainer", + "type": "concept" + }, + "name": "three-items", + "site": { + "base": "https://a.example/" + } + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-37" +} diff --git a/tests/fixtures/vectors/discovery/disc-0004-level0-wellknown.json b/tests/fixtures/vectors/discovery/disc-0004-level0-wellknown.json index 8ec06b7..3503237 100644 --- a/tests/fixtures/vectors/discovery/disc-0004-level0-wellknown.json +++ b/tests/fixtures/vectors/discovery/disc-0004-level0-wellknown.json @@ -49,7 +49,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-08a" } diff --git a/tests/fixtures/vectors/discovery/disc-0005-peer-mutual-conformance.json b/tests/fixtures/vectors/discovery/disc-0005-peer-mutual-conformance.json index a6f6436..ae9b66d 100644 --- a/tests/fixtures/vectors/discovery/disc-0005-peer-mutual-conformance.json +++ b/tests/fixtures/vectors/discovery/disc-0005-peer-mutual-conformance.json @@ -22,7 +22,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-10-12" } diff --git a/tests/fixtures/vectors/discovery/disc-0008-every-item-reachable-from-llms-txt.json b/tests/fixtures/vectors/discovery/disc-0008-every-item-reachable-from-llms-txt.json index 3d2b50c..a2a37a1 100644 --- a/tests/fixtures/vectors/discovery/disc-0008-every-item-reachable-from-llms-txt.json +++ b/tests/fixtures/vectors/discovery/disc-0008-every-item-reachable-from-llms-txt.json @@ -66,7 +66,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-14" } diff --git a/tests/fixtures/vectors/discovery/disc-0009-sitemap-order-and-lastmod.json b/tests/fixtures/vectors/discovery/disc-0009-sitemap-order-and-lastmod.json index 44d77c3..fbb0cee 100644 --- a/tests/fixtures/vectors/discovery/disc-0009-sitemap-order-and-lastmod.json +++ b/tests/fixtures/vectors/discovery/disc-0009-sitemap-order-and-lastmod.json @@ -36,7 +36,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-19" } diff --git a/tests/fixtures/vectors/discovery/disc-0012-robots-tdm-crawler-groups.json b/tests/fixtures/vectors/discovery/disc-0012-robots-tdm-crawler-groups.json index 6b271e0..4e60397 100644 --- a/tests/fixtures/vectors/discovery/disc-0012-robots-tdm-crawler-groups.json +++ b/tests/fixtures/vectors/discovery/disc-0012-robots-tdm-crawler-groups.json @@ -61,7 +61,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-18" } diff --git a/tests/fixtures/vectors/discovery/disc-0013-llms-txt-byte-layout-with-content-version.json b/tests/fixtures/vectors/discovery/disc-0013-llms-txt-byte-layout-with-content-version.json index e1cdbb3..497afba 100644 --- a/tests/fixtures/vectors/discovery/disc-0013-llms-txt-byte-layout-with-content-version.json +++ b/tests/fixtures/vectors/discovery/disc-0013-llms-txt-byte-layout-with-content-version.json @@ -2,10 +2,7 @@ "area": "discovery", "description": "The agent-facing text file has an exact byte layout: H1 (first, as llms.txt v2 requires), provenance comment, blockquote, cluster sections ordered by slug, an Other section for unclustered items, one blank line between blocks and nothing else. An item with no description repeats its title; a draft item appears nowhere. Without this pin two conforming writers emit different bytes and Level 0 is unreachable. The provenance header carries the AI-assistance statement of AGSC-06-15 as its last line, a constant of the specification and never authored; no value interpolated into the block may carry `-->` (AGSC-06-13a). Expected bytes are derived by hand from the rule text: block (2) is the provenance comment, whose header carries the line `bundle_version: ` between `spec_version:` and `generated_at:` (AGSC-06-13a, AGSC-04-25). The value here is the branch-1 form of AGSC-04-25 — the tag on the built commit, `v1.4.0`.", "expected": { - "draft_excluded": [ - "hidden" - ], - "output": "# Example Node\n\n\n\n> A node of the Agentic Knowledge Web.\n\n## Coordination\n\n- [Supervisor](https://a.example/concepts/supervisor/): Routes work to workers.\n\n## Other\n\n- [Loose Note](https://a.example/concepts/loose-note/): Loose Note\n" + "withdrawn": true }, "id": "disc-0013", "input": { @@ -44,9 +41,11 @@ ], "spec_version": "1.0.0" }, - "level": "required", + "level": "withdrawn", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, - "rule": "AGSC-06-13a" + "reason": "Withdrawn for 1.1.0 (2026-10-29). AGSC-06-13a now puts the blockquote summary straight after the H1 and the provenance comment after the summary, escapes the backslash, `[`, `]` and `(` in a link line, and lets a restricted node leave out the bundle_version line; the expected bytes of this case change in all three respects. Superseded by disc-0024.", + "rule": "AGSC-06-13a", + "superseded_by": "disc-0024" } diff --git a/tests/fixtures/vectors/discovery/disc-0014-llms-full-with-content-version.json b/tests/fixtures/vectors/discovery/disc-0014-llms-full-with-content-version.json index 5a84ee1..953e9e8 100644 --- a/tests/fixtures/vectors/discovery/disc-0014-llms-full-with-content-version.json +++ b/tests/fixtures/vectors/discovery/disc-0014-llms-full-with-content-version.json @@ -2,9 +2,7 @@ "area": "discovery", "description": "An item in two clusters appears once, under its PRIMARY (first-listed) cluster; /llms.txt opens with the H1 and then the provenance comment (a profile of llms.txt v2); /llms-full.txt repeats /llms.txt through the section blocks and then, per item in the same order, one three-part block: the H2 title, the agsc:item comment, and the body fenced as text agsc-content, blocks separated by exactly one blank line. The provenance header of both files carries the AI-assistance statement of AGSC-06-15 as its last line, a constant of the specification and never authored (AGSC-06-13a). Expected bytes are derived by hand from the rule text: the header block of each file carries the line `bundle_version: ` between `spec_version:` and `generated_at:` (AGSC-06-13a, AGSC-04-25). The value here is the branch-1 form of AGSC-04-25 — the tag on the built commit, `v1.4.0`.", "expected": { - "both_appears_once_under": "beta", - "llms_full_txt": "# Node\n\n\n\n> Two clusters, one item in both.\n\n## Alpha\n\n- [Only](https://a.example/concepts/only/): Only\n\n## Beta\n\n- [Both](https://a.example/concepts/both/): In beta first.\n\n## Only\n\n```text agsc-content\nBody of only.\n```\n\n## Both\n\n```text agsc-content\nBody of both.\n```\n", - "llms_txt": "# Node\n\n\n\n> Two clusters, one item in both.\n\n## Alpha\n\n- [Only](https://a.example/concepts/only/): Only\n\n## Beta\n\n- [Both](https://a.example/concepts/both/): In beta first.\n" + "withdrawn": true }, "id": "disc-0014", "input": { @@ -48,9 +46,11 @@ ], "spec_version": "1.0.0" }, - "level": "required", + "level": "withdrawn", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, - "rule": "AGSC-06-13a" + "reason": "Withdrawn for 1.1.0 (2026-10-29). AGSC-06-13a now orders the blocks of /llms.txt and /llms-full.txt as H1, summary, provenance comment, sections; the expected bytes of both files change. Superseded by disc-0025.", + "rule": "AGSC-06-13a", + "superseded_by": "disc-0025" } diff --git a/tests/fixtures/vectors/discovery/disc-0015-bundle-version-attribute.json b/tests/fixtures/vectors/discovery/disc-0015-bundle-version-attribute.json index e11bfb8..c46b7c9 100644 --- a/tests/fixtures/vectors/discovery/disc-0015-bundle-version-attribute.json +++ b/tests/fixtures/vectors/discovery/disc-0015-bundle-version-attribute.json @@ -165,7 +165,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-08" } diff --git a/tests/fixtures/vectors/discovery/disc-0016-wellknown-linkset-six-bundle-facts.json b/tests/fixtures/vectors/discovery/disc-0016-wellknown-linkset-six-bundle-facts.json index 4a18c0b..58066d0 100644 --- a/tests/fixtures/vectors/discovery/disc-0016-wellknown-linkset-six-bundle-facts.json +++ b/tests/fixtures/vectors/discovery/disc-0016-wellknown-linkset-six-bundle-facts.json @@ -62,7 +62,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-08" } diff --git a/tests/fixtures/vectors/discovery/disc-0017-level-2-requires-ledger-link.json b/tests/fixtures/vectors/discovery/disc-0017-level-2-requires-ledger-link.json index 4b46a0b..c5c731d 100644 --- a/tests/fixtures/vectors/discovery/disc-0017-level-2-requires-ledger-link.json +++ b/tests/fixtures/vectors/discovery/disc-0017-level-2-requires-ledger-link.json @@ -51,7 +51,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-09-93" } diff --git a/tests/fixtures/vectors/discovery/disc-0018-bundle-hash-is-the-graph-nq-digest.json b/tests/fixtures/vectors/discovery/disc-0018-bundle-hash-is-the-graph-nq-digest.json index c7541e1..4fcd0bd 100644 --- a/tests/fixtures/vectors/discovery/disc-0018-bundle-hash-is-the-graph-nq-digest.json +++ b/tests/fixtures/vectors/discovery/disc-0018-bundle-hash-is-the-graph-nq-digest.json @@ -14,7 +14,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-08" } diff --git a/tests/fixtures/vectors/discovery/disc-0019-newer-minor-relation-is-ignored.json b/tests/fixtures/vectors/discovery/disc-0019-newer-minor-relation-is-ignored.json index 353fd9d..c068c30 100644 --- a/tests/fixtures/vectors/discovery/disc-0019-newer-minor-relation-is-ignored.json +++ b/tests/fixtures/vectors/discovery/disc-0019-newer-minor-relation-is-ignored.json @@ -2,28 +2,7 @@ "area": "discovery", "description": "AGSC-09-93 with AGSC-00-21: a discovery document whose `agsc-spec-version` has the reader's MAJOR and a newer MINOR may use a relation this version does not define; a 1.0 reader ignores it, with the warning AGSC-E506 naming the newer version, and never reports it as AGSC-E209 or AGSC-E202. Another MAJOR has no such tolerance. Derivation, case by case, each document otherwise a complete public Level-2 document (the six bundle facts on the anchor's `describedby` link, the ledger link with its head, and a `digest` on every link, the `rel#brief` link included, so no reader can report a missing digest; digests are not recomputed in this case). (1) `newer-minor`: `agsc-spec-version` is `1.1.0` and the document carries one link under `https://w3id.org/agentic-system-core/rel#brief`, which AGSC-06-10 does not list: the document is valid, with exactly one finding, the warning AGSC-E506. (2) `other-major`: the same document declaring `2.0.0`: the unknown relation is the error AGSC-E209, so the document is invalid, and it is the only finding — a 1.x reader cannot know what a later MAJOR defines, so it judges no attribute of that document against AGSC-00-23 (no AGSC-E210 for `agsc-bundle-version`, which this version defines from MAJOR 1). The reader in both cases is a 1.0 reader.", "expected": { - "cases": [ - { - "findings": [ - { - "code": "AGSC-E506", - "severity": "warn" - } - ], - "name": "newer-minor", - "valid": true - }, - { - "findings": [ - { - "code": "AGSC-E209", - "severity": "error" - } - ], - "name": "other-major", - "valid": false - } - ] + "withdrawn": true }, "id": "disc-0019", "input": { @@ -154,9 +133,11 @@ } ] }, - "level": "required", + "level": "withdrawn", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, - "rule": "AGSC-09-93" + "reason": "Withdrawn for 1.1.0 (2026-10-29). Its first sub-case declared `agsc-spec-version` 1.1.0 and expected a 1.0 reader to find it newer; once the tool under test is 1.1 the document is no longer a newer MINOR and the expectation fails, and the case would fail again at every later MINOR. Superseded by disc-0023: the same two sub-cases with a document at 1.99.0 and a 1.1.0 reader.", + "rule": "AGSC-09-93", + "superseded_by": "disc-0023" } diff --git a/tests/fixtures/vectors/discovery/disc-0021-boards-link-present-and-absent.json b/tests/fixtures/vectors/discovery/disc-0021-boards-link-present-and-absent.json index dd1cd8c..a42864c 100644 --- a/tests/fixtures/vectors/discovery/disc-0021-boards-link-present-and-absent.json +++ b/tests/fixtures/vectors/discovery/disc-0021-boards-link-present-and-absent.json @@ -355,7 +355,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-08" } diff --git a/tests/fixtures/vectors/discovery/disc-0022-restricted-node-access-link.json b/tests/fixtures/vectors/discovery/disc-0022-restricted-node-access-link.json index 6e7fee2..dd1209a 100644 --- a/tests/fixtures/vectors/discovery/disc-0022-restricted-node-access-link.json +++ b/tests/fixtures/vectors/discovery/disc-0022-restricted-node-access-link.json @@ -170,7 +170,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-11-20" } diff --git a/tests/fixtures/vectors/discovery/disc-0023-newer-minor-relation-is-ignored-by-every-1x-reader.json b/tests/fixtures/vectors/discovery/disc-0023-newer-minor-relation-is-ignored-by-every-1x-reader.json new file mode 100644 index 0000000..98f0629 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0023-newer-minor-relation-is-ignored-by-every-1x-reader.json @@ -0,0 +1,162 @@ +{ + "area": "discovery", + "description": "AGSC-09-93 with AGSC-00-21: a discovery document whose `agsc-spec-version` has the reader's MAJOR and a newer MINOR may use a relation this version does not define; a reader ignores it, with the warning AGSC-E506 naming the newer version, and never reports it as AGSC-E209 or AGSC-E202. Another MAJOR has no such tolerance. This case is the successor of `disc-0019`, which put the newer MINOR at `1.1.0` and the reader at 1.0 and so stopped being a case of a newer MINOR once the tool became 1.1: the reader is now 1.1.0 and the document declares `1.99.0`, a version that is newer for every 1.x reader, so the case does not move again at a later MINOR. Derivation, case by case, each document otherwise a complete public Level-2 document (the six bundle facts on the anchor's `describedby` link, the ledger link with its head, and a `digest` on every link, the `rel#brief` link included, so no reader can report a missing digest; digests are not recomputed in this case). (1) `newer-minor`: `agsc-spec-version` is `1.99.0` and the document carries one link under `https://w3id.org/agentic-system-core/rel#brief`, which AGSC-06-10 does not list: the document is valid, with exactly one finding, the warning AGSC-E506. (2) `other-major`: the same document declaring `2.0.0`: the unknown relation is the error AGSC-E209, so the document is invalid, and it is the only finding — a 1.x reader cannot know what a later MAJOR defines, so it judges no attribute of that document against AGSC-00-23 (no AGSC-E210 for `agsc-bundle-version`, which this version defines from MAJOR 1). The reader in both cases is a 1.1 reader.", + "expected": { + "cases": [ + { + "findings": [ + { + "code": "AGSC-E506", + "severity": "warn" + } + ], + "name": "newer-minor", + "valid": true + }, + { + "findings": [ + { + "code": "AGSC-E209", + "severity": "error" + } + ], + "name": "other-major", + "valid": false + } + ] + }, + "id": "disc-0023", + "input": { + "cases": [ + { + "document": { + "linkset": [ + { + "anchor": "https://b.example/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "agsc-bundle-version": [ + "v1.0.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-09-16T00:00:00Z" + ], + "agsc-spec-version": [ + "1.99.0" + ], + "digest": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "href": "https://b.example/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#brief": [ + { + "digest": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "href": "https://b.example/brief.md", + "type": "text/markdown" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "digest": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "href": "https://b.example/ledger.jsonl", + "type": "application/jsonl" + } + ] + } + ] + }, + "level": 2, + "name": "newer-minor", + "reader_version": "1.1.0" + }, + { + "document": { + "linkset": [ + { + "anchor": "https://b.example/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "agsc-bundle-version": [ + "v1.0.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-09-16T00:00:00Z" + ], + "agsc-spec-version": [ + "2.0.0" + ], + "digest": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "href": "https://b.example/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#brief": [ + { + "digest": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "href": "https://b.example/brief.md", + "type": "text/markdown" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ], + "digest": [ + "sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:" + ], + "href": "https://b.example/ledger.jsonl", + "type": "application/jsonl" + } + ] + } + ] + }, + "level": 2, + "name": "other-major", + "reader_version": "1.1.0" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-09-93" +} diff --git a/tests/fixtures/vectors/discovery/disc-0024-llms-txt-byte-layout-1-1.json b/tests/fixtures/vectors/discovery/disc-0024-llms-txt-byte-layout-1-1.json new file mode 100644 index 0000000..8dc2c40 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0024-llms-txt-byte-layout-1-1.json @@ -0,0 +1,57 @@ +{ + "area": "discovery", + "description": "Successor of disc-0013. The agent-facing text file has an exact byte layout at 1.1: the H1 first, the blockquote summary straight after it as llms.txt v2 orders them, then the provenance comment, then the cluster sections ordered by slug and an Other section for unclustered items, one blank line between blocks and nothing else; a draft item appears nowhere; an item with no description repeats its title. In a link line the backslash, `[`, `]` and `(` of the title and of the description are each preceded by one backslash, the backslash first, and no other character is escaped: the item odd-title has the title `Odd [title] (v2)\\` and the description `See [the guide](x) and a \\ backslash.`, which become `Odd \\[title\\] \\(v2)\\\\` and `See \\[the guide\\]\\(x) and a \\\\ backslash.` (`)` is not escaped). The provenance header carries the line bundle_version between spec_version and generated_at on a node that is not restricted. Expected bytes are derived by hand from AGSC-06-13a.", + "expected": { + "draft_excluded": [ + "hidden" + ], + "output": "# Example Node\n\n> A node of the Agentic Knowledge Web.\n\n\n\n## Coordination\n\n- [Supervisor](https://a.example/concepts/supervisor/): Routes work to workers.\n\n## Other\n\n- [Loose Note](https://a.example/concepts/loose-note/): Loose Note\n- [Odd \\[title\\] \\(v2)\\\\](https://a.example/concepts/odd-title/): See \\[the guide\\]\\(x) and a \\\\ backslash.\n" + }, + "id": "disc-0024", + "input": { + "bundle": { + "base": "https://a.example/", + "description": "A node of the Agentic Knowledge Web.", + "license_prose": "LicenseRef-AgenticSystemCore-Content-Use-1.0", + "title": "Example Node" + }, + "bundle_version": "v1.4.0", + "clusters": [ + { + "slug": "coordination", + "title": "Coordination" + } + ], + "generated_at": "2026-09-16T00:00:00Z", + "items": [ + { + "clusters": [ + "coordination" + ], + "description": "Routes work to workers.", + "slug": "supervisor", + "title": "Supervisor" + }, + { + "description": "See [the guide](x) and a \\ backslash.", + "slug": "odd-title", + "title": "Odd [title] (v2)\\" + }, + { + "slug": "loose-note", + "title": "Loose Note" + }, + { + "slug": "hidden", + "status": "draft", + "title": "Hidden" + } + ], + "spec_version": "1.0.0" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-13a" +} diff --git a/tests/fixtures/vectors/discovery/disc-0025-llms-full-1-1.json b/tests/fixtures/vectors/discovery/disc-0025-llms-full-1-1.json new file mode 100644 index 0000000..73e3056 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0025-llms-full-1-1.json @@ -0,0 +1,56 @@ +{ + "area": "discovery", + "description": "Successor of disc-0014. An item in two clusters appears once, under its PRIMARY (first-listed) cluster; /llms.txt opens with the H1, the blockquote summary and then the provenance comment, as llms.txt v2 orders its parts; /llms-full.txt repeats /llms.txt through the section blocks and then, per item in the same order, one three-part block: the H2 title, the agsc:item comment, and the body fenced as text agsc-content, blocks separated by exactly one blank line. The provenance header of both files carries the AI-assistance statement of AGSC-06-15 as its last line. Expected bytes are derived by hand from AGSC-06-13a.", + "expected": { + "both_appears_once_under": "beta", + "llms_full_txt": "# Node\n\n> Two clusters, one item in both.\n\n\n\n## Alpha\n\n- [Only](https://a.example/concepts/only/): Only\n\n## Beta\n\n- [Both](https://a.example/concepts/both/): In beta first.\n\n## Only\n\n```text agsc-content\nBody of only.\n```\n\n## Both\n\n```text agsc-content\nBody of both.\n```\n", + "llms_txt": "# Node\n\n> Two clusters, one item in both.\n\n\n\n## Alpha\n\n- [Only](https://a.example/concepts/only/): Only\n\n## Beta\n\n- [Both](https://a.example/concepts/both/): In beta first.\n" + }, + "id": "disc-0025", + "input": { + "bundle": { + "base": "https://a.example/", + "description": "Two clusters, one item in both.", + "license_prose": "LicenseRef-AgenticSystemCore-Content-Use-1.0", + "title": "Node" + }, + "bundle_version": "v1.4.0", + "clusters": [ + { + "slug": "alpha", + "title": "Alpha" + }, + { + "slug": "beta", + "title": "Beta" + } + ], + "generated_at": "2026-09-17T00:00:00Z", + "items": [ + { + "body": "Body of both.\n", + "clusters": [ + "beta", + "alpha" + ], + "description": "In beta first.", + "slug": "both", + "title": "Both" + }, + { + "body": "Body of only.\n", + "clusters": [ + "alpha" + ], + "slug": "only", + "title": "Only" + } + ], + "spec_version": "1.0.0" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-13a" +} diff --git a/tests/fixtures/vectors/discovery/disc-0026-signposting-link-header-on-home.json b/tests/fixtures/vectors/discovery/disc-0026-signposting-link-header-on-home.json new file mode 100644 index 0000000..4e40598 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0026-signposting-link-header-on-home.json @@ -0,0 +1,218 @@ +{ + "area": "discovery", + "description": "AGSC-06-40: the Link header of the home page carries the FAIR Signposting Level 1 links (signposting.org/FAIR, read 2026-10-29): cite-as exactly once (the first related[] cite-as link in href order, else the Bundle IRI), two type links (https://schema.org/Dataset then https://schema.org/AboutPage), describedby for the discovery document and for /graph.jsonld, item for the graph files and the chunks, license when the node has a licence URL (AGSC-06-44), and linkset for the discovery document. The values are compared as a set of {href, rel, type} (the order and the folding of the values into one field or several are not asserted, and the targets on the node are root-relative while cite-as and license are absolute). Three nodes: public with a DOI as cite-as and a versioned licence URL; public with the defaults (the Content Use Terms, /legal/ emitted); restricted (no item link). The validator part: given a URL whose / response lacks the describedby link, validate-wellknown reports a warning under AGSC-E202, because the header is a SHOULD in AGSC-06-25. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "links_as_set": [ + { + "href": "https://doi.org/10.5281/zenodo.1", + "rel": "cite-as" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "describedby", + "type": "application/linkset+json" + }, + { + "href": "/graph.jsonld", + "rel": "describedby", + "type": "application/ld+json" + }, + { + "href": "/chunks.jsonl", + "rel": "item", + "type": "application/jsonl" + }, + { + "href": "/graph.nq", + "rel": "item", + "type": "application/n-quads" + }, + { + "href": "/graph.ttl", + "rel": "item", + "type": "text/turtle" + }, + { + "href": "https://creativecommons.org/licenses/by/4.0/", + "rel": "license" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "linkset", + "type": "application/linkset+json" + }, + { + "href": "https://schema.org/AboutPage", + "rel": "type" + }, + { + "href": "https://schema.org/Dataset", + "rel": "type" + } + ], + "name": "public-with-doi-and-versioned-licence" + }, + { + "links_as_set": [ + { + "href": "https://a.example/", + "rel": "cite-as" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "describedby", + "type": "application/linkset+json" + }, + { + "href": "/graph.jsonld", + "rel": "describedby", + "type": "application/ld+json" + }, + { + "href": "/chunks.jsonl", + "rel": "item", + "type": "application/jsonl" + }, + { + "href": "/graph.nq", + "rel": "item", + "type": "application/n-quads" + }, + { + "href": "/graph.ttl", + "rel": "item", + "type": "text/turtle" + }, + { + "href": "https://a.example/legal/", + "rel": "license" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "linkset", + "type": "application/linkset+json" + }, + { + "href": "https://schema.org/AboutPage", + "rel": "type" + }, + { + "href": "https://schema.org/Dataset", + "rel": "type" + } + ], + "name": "public-defaults" + }, + { + "links_as_set": [ + { + "href": "https://a.example/", + "rel": "cite-as" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "describedby", + "type": "application/linkset+json" + }, + { + "href": "/graph.jsonld", + "rel": "describedby", + "type": "application/ld+json" + }, + { + "href": "https://a.example/legal/", + "rel": "license" + }, + { + "href": "/.well-known/knowledge-linkset", + "rel": "linkset", + "type": "application/linkset+json" + }, + { + "href": "https://schema.org/AboutPage", + "rel": "type" + }, + { + "href": "https://schema.org/Dataset", + "rel": "type" + } + ], + "name": "restricted" + } + ], + "validator_cases": [ + { + "findings": [ + { + "code": "AGSC-E202", + "severity": "warn" + } + ], + "name": "home-without-the-describedby-link" + }, + { + "findings": [], + "name": "home-with-the-describedby-link" + } + ] + }, + "id": "disc-0026", + "input": { + "cases": [ + { + "base": "https://a.example/", + "chunks_served": true, + "legal_emitted": true, + "license_url": "https://creativecommons.org/licenses/by/4.0/", + "name": "public-with-doi-and-versioned-licence", + "related": [ + { + "href": "https://doi.org/10.5281/zenodo.1", + "rel": "cite-as", + "type": "text/html" + } + ], + "visibility": "public" + }, + { + "base": "https://a.example/", + "chunks_served": true, + "legal_emitted": true, + "name": "public-defaults", + "related": [], + "visibility": "public" + }, + { + "base": "https://a.example/", + "chunks_served": true, + "legal_emitted": true, + "name": "restricted", + "related": [], + "visibility": "restricted" + } + ], + "validator_cases": [ + { + "home_link_header": [ + "; rel=\"describedby\"; type=\"application/ld+json\"" + ], + "level": 2, + "name": "home-without-the-describedby-link" + }, + { + "home_link_header": [ + "; rel=\"describedby\"; type=\"application/linkset+json\"" + ], + "level": 2, + "name": "home-with-the-describedby-link" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-40" +} diff --git a/tests/fixtures/vectors/discovery/disc-0027-dataset-license-creator-distribution.json b/tests/fixtures/vectors/discovery/disc-0027-dataset-license-creator-distribution.json new file mode 100644 index 0000000..b8b2bb2 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0027-dataset-license-creator-distribution.json @@ -0,0 +1,82 @@ +{ + "area": "discovery", + "description": "AGSC-06-41: the Dataset block of the home page carries, besides name, description and url, a license URL that names a specific version of the licence (here version 4.0 of a Creative Commons licence, from bundle.license_url), a creator (a Person) whose sameAs is https://orcid.org/ followed by the ORCID iD of site.author_orcid, isAccessibleForFree true on a node that is not restricted, and one DataDownload for each machine file the node serves, in the order graph.jsonld, graph.ttl, graph.nq, chunks.jsonl, the discovery document, each with an absolute contentUrl and an encodingFormat (application/jsonl for the chunks). The block names the PROV-O prefix in its @context and holds prov:generatedAtTime (the build instant) and prov:wasAttributedTo (the creator). The second case is the node with none of license_url, creator and ORCID: those three members are omitted and nothing is invented; the PROV-O generation time stays. The third is a restricted node: no distribution. The block is compared as a JSON value (member order is not asserted, as for any page of HTML). Derived by hand from the rule and from the Google Search Central dataset guide (last updated 2026-09-08, read 2026-10-29).", + "expected": { + "withdrawn": true + }, + "id": "disc-0027", + "input": { + "cases": [ + { + "bundle": { + "id": "example", + "license_url": "https://creativecommons.org/licenses/by/4.0/" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.jsonld", + "/graph.ttl", + "/graph.nq", + "/chunks.jsonl", + "/.well-known/knowledge-linkset" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "configured", + "site": { + "author": "Josiah Carberry", + "author_orcid": "0000-0002-1825-0097", + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "public" + }, + { + "bundle": { + "id": "example", + "license_prose": "CC0-1.0" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.nq" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "nothing-configured", + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "public" + }, + { + "bundle": { + "id": "example", + "license_url": "https://creativecommons.org/licenses/by/4.0/" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.jsonld", + "/graph.ttl", + "/graph.nq", + "/chunks.jsonl", + "/.well-known/knowledge-linkset" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "restricted", + "site": { + "author": "Josiah Carberry", + "author_orcid": "0000-0002-1825-0097", + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "restricted" + } + ] + }, + "level": "withdrawn", + "options": { + "spec_version": "1.1.0" + }, + "reason": "Withdrawn for 1.1.0 (2026-11-10). The block had no `@id` and wrote the creator twice, as `creator` and as `prov:wasAttributedTo`, so `jsonld.toRDF` read its triples on blank nodes and found two unlinked Persons. AGSC-06-41 as amended names the block and the Person by `@id`; disc-0037 supersedes this case.", + "rule": "AGSC-06-41", + "superseded_by": "disc-0037" +} diff --git a/tests/fixtures/vectors/discovery/disc-0028-ai-catalog-json-opt-in.json b/tests/fixtures/vectors/discovery/disc-0028-ai-catalog-json-opt-in.json new file mode 100644 index 0000000..3785a87 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0028-ai-catalog-json-opt-in.json @@ -0,0 +1,88 @@ +{ + "area": "discovery", + "description": "AGSC-06-42: /.well-known/ai-catalog.json (the AI Catalog draft, specVersion \"1.0\", ai-catalog.io/spec, read 2026-10-29 — a draft, not a standard, and not in the IANA well-known registry) is emitted only when discovery.ai_catalog is true. The file is {\"entries\":[…],\"specVersion\":\"1.0\"} in JCS form with one trailing LF; an entry has identifier (urn:air::knowledge:, and urn:air::a2a: for the card), displayName, type (the media type the discovery document is served with, parameter included; application/a2a-agent-card+json for the card), url, description and digest, written sha256: and the lowercase hex SHA-256 of the exact bytes served at url; entries are in identifier order, so the card entry (a2a) comes before the discovery entry (knowledge). Four cases: the switch on without a card; with a card; the switch off (no file); the switch on with a host that is not a fully qualified domain name (rejected at build, AGSC-E209). The digests are the SHA-256 of the two byte strings of the input. Derived by hand.", + "expected": { + "cases": [ + { + "file": "{\"entries\":[{\"description\":\"A node of the Agentic Knowledge Web.\",\"digest\":\"sha256:b5bf6e233ec20bbe282b808786bb8530bb2fef37161477af2c9b37037b6c345f\",\"displayName\":\"Example Node\",\"identifier\":\"urn:air:a.example:knowledge:example\",\"type\":\"application/linkset+json; profile=\\\"https://w3id.org/agentic-system-core/profile/agentic-knowledge\\\"\",\"url\":\"https://a.example/.well-known/knowledge-linkset\"}],\"specVersion\":\"1.0\"}\n", + "name": "switch-on-no-card" + }, + { + "file": "{\"entries\":[{\"description\":\"A node of the Agentic Knowledge Web.\",\"digest\":\"sha256:eb817f216412c70562f8824de9d5f13dece75ebb3622565e1701e3e6698276bc\",\"displayName\":\"Example Node\",\"identifier\":\"urn:air:a.example:a2a:example\",\"type\":\"application/a2a-agent-card+json\",\"url\":\"https://a.example/.well-known/agent-card.json\"},{\"description\":\"A node of the Agentic Knowledge Web.\",\"digest\":\"sha256:b5bf6e233ec20bbe282b808786bb8530bb2fef37161477af2c9b37037b6c345f\",\"displayName\":\"Example Node\",\"identifier\":\"urn:air:a.example:knowledge:example\",\"type\":\"application/linkset+json; profile=\\\"https://w3id.org/agentic-system-core/profile/agentic-knowledge\\\"\",\"url\":\"https://a.example/.well-known/knowledge-linkset\"}],\"specVersion\":\"1.0\"}\n", + "name": "switch-on-with-card" + }, + { + "file": null, + "name": "switch-off" + }, + { + "file": null, + "findings": [ + { + "code": "AGSC-E209", + "severity": "error" + } + ], + "name": "host-is-not-a-domain-name" + } + ] + }, + "id": "disc-0028", + "input": { + "cases": [ + { + "ai_catalog": true, + "bundle_id": "example", + "card_bytes": null, + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "switch-on-no-card", + "site": { + "base": "https://a.example/", + "title": "Example Node" + } + }, + { + "ai_catalog": true, + "bundle_id": "example", + "card_bytes": "{\"capabilities\":{},\"name\":\"Example Node\"}\n", + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "switch-on-with-card", + "site": { + "base": "https://a.example/", + "title": "Example Node" + } + }, + { + "ai_catalog": false, + "bundle_id": "example", + "card_bytes": null, + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "switch-off", + "site": { + "base": "https://a.example/", + "title": "Example Node" + } + }, + { + "ai_catalog": true, + "bundle_id": "example", + "card_bytes": null, + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "host-is-not-a-domain-name", + "site": { + "base": "http://localhost:8080/", + "title": "Example Node" + } + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-42" +} diff --git a/tests/fixtures/vectors/discovery/disc-0029-ard-json-opt-in.json b/tests/fixtures/vectors/discovery/disc-0029-ard-json-opt-in.json new file mode 100644 index 0000000..c84b495 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0029-ard-json-opt-in.json @@ -0,0 +1,88 @@ +{ + "area": "discovery", + "description": "AGSC-06-42: /.well-known/ard.json (the Agentic Resource Discovery manifest, version 0.91, status \"Proposal\", dated 26 August 2026, agenticresourcediscovery.org/spec, read 2026-10-29 — a proposal, not a standard, and not in the IANA well-known registry) is emitted only when discovery.ai_catalog is true, beside ai-catalog.json (disc-0028). The file is {\"entries\":[…]} in JCS form with one trailing LF. ARD defines no digest member on an entry, so the SHA-256 of the exact bytes served at url is carried as metadata.digest (sha256: and the lowercase hex); representativeQueries is not written, because it would have to be invented, and the absence is the ARD warning this rule accepts. Entries are in identifier order. The same four cases as disc-0028. Derived by hand.", + "expected": { + "cases": [ + { + "file": "{\"entries\":[{\"description\":\"A node of the Agentic Knowledge Web.\",\"displayName\":\"Example Node\",\"identifier\":\"urn:air:a.example:knowledge:example\",\"metadata\":{\"digest\":\"sha256:b5bf6e233ec20bbe282b808786bb8530bb2fef37161477af2c9b37037b6c345f\"},\"type\":\"application/linkset+json; profile=\\\"https://w3id.org/agentic-system-core/profile/agentic-knowledge\\\"\",\"url\":\"https://a.example/.well-known/knowledge-linkset\"}]}\n", + "name": "switch-on-no-card" + }, + { + "file": "{\"entries\":[{\"description\":\"A node of the Agentic Knowledge Web.\",\"displayName\":\"Example Node\",\"identifier\":\"urn:air:a.example:a2a:example\",\"metadata\":{\"digest\":\"sha256:eb817f216412c70562f8824de9d5f13dece75ebb3622565e1701e3e6698276bc\"},\"type\":\"application/a2a-agent-card+json\",\"url\":\"https://a.example/.well-known/agent-card.json\"},{\"description\":\"A node of the Agentic Knowledge Web.\",\"displayName\":\"Example Node\",\"identifier\":\"urn:air:a.example:knowledge:example\",\"metadata\":{\"digest\":\"sha256:b5bf6e233ec20bbe282b808786bb8530bb2fef37161477af2c9b37037b6c345f\"},\"type\":\"application/linkset+json; profile=\\\"https://w3id.org/agentic-system-core/profile/agentic-knowledge\\\"\",\"url\":\"https://a.example/.well-known/knowledge-linkset\"}]}\n", + "name": "switch-on-with-card" + }, + { + "file": null, + "name": "switch-off" + }, + { + "file": null, + "findings": [ + { + "code": "AGSC-E209", + "severity": "error" + } + ], + "name": "host-is-not-a-domain-name" + } + ] + }, + "id": "disc-0029", + "input": { + "cases": [ + { + "ai_catalog": true, + "bundle_id": "example", + "card_bytes": null, + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "switch-on-no-card", + "site": { + "base": "https://a.example/", + "title": "Example Node" + } + }, + { + "ai_catalog": true, + "bundle_id": "example", + "card_bytes": "{\"capabilities\":{},\"name\":\"Example Node\"}\n", + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "switch-on-with-card", + "site": { + "base": "https://a.example/", + "title": "Example Node" + } + }, + { + "ai_catalog": false, + "bundle_id": "example", + "card_bytes": null, + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "switch-off", + "site": { + "base": "https://a.example/", + "title": "Example Node" + } + }, + { + "ai_catalog": true, + "bundle_id": "example", + "card_bytes": null, + "description": "A node of the Agentic Knowledge Web.", + "discovery_document_bytes": "{\"linkset\":[{\"anchor\":\"https://a.example/\"}]}\n", + "name": "host-is-not-a-domain-name", + "site": { + "base": "http://localhost:8080/", + "title": "Example Node" + } + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-42" +} diff --git a/tests/fixtures/vectors/discovery/disc-0030-a2a-card-with-a-responder.json b/tests/fixtures/vectors/discovery/disc-0030-a2a-card-with-a-responder.json new file mode 100644 index 0000000..9efc5e9 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0030-a2a-card-with-a-responder.json @@ -0,0 +1,102 @@ +{ + "area": "discovery", + "description": "AGSC-06-34: a node that declares both a2a-card and a responder surface emits /.well-known/agent-card.json, the Agent2Agent 1.0 Agent Card (a2a-protocol.org/latest/specification, version 1.0.0, read 2026-10-29; agent-card.json is in the IANA registry as permanent since 2025-08-01). The card carries the members 1.0 requires — name, description, supportedInterfaces, version, capabilities, defaultInputModes, defaultOutputModes, skills — and each skill carries id, name, description and tags (tags is required by 1.0 on every AgentSkill). supportedInterfaces has one interface for the responder entry (url its target, protocolBinding its binding member, protocolVersion the version declared for a2a-card); skills has one skill for each pack of /skills/index.json in index order; version is the content version, and on a restricted node the specification version. Serialised JCS with one trailing LF. Two cases, public and restricted. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "file": "{\"capabilities\":{},\"defaultInputModes\":[\"text/plain\"],\"defaultOutputModes\":[\"application/json\"],\"description\":\"A node of the Agentic Knowledge Web.\",\"name\":\"Example Node\",\"skills\":[{\"description\":\"Recurring shapes for arranging agents and the work that passes between them, gathered in one place.\",\"id\":\"agent-patterns\",\"name\":\"agent-patterns\",\"tags\":[\"knowledge\",\"skill-pack\"]},{\"description\":\"How a worker hands work back.\",\"id\":\"hand-back\",\"name\":\"hand-back\",\"tags\":[\"knowledge\",\"skill-pack\"]}],\"supportedInterfaces\":[{\"protocolBinding\":\"HTTP+JSON\",\"protocolVersion\":\"1.0\",\"url\":\"https://a.example/a2a\"}],\"version\":\"v1.4.0\"}\n", + "name": "public" + }, + { + "file": "{\"capabilities\":{},\"defaultInputModes\":[\"text/plain\"],\"defaultOutputModes\":[\"application/json\"],\"description\":\"A node of the Agentic Knowledge Web.\",\"name\":\"Example Node\",\"skills\":[{\"description\":\"Recurring shapes for arranging agents and the work that passes between them, gathered in one place.\",\"id\":\"agent-patterns\",\"name\":\"agent-patterns\",\"tags\":[\"knowledge\",\"skill-pack\"]},{\"description\":\"How a worker hands work back.\",\"id\":\"hand-back\",\"name\":\"hand-back\",\"tags\":[\"knowledge\",\"skill-pack\"]}],\"supportedInterfaces\":[{\"protocolBinding\":\"HTTP+JSON\",\"protocolVersion\":\"1.0\",\"url\":\"https://a.example/a2a\"}],\"version\":\"1.0.0\"}\n", + "name": "restricted" + } + ] + }, + "id": "disc-0030", + "input": { + "cases": [ + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "public", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "consent", + "binding": "HTTP+JSON", + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + }, + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + } + ], + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "restricted", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "consent", + "binding": "HTTP+JSON", + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + }, + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + } + ], + "visibility": "restricted" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-34" +} diff --git a/tests/fixtures/vectors/discovery/disc-0031-no-responder-no-card.json b/tests/fixtures/vectors/discovery/disc-0031-no-responder-no-card.json new file mode 100644 index 0000000..b9f74db --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0031-no-responder-no-card.json @@ -0,0 +1,125 @@ +{ + "area": "discovery", + "description": "AGSC-06-34 with AGSC-06-07: the card is emitted only when the node declares both a2a-card and a responder surface. Three nodes: a2a-card declared and no responder (no card is emitted, and the declaration is a card without an endpoint, reported as AGSC-E210); a responder declared and no a2a-card (no card, no finding); neither (no card, no finding). A read-only local MCP tool server declares no responder and makes no node eligible. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "file": null, + "findings": [ + { + "code": "AGSC-E210", + "severity": "error" + } + ], + "name": "card-without-responder" + }, + { + "file": null, + "findings": [], + "name": "responder-without-card" + }, + { + "file": null, + "findings": [], + "name": "neither" + } + ] + }, + "id": "disc-0031", + "input": { + "cases": [ + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "card-without-responder", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + } + ], + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "responder-without-card", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "consent", + "binding": "HTTP+JSON", + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + } + ], + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "neither", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [], + "visibility": "public" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-34" +} diff --git a/tests/fixtures/vectors/discovery/disc-0032-prov-o-terms-only-in-the-dataset-block.json b/tests/fixtures/vectors/discovery/disc-0032-prov-o-terms-only-in-the-dataset-block.json new file mode 100644 index 0000000..4b9c461 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0032-prov-o-terms-only-in-the-dataset-block.json @@ -0,0 +1,24 @@ +{ + "area": "discovery", + "description": "AGSC-06-41 with the confinement of the PROV-O terms: the PROV-O terms prov:generatedAtTime and prov:wasAttributedTo appear in the Dataset block of the home page and in no other output of the build: not in graph.jsonld, graph.ttl or graph.nq (their bytes and the @context address stay those of 1.0), not in a pages/.jsonld, not in the block of another index page. The fixture is the minimal Bundle built with SOURCE_DATE_EPOCH set and no git history, with site.author and site.author_orcid configured so that prov:wasAttributedTo is present; the expected list names every emitted file that contains either term. Derived by hand from the rule.", + "expected": { + "files_containing_a_prov_term": [ + "/index.html" + ] + }, + "id": "disc-0032", + "input": { + "add_files": { + "agsc.config.json": "{\n \"bundle\": {\n \"id\": \"minimal\",\n \"license_prose\": \"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\n \"license_schema\": \"CC0-1.0\",\n \"operator\": \"human:andreibesleaga\"\n },\n \"build\": {\n \"out\": \"www\"\n },\n \"site\": {\n \"author\": \"Josiah Carberry\",\n \"author_orcid\": \"0000-0002-1825-0097\",\n \"base\": \"https://minimal.example/\",\n \"tagline\": \"The smallest Bundle that conforms.\",\n \"tdm_crawlers\": [\n \"Applebot-Extended\",\n \"CCBot\",\n \"ClaudeBot\",\n \"GPTBot\",\n \"Google-Extended\",\n \"meta-externalagent\"\n ],\n \"title\": \"Minimal Bundle\"\n },\n \"spec_version\": \"1.0.0\",\n \"tags\": {\n \"allowed\": [\n \"agents\",\n \"patterns\"\n ]\n }\n}\n" + }, + "bundle": "fixtures/minimal", + "git_history": false + }, + "level": "required", + "note": "The build harness (source_date_epoch 1767225600, no git history) is that of build-0029; the case has no handler yet (expected red until the Dataset block lands).", + "options": { + "source_date_epoch": 1767225600, + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-41" +} diff --git a/tests/fixtures/vectors/discovery/disc-0033-chunks-surface-link-carries-digest-count-and-set.json b/tests/fixtures/vectors/discovery/disc-0033-chunks-surface-link-carries-digest-count-and-set.json new file mode 100644 index 0000000..b5e092f --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0033-chunks-surface-link-carries-digest-count-and-set.json @@ -0,0 +1,281 @@ +{ + "area": "discovery", + "description": "AGSC-06-44 with AGSC-06-08: at Level 2 and above the rel#surface link of the chunks surface carries digest (over /chunks.jsonl), agsc-chunk-count and agsc-chunk-set, and validate-wellknown recomputes them over the fetched file and requires them of a document whose agsc-spec-version is 1.1.0 or later. (1) complete: a 1.1.0 document whose chunks link carries the three, over a chunks file of three lines (the export of chk-0014): valid. (2) missing: the same 1.1.0 document without the three: the checker reports AGSC-E202, the code for a required member that is absent. (3) earlier-document: a document that declares 1.0.0 and has no chunks digest: valid, because the attributes are required only of 1.1.0 and later. The files input holds the bytes the checker fetches for each route; every digest in the documents is the SHA-256 of those bytes, so the valid documents recompute. Derived by hand with hashlib.", + "expected": { + "cases": [ + { + "codes_reported": [], + "name": "complete", + "valid": true + }, + { + "codes_reported": [ + "AGSC-E202" + ], + "name": "missing", + "valid": false + }, + { + "codes_reported": [], + "name": "earlier-document", + "valid": true + } + ] + }, + "id": "disc-0033", + "input": { + "cases": [ + { + "document": { + "linkset": [ + { + "alternate": [ + { + "digest": [ + "sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:" + ], + "href": "https://example.org/llms.txt", + "type": "text/plain" + } + ], + "anchor": "https://example.org/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:" + ], + "agsc-bundle-version": [ + "v1.4.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-10-29T00:00:00Z" + ], + "agsc-spec-version": [ + "1.1.0" + ], + "digest": [ + "sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:" + ], + "href": "https://example.org/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + ], + "digest": [ + "sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:" + ], + "href": "https://example.org/ledger.jsonl", + "type": "application/jsonl" + } + ], + "https://w3id.org/agentic-system-core/rel#surface": [ + { + "agsc-access": [ + "none" + ], + "agsc-chunk-count": [ + "3" + ], + "agsc-chunk-set": [ + "sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:" + ], + "agsc-surface": [ + "chunks" + ], + "digest": [ + "sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:" + ], + "href": "https://example.org/chunks.jsonl", + "type": "application/jsonl" + } + ] + } + ] + }, + "files": { + "/chunks.jsonl": "{\"digest\":\"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3\",\"id\":\"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"Intro paragraph.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94\",\"id\":\"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"intent\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Intent\\n\\nCoordinate workers.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5\",\"id\":\"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"structure\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Structure\\n\\n```text\\ncode stays\\n```\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n", + "/graph.jsonld": "{\"@graph\":[]}\n", + "/ledger.jsonl": "{\"hash\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}\n", + "/llms.txt": "# Example\n" + }, + "level": 2, + "name": "complete" + }, + { + "document": { + "linkset": [ + { + "alternate": [ + { + "digest": [ + "sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:" + ], + "href": "https://example.org/llms.txt", + "type": "text/plain" + } + ], + "anchor": "https://example.org/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:" + ], + "agsc-bundle-version": [ + "v1.4.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-10-29T00:00:00Z" + ], + "agsc-spec-version": [ + "1.1.0" + ], + "digest": [ + "sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:" + ], + "href": "https://example.org/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + ], + "digest": [ + "sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:" + ], + "href": "https://example.org/ledger.jsonl", + "type": "application/jsonl" + } + ], + "https://w3id.org/agentic-system-core/rel#surface": [ + { + "agsc-access": [ + "none" + ], + "agsc-surface": [ + "chunks" + ], + "href": "https://example.org/chunks.jsonl", + "type": "application/jsonl" + } + ] + } + ] + }, + "files": { + "/chunks.jsonl": "{\"digest\":\"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3\",\"id\":\"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"Intro paragraph.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94\",\"id\":\"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"intent\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Intent\\n\\nCoordinate workers.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5\",\"id\":\"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"structure\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Structure\\n\\n```text\\ncode stays\\n```\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n", + "/graph.jsonld": "{\"@graph\":[]}\n", + "/ledger.jsonl": "{\"hash\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}\n", + "/llms.txt": "# Example\n" + }, + "level": 2, + "name": "missing" + }, + { + "document": { + "linkset": [ + { + "alternate": [ + { + "digest": [ + "sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:" + ], + "href": "https://example.org/llms.txt", + "type": "text/plain" + } + ], + "anchor": "https://example.org/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:" + ], + "agsc-bundle-version": [ + "v1.4.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-10-29T00:00:00Z" + ], + "agsc-spec-version": [ + "1.0.0" + ], + "digest": [ + "sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:" + ], + "href": "https://example.org/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + ], + "digest": [ + "sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:" + ], + "href": "https://example.org/ledger.jsonl", + "type": "application/jsonl" + } + ], + "https://w3id.org/agentic-system-core/rel#surface": [ + { + "agsc-access": [ + "none" + ], + "agsc-surface": [ + "chunks" + ], + "href": "https://example.org/chunks.jsonl", + "type": "application/jsonl" + } + ] + } + ] + }, + "files": { + "/chunks.jsonl": "{\"digest\":\"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3\",\"id\":\"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"Intro paragraph.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94\",\"id\":\"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"intent\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Intent\\n\\nCoordinate workers.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5\",\"id\":\"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"structure\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Structure\\n\\n```text\\ncode stays\\n```\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n", + "/graph.jsonld": "{\"@graph\":[]}\n", + "/ledger.jsonl": "{\"hash\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}\n", + "/llms.txt": "# Example\n" + }, + "level": 2, + "name": "earlier-document" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-44" +} diff --git a/tests/fixtures/vectors/discovery/disc-0034-restricted-node-llms-txt-has-no-content-version.json b/tests/fixtures/vectors/discovery/disc-0034-restricted-node-llms-txt-has-no-content-version.json new file mode 100644 index 0000000..2358eb6 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0034-restricted-node-llms-txt-has-no-content-version.json @@ -0,0 +1,45 @@ +{ + "area": "discovery", + "description": "AGSC-06-13a with AGSC-11-20: a restricted node leaves the bundle_version line out of the provenance header of /llms.txt, because the content version is commit activity by another name; the header runs from spec_version straight to generated_at, and nothing else of the layout changes. The input is the node of disc-0024 without its escape item and without the draft, marked restricted; the same input, public, gives the bundle_version line. Expected bytes are derived by hand from AGSC-06-13a.", + "expected": { + "output": "# Example Node\n\n> A node of the Agentic Knowledge Web.\n\n\n\n## Coordination\n\n- [Supervisor](https://a.example/concepts/supervisor/): Routes work to workers.\n\n## Other\n\n- [Loose Note](https://a.example/concepts/loose-note/): Loose Note\n" + }, + "id": "disc-0034", + "input": { + "bundle": { + "base": "https://a.example/", + "description": "A node of the Agentic Knowledge Web.", + "license_prose": "LicenseRef-AgenticSystemCore-Content-Use-1.0", + "title": "Example Node" + }, + "bundle_version": "v1.4.0", + "clusters": [ + { + "slug": "coordination", + "title": "Coordination" + } + ], + "generated_at": "2026-09-16T00:00:00Z", + "items": [ + { + "clusters": [ + "coordination" + ], + "description": "Routes work to workers.", + "slug": "supervisor", + "title": "Supervisor" + }, + { + "slug": "loose-note", + "title": "Loose Note" + } + ], + "spec_version": "1.0.0", + "visibility": "restricted" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-13a" +} diff --git a/tests/fixtures/vectors/discovery/disc-0035-a2a-only-card-and-its-declaration.json b/tests/fixtures/vectors/discovery/disc-0035-a2a-only-card-and-its-declaration.json new file mode 100644 index 0000000..6ecf101 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0035-a2a-only-card-and-its-declaration.json @@ -0,0 +1,156 @@ +{ + "area": "discovery", + "description": "AGSC-06-34 with AGSC-11-16 and AGSC-11-21, as amended 2026-11-10: the card lists every responder as an A2A interface and carries the a2a-card version as their protocolVersion, so it is written only when every responder is an A2A one (version a2a:) and the a2a-card version is a bare A2A version. In mcp-responder the responder is an MCP server, and in version-not-bare the a2a-card version is a2a:1.0: no card is written, the warning AGSC-E210 says why, and the discovery document does not declare a2a-card, which the node does not serve. In a2a-responder the card is written and declared. Beside disc-0031, which covers a card with no responder. Derived by hand from the rules.", + "expected": { + "cases": [ + { + "declares_a2a_card": false, + "file": null, + "findings": [ + { + "code": "AGSC-E210", + "severity": "warn" + } + ], + "name": "mcp-responder" + }, + { + "declares_a2a_card": false, + "file": null, + "findings": [ + { + "code": "AGSC-E210", + "severity": "warn" + } + ], + "name": "version-not-bare" + }, + { + "declares_a2a_card": true, + "findings": [], + "name": "a2a-responder" + } + ] + }, + "id": "disc-0035", + "input": { + "cases": [ + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "mcp-responder", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + }, + { + "access": "none", + "surface": "responder", + "target": "https://a.example/mcp", + "version": "mcp:2026-07-28" + } + ], + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "version-not-bare", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "a2a:1.0" + }, + { + "access": "none", + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + } + ], + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "a2a-responder", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + }, + { + "access": "none", + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + } + ], + "visibility": "public" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-34" +} diff --git a/tests/fixtures/vectors/discovery/disc-0036-webmcp-version-is-a-date.json b/tests/fixtures/vectors/discovery/disc-0036-webmcp-version-is-a-date.json new file mode 100644 index 0000000..336e61a --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0036-webmcp-version-is-a-date.json @@ -0,0 +1,232 @@ +{ + "area": "discovery", + "description": "AGSC-11-16 as amended 2026-11-10: the `agsc-surface-version` of a `webmcp` surface is a date of the form YYYY-MM-DD, the date of the WebMCP Draft Community Group Report the node targets. The document of `disc-0033`'s complete case gains a `webmcp` surface for `/compose/`. In `date` its version is 2026-10-27 and the document passes; in `not-a-date` it is 2026-13-45x and the checker of AGSC-09-93 (`tools/validate-wellknown`) reports AGSC-E210. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "codes_reported": [], + "name": "date", + "valid": true + }, + { + "codes_reported": [ + "AGSC-E210" + ], + "name": "not-a-date", + "valid": false + } + ] + }, + "id": "disc-0036", + "input": { + "cases": [ + { + "document": { + "linkset": [ + { + "alternate": [ + { + "digest": [ + "sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:" + ], + "href": "https://example.org/llms.txt", + "type": "text/plain" + } + ], + "anchor": "https://example.org/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:" + ], + "agsc-bundle-version": [ + "v1.4.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-10-29T00:00:00Z" + ], + "agsc-spec-version": [ + "1.1.0" + ], + "digest": [ + "sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:" + ], + "href": "https://example.org/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + ], + "digest": [ + "sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:" + ], + "href": "https://example.org/ledger.jsonl", + "type": "application/jsonl" + } + ], + "https://w3id.org/agentic-system-core/rel#surface": [ + { + "agsc-access": [ + "none" + ], + "agsc-chunk-count": [ + "3" + ], + "agsc-chunk-set": [ + "sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:" + ], + "agsc-surface": [ + "chunks" + ], + "digest": [ + "sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:" + ], + "href": "https://example.org/chunks.jsonl", + "type": "application/jsonl" + }, + { + "agsc-access": [ + "consent" + ], + "agsc-surface": [ + "webmcp" + ], + "agsc-surface-version": [ + "2026-10-27" + ], + "href": "https://example.org/compose/" + } + ] + } + ] + }, + "files": { + "/chunks.jsonl": "{\"digest\":\"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3\",\"id\":\"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"Intro paragraph.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94\",\"id\":\"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"intent\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Intent\\n\\nCoordinate workers.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5\",\"id\":\"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"structure\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Structure\\n\\n```text\\ncode stays\\n```\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n", + "/compose/index.html": "Compose\n", + "/graph.jsonld": "{\"@graph\":[]}\n", + "/ledger.jsonl": "{\"hash\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}\n", + "/llms.txt": "# Example\n" + }, + "level": 2, + "name": "date" + }, + { + "document": { + "linkset": [ + { + "alternate": [ + { + "digest": [ + "sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:" + ], + "href": "https://example.org/llms.txt", + "type": "text/plain" + } + ], + "anchor": "https://example.org/", + "describedby": [ + { + "agsc-bundle-hash": [ + "sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:" + ], + "agsc-bundle-version": [ + "v1.4.0" + ], + "agsc-counts": [ + "clusters=0", + "concepts=1", + "episodes=0", + "gates=0", + "lessons=0", + "procedures=0" + ], + "agsc-generated-at": [ + "2026-10-29T00:00:00Z" + ], + "agsc-spec-version": [ + "1.1.0" + ], + "digest": [ + "sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:" + ], + "href": "https://example.org/graph.jsonld", + "type": "application/ld+json" + } + ], + "https://w3id.org/agentic-system-core/rel#ledger": [ + { + "agsc-ledger-head": [ + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + ], + "digest": [ + "sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:" + ], + "href": "https://example.org/ledger.jsonl", + "type": "application/jsonl" + } + ], + "https://w3id.org/agentic-system-core/rel#surface": [ + { + "agsc-access": [ + "none" + ], + "agsc-chunk-count": [ + "3" + ], + "agsc-chunk-set": [ + "sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:" + ], + "agsc-surface": [ + "chunks" + ], + "digest": [ + "sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:" + ], + "href": "https://example.org/chunks.jsonl", + "type": "application/jsonl" + }, + { + "agsc-access": [ + "consent" + ], + "agsc-surface": [ + "webmcp" + ], + "agsc-surface-version": [ + "2026-13-45x" + ], + "href": "https://example.org/compose/" + } + ] + } + ] + }, + "files": { + "/chunks.jsonl": "{\"digest\":\"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3\",\"id\":\"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"Intro paragraph.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94\",\"id\":\"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"intent\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Intent\\n\\nCoordinate workers.\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n{\"digest\":\"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5\",\"id\":\"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed\",\"iri\":\"https://example.org/concepts/supervisor/\",\"item\":\"supervisor\",\"kind\":\"concept\",\"license\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"links\":{\"requires\":[\"worker\"]},\"ordinal\":0,\"section\":\"structure\",\"subkind\":\"pattern\",\"terms\":\"LicenseRef-AgenticSystemCore-Content-Use-1.0\",\"text\":\"## Structure\\n\\n```text\\ncode stays\\n```\\n\",\"title\":\"Supervisor\",\"trust\":\"untrusted\",\"type\":\"text\"}\n", + "/compose/index.html": "Compose\n", + "/graph.jsonld": "{\"@graph\":[]}\n", + "/ledger.jsonl": "{\"hash\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"}\n", + "/llms.txt": "# Example\n" + }, + "level": 2, + "name": "not-a-date" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-11-16" +} diff --git a/tests/fixtures/vectors/discovery/disc-0037-dataset-block-names-the-bundle-and-one-person.json b/tests/fixtures/vectors/discovery/disc-0037-dataset-block-names-the-bundle-and-one-person.json new file mode 100644 index 0000000..83eea9f --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0037-dataset-block-names-the-bundle-and-one-person.json @@ -0,0 +1,434 @@ +{ + "area": "discovery", + "description": "AGSC-06-41 as amended 2026-11-10, the successor of disc-0027. The Dataset block of the home page is the node `@id` `site.base` (the Bundle IRI), so that its triples describe the Bundle and do not float on a blank node; its `creator` Person has the `@id` of its ORCID iD URL, or `#creator` when no iD is configured, and `prov:wasAttributedTo` names that Person by `@id`, so a JSON-LD reader finds one Person and not two. Cases `configured`, `nothing-configured` and `restricted` are those of disc-0027 with these changes; `creator-without-orcid` names the Person by the fragment. With `discovery.dcat` set to `true` (`dcat-catalogue`), the page carries, beside the Dataset block, a DCAT 3 catalogue block (W3C Recommendation, 22 August 2024): a `dcat:Catalog` `#catalog` whose `dcat:dataset` is the Bundle IRI as a `dcat:Dataset` with `dcterms:title`, `dcterms:description`, `dcterms:license`, `dcterms:creator`, `dcterms:modified` (the build instant) and one `dcat:Distribution` for each `DataDownload` of the Dataset block, with `dcat:downloadURL` and `dcat:mediaType` the IANA media type IRI of the served type, or `dcterms:format` for the chunks, whose type is not registered; `catalog` is null when the switch is off. Each block is compared as a JSON value. Derived by hand from the rule.", + "expected": { + "cases": [ + { + "block": { + "@context": [ + "https://schema.org", + { + "prov": "http://www.w3.org/ns/prov#" + } + ], + "@id": "https://a.example/", + "@type": "Dataset", + "creator": { + "@id": "https://orcid.org/0000-0002-1825-0097", + "@type": "Person", + "name": "Josiah Carberry", + "sameAs": "https://orcid.org/0000-0002-1825-0097" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "distribution": [ + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.jsonld", + "encodingFormat": "application/ld+json" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.ttl", + "encodingFormat": "text/turtle" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.nq", + "encodingFormat": "application/n-quads" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/chunks.jsonl", + "encodingFormat": "application/jsonl" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/.well-known/knowledge-linkset", + "encodingFormat": "application/linkset+json" + } + ], + "isAccessibleForFree": true, + "license": "https://creativecommons.org/licenses/by/4.0/", + "name": "Example Node", + "prov:generatedAtTime": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2026-01-01T00:00:00Z" + }, + "prov:wasAttributedTo": { + "@id": "https://orcid.org/0000-0002-1825-0097" + }, + "url": "https://a.example/" + }, + "catalog": null, + "name": "configured" + }, + { + "block": { + "@context": [ + "https://schema.org", + { + "prov": "http://www.w3.org/ns/prov#" + } + ], + "@id": "https://a.example/", + "@type": "Dataset", + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "distribution": [ + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.nq", + "encodingFormat": "application/n-quads" + } + ], + "isAccessibleForFree": true, + "name": "Example Node", + "prov:generatedAtTime": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2026-01-01T00:00:00Z" + }, + "url": "https://a.example/" + }, + "catalog": null, + "name": "nothing-configured" + }, + { + "block": { + "@context": [ + "https://schema.org", + { + "prov": "http://www.w3.org/ns/prov#" + } + ], + "@id": "https://a.example/", + "@type": "Dataset", + "creator": { + "@id": "https://orcid.org/0000-0002-1825-0097", + "@type": "Person", + "name": "Josiah Carberry", + "sameAs": "https://orcid.org/0000-0002-1825-0097" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "license": "https://creativecommons.org/licenses/by/4.0/", + "name": "Example Node", + "prov:generatedAtTime": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2026-01-01T00:00:00Z" + }, + "prov:wasAttributedTo": { + "@id": "https://orcid.org/0000-0002-1825-0097" + }, + "url": "https://a.example/" + }, + "catalog": null, + "name": "restricted" + }, + { + "block": { + "@context": [ + "https://schema.org", + { + "prov": "http://www.w3.org/ns/prov#" + } + ], + "@id": "https://a.example/", + "@type": "Dataset", + "creator": { + "@id": "https://a.example/#creator", + "@type": "Person", + "name": "Josiah Carberry" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "distribution": [ + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.jsonld", + "encodingFormat": "application/ld+json" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.ttl", + "encodingFormat": "text/turtle" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.nq", + "encodingFormat": "application/n-quads" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/chunks.jsonl", + "encodingFormat": "application/jsonl" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/.well-known/knowledge-linkset", + "encodingFormat": "application/linkset+json" + } + ], + "isAccessibleForFree": true, + "license": "https://creativecommons.org/licenses/by/4.0/", + "name": "Example Node", + "prov:generatedAtTime": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2026-01-01T00:00:00Z" + }, + "prov:wasAttributedTo": { + "@id": "https://a.example/#creator" + }, + "url": "https://a.example/" + }, + "catalog": null, + "name": "creator-without-orcid" + }, + { + "block": { + "@context": [ + "https://schema.org", + { + "prov": "http://www.w3.org/ns/prov#" + } + ], + "@id": "https://a.example/", + "@type": "Dataset", + "creator": { + "@id": "https://orcid.org/0000-0002-1825-0097", + "@type": "Person", + "name": "Josiah Carberry", + "sameAs": "https://orcid.org/0000-0002-1825-0097" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "distribution": [ + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.jsonld", + "encodingFormat": "application/ld+json" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.ttl", + "encodingFormat": "text/turtle" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/graph.nq", + "encodingFormat": "application/n-quads" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/chunks.jsonl", + "encodingFormat": "application/jsonl" + }, + { + "@type": "DataDownload", + "contentUrl": "https://a.example/.well-known/knowledge-linkset", + "encodingFormat": "application/linkset+json" + } + ], + "isAccessibleForFree": true, + "license": "https://creativecommons.org/licenses/by/4.0/", + "name": "Example Node", + "prov:generatedAtTime": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2026-01-01T00:00:00Z" + }, + "prov:wasAttributedTo": { + "@id": "https://orcid.org/0000-0002-1825-0097" + }, + "url": "https://a.example/" + }, + "catalog": { + "@context": { + "dcat": "http://www.w3.org/ns/dcat#", + "dcterms": "http://purl.org/dc/terms/" + }, + "@id": "https://a.example/#catalog", + "@type": "dcat:Catalog", + "dcat:dataset": { + "@id": "https://a.example/", + "@type": "dcat:Dataset", + "dcat:distribution": [ + { + "@type": "dcat:Distribution", + "dcat:downloadURL": { + "@id": "https://a.example/graph.jsonld" + }, + "dcat:mediaType": { + "@id": "https://www.iana.org/assignments/media-types/application/ld+json" + } + }, + { + "@type": "dcat:Distribution", + "dcat:downloadURL": { + "@id": "https://a.example/graph.ttl" + }, + "dcat:mediaType": { + "@id": "https://www.iana.org/assignments/media-types/text/turtle" + } + }, + { + "@type": "dcat:Distribution", + "dcat:downloadURL": { + "@id": "https://a.example/graph.nq" + }, + "dcat:mediaType": { + "@id": "https://www.iana.org/assignments/media-types/application/n-quads" + } + }, + { + "@type": "dcat:Distribution", + "dcat:downloadURL": { + "@id": "https://a.example/chunks.jsonl" + }, + "dcterms:format": "application/jsonl" + }, + { + "@type": "dcat:Distribution", + "dcat:downloadURL": { + "@id": "https://a.example/.well-known/knowledge-linkset" + }, + "dcat:mediaType": { + "@id": "https://www.iana.org/assignments/media-types/application/linkset+json" + } + } + ], + "dcterms:creator": { + "@id": "https://orcid.org/0000-0002-1825-0097" + }, + "dcterms:description": "Recurring shapes for arranging agents and the work that passes between them.", + "dcterms:license": { + "@id": "https://creativecommons.org/licenses/by/4.0/" + }, + "dcterms:modified": { + "@type": "http://www.w3.org/2001/XMLSchema#dateTime", + "@value": "2026-01-01T00:00:00Z" + }, + "dcterms:title": "Example Node" + }, + "dcterms:title": "Example Node" + }, + "name": "dcat-catalogue" + } + ] + }, + "id": "disc-0037", + "input": { + "cases": [ + { + "bundle": { + "id": "example", + "license_url": "https://creativecommons.org/licenses/by/4.0/" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.jsonld", + "/graph.ttl", + "/graph.nq", + "/chunks.jsonl", + "/.well-known/knowledge-linkset" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "configured", + "site": { + "author": "Josiah Carberry", + "author_orcid": "0000-0002-1825-0097", + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "public" + }, + { + "bundle": { + "id": "example", + "license_prose": "CC0-1.0" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.nq" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "nothing-configured", + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "public" + }, + { + "bundle": { + "id": "example", + "license_url": "https://creativecommons.org/licenses/by/4.0/" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.jsonld", + "/graph.ttl", + "/graph.nq", + "/chunks.jsonl", + "/.well-known/knowledge-linkset" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "restricted", + "site": { + "author": "Josiah Carberry", + "author_orcid": "0000-0002-1825-0097", + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "restricted" + }, + { + "bundle": { + "id": "example", + "license_url": "https://creativecommons.org/licenses/by/4.0/" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "files_served": [ + "/graph.jsonld", + "/graph.ttl", + "/graph.nq", + "/chunks.jsonl", + "/.well-known/knowledge-linkset" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "creator-without-orcid", + "site": { + "author": "Josiah Carberry", + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "public" + }, + { + "bundle": { + "id": "example", + "license_url": "https://creativecommons.org/licenses/by/4.0/" + }, + "description": "Recurring shapes for arranging agents and the work that passes between them.", + "discovery": { + "dcat": true + }, + "files_served": [ + "/graph.jsonld", + "/graph.ttl", + "/graph.nq", + "/chunks.jsonl", + "/.well-known/knowledge-linkset" + ], + "instant": "2026-01-01T00:00:00Z", + "name": "dcat-catalogue", + "site": { + "author": "Josiah Carberry", + "author_orcid": "0000-0002-1825-0097", + "base": "https://a.example/", + "title": "Example Node" + }, + "visibility": "public" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-41" +} diff --git a/tests/fixtures/vectors/discovery/disc-0038-card-security-for-a-credential-responder.json b/tests/fixtures/vectors/discovery/disc-0038-card-security-for-a-credential-responder.json new file mode 100644 index 0000000..c1aaa10 --- /dev/null +++ b/tests/fixtures/vectors/discovery/disc-0038-card-security-for-a-credential-responder.json @@ -0,0 +1,126 @@ +{ + "area": "discovery", + "description": "AGSC-06-34 as amended 2026-11-10: the card carries `securitySchemes` and `securityRequirements`, which A2A 1.0 defines as OPTIONAL members of an Agent Card, when the responder entry states `security_schemes` and `security_requirements` (AGSC-01-18), written in A2A's JSON form. In `credential-with-schemes` the responder of `disc-0030` is declared with access `credential` and a bearer scheme; the card carries the scheme and the requirement, and there is no finding. In `credential-without-schemes` it names none: the card is written as before, and the warning AGSC-E210 says that an A2A client reads it as open. The card is compared as bytes: those of disc-0030 with the two members added in JCS order.", + "expected": { + "cases": [ + { + "file": "{\"capabilities\":{},\"defaultInputModes\":[\"text/plain\"],\"defaultOutputModes\":[\"application/json\"],\"description\":\"A node of the Agentic Knowledge Web.\",\"name\":\"Example Node\",\"securityRequirements\":[{\"schemes\":{\"bearer\":{}}}],\"securitySchemes\":{\"bearer\":{\"httpAuthSecurityScheme\":{\"bearerFormat\":\"JWT\",\"scheme\":\"Bearer\"}}},\"skills\":[{\"description\":\"Recurring shapes for arranging agents and the work that passes between them, gathered in one place.\",\"id\":\"agent-patterns\",\"name\":\"agent-patterns\",\"tags\":[\"knowledge\",\"skill-pack\"]},{\"description\":\"How a worker hands work back.\",\"id\":\"hand-back\",\"name\":\"hand-back\",\"tags\":[\"knowledge\",\"skill-pack\"]}],\"supportedInterfaces\":[{\"protocolBinding\":\"HTTP+JSON\",\"protocolVersion\":\"1.0\",\"url\":\"https://a.example/a2a\"}],\"version\":\"v1.4.0\"}\n", + "findings": [], + "name": "credential-with-schemes" + }, + { + "file": "{\"capabilities\":{},\"defaultInputModes\":[\"text/plain\"],\"defaultOutputModes\":[\"application/json\"],\"description\":\"A node of the Agentic Knowledge Web.\",\"name\":\"Example Node\",\"skills\":[{\"description\":\"Recurring shapes for arranging agents and the work that passes between them, gathered in one place.\",\"id\":\"agent-patterns\",\"name\":\"agent-patterns\",\"tags\":[\"knowledge\",\"skill-pack\"]},{\"description\":\"How a worker hands work back.\",\"id\":\"hand-back\",\"name\":\"hand-back\",\"tags\":[\"knowledge\",\"skill-pack\"]}],\"supportedInterfaces\":[{\"protocolBinding\":\"HTTP+JSON\",\"protocolVersion\":\"1.0\",\"url\":\"https://a.example/a2a\"}],\"version\":\"v1.4.0\"}\n", + "findings": [ + { + "code": "AGSC-E210", + "severity": "warn" + } + ], + "name": "credential-without-schemes" + } + ] + }, + "id": "disc-0038", + "input": { + "cases": [ + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "credential-with-schemes", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "credential", + "binding": "HTTP+JSON", + "security_requirements": [ + { + "schemes": { + "bearer": { + "list": [] + } + } + } + ], + "security_schemes": { + "bearer": { + "httpAuthSecurityScheme": { + "bearerFormat": "JWT", + "scheme": "Bearer" + } + } + }, + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + }, + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + } + ], + "visibility": "public" + }, + { + "bundle_version": "v1.4.0", + "description": "A node of the Agentic Knowledge Web.", + "name": "credential-without-schemes", + "packs": [ + { + "description": "Recurring shapes for arranging agents and the work that passes between them, gathered in one place.", + "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md" + }, + { + "description": "How a worker hands work back.", + "name": "hand-back", + "path": "/skills/hand-back/SKILL.md" + } + ], + "site": { + "base": "https://a.example/", + "title": "Example Node" + }, + "spec_version": "1.0.0", + "surfaces": [ + { + "access": "credential", + "binding": "HTTP+JSON", + "surface": "responder", + "target": "https://a.example/a2a", + "version": "a2a:1.0" + }, + { + "access": "none", + "surface": "a2a-card", + "target": "https://a.example/.well-known/agent-card.json", + "version": "1.0" + } + ], + "visibility": "public" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-06-34" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0001-concept-valid.json b/tests/fixtures/vectors/frontmatter/fm-0001-concept-valid.json index 442a8bb..d8a6546 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0001-concept-valid.json +++ b/tests/fixtures/vectors/frontmatter/fm-0001-concept-valid.json @@ -20,7 +20,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-03" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0002-episode-valid.json b/tests/fixtures/vectors/frontmatter/fm-0002-episode-valid.json index fe88d05..cdbbae8 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0002-episode-valid.json +++ b/tests/fixtures/vectors/frontmatter/fm-0002-episode-valid.json @@ -23,7 +23,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-14" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0003-gate-valid.json b/tests/fixtures/vectors/frontmatter/fm-0003-gate-valid.json index 9968bcf..e0faf6f 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0003-gate-valid.json +++ b/tests/fixtures/vectors/frontmatter/fm-0003-gate-valid.json @@ -29,7 +29,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-18" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0004-missing-prov.json b/tests/fixtures/vectors/frontmatter/fm-0004-missing-prov.json index 8bb5ea9..9b4de72 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0004-missing-prov.json +++ b/tests/fixtures/vectors/frontmatter/fm-0004-missing-prov.json @@ -10,7 +10,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-08-01" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0005-yaml-anchor-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0005-yaml-anchor-rejected.json index 88f8c63..3c88333 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0005-yaml-anchor-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0005-yaml-anchor-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0006-failsafe-scalars-are-strings.json b/tests/fixtures/vectors/frontmatter/fm-0006-failsafe-scalars-are-strings.json index 36238ac..aadc256 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0006-failsafe-scalars-are-strings.json +++ b/tests/fixtures/vectors/frontmatter/fm-0006-failsafe-scalars-are-strings.json @@ -47,7 +47,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-03" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0007-stale-after-must-be-instant.json b/tests/fixtures/vectors/frontmatter/fm-0007-stale-after-must-be-instant.json index 56dcd28..e6b14a7 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0007-stale-after-must-be-instant.json +++ b/tests/fixtures/vectors/frontmatter/fm-0007-stale-after-must-be-instant.json @@ -10,7 +10,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-06" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0008-adoption-idempotence.json b/tests/fixtures/vectors/frontmatter/fm-0008-adoption-idempotence.json index 9463f90..b66aa1f 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0008-adoption-idempotence.json +++ b/tests/fixtures/vectors/frontmatter/fm-0008-adoption-idempotence.json @@ -28,7 +28,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-91" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0009-x-namespace-preserved.json b/tests/fixtures/vectors/frontmatter/fm-0009-x-namespace-preserved.json index c43ea7b..dfff0d6 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0009-x-namespace-preserved.json +++ b/tests/fixtures/vectors/frontmatter/fm-0009-x-namespace-preserved.json @@ -32,7 +32,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-05a" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0010-single-line-strings.json b/tests/fixtures/vectors/frontmatter/fm-0010-single-line-strings.json index 0d3b11c..7337cea 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0010-single-line-strings.json +++ b/tests/fixtures/vectors/frontmatter/fm-0010-single-line-strings.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-24" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0011-frontmatter-missing.json b/tests/fixtures/vectors/frontmatter/fm-0011-frontmatter-missing.json index 8e7bd90..3b0a3b4 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0011-frontmatter-missing.json +++ b/tests/fixtures/vectors/frontmatter/fm-0011-frontmatter-missing.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-01" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0012-frontmatter-not-terminated.json b/tests/fixtures/vectors/frontmatter/fm-0012-frontmatter-not-terminated.json index 7bcef66..a302c9f 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0012-frontmatter-not-terminated.json +++ b/tests/fixtures/vectors/frontmatter/fm-0012-frontmatter-not-terminated.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-01" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0013-document-terminator-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0013-document-terminator-rejected.json index f1cc751..da89d97 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0013-document-terminator-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0013-document-terminator-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-01" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0014-yaml-tag-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0014-yaml-tag-rejected.json index 9364d19..f64db32 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0014-yaml-tag-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0014-yaml-tag-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0015-yaml-merge-key-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0015-yaml-merge-key-rejected.json index 7cd8e2c..0db6602 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0015-yaml-merge-key-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0015-yaml-merge-key-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0016-yaml-flow-mapping-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0016-yaml-flow-mapping-rejected.json index 887ea76..bef0c3b 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0016-yaml-flow-mapping-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0016-yaml-flow-mapping-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0017-yaml-complex-key-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0017-yaml-complex-key-rejected.json index 06c6d35..39b1ec0 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0017-yaml-complex-key-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0017-yaml-complex-key-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0018-duplicate-key-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0018-duplicate-key-rejected.json index 9ed0c17..bb585eb 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0018-duplicate-key-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0018-duplicate-key-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0019-description-bound-on-every-type.json b/tests/fixtures/vectors/frontmatter/fm-0019-description-bound-on-every-type.json index f711a85..21a198f 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0019-description-bound-on-every-type.json +++ b/tests/fixtures/vectors/frontmatter/fm-0019-description-bound-on-every-type.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-24" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0020-yaml-explicit-key-rejected.json b/tests/fixtures/vectors/frontmatter/fm-0020-yaml-explicit-key-rejected.json index d096748..5d77190 100644 --- a/tests/fixtures/vectors/frontmatter/fm-0020-yaml-explicit-key-rejected.json +++ b/tests/fixtures/vectors/frontmatter/fm-0020-yaml-explicit-key-rejected.json @@ -11,7 +11,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-02" } diff --git a/tests/fixtures/vectors/frontmatter/fm-0021-nesting-deeper-than-64-levels-warned.json b/tests/fixtures/vectors/frontmatter/fm-0021-nesting-deeper-than-64-levels-warned.json new file mode 100644 index 0000000..4a3e406 --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0021-nesting-deeper-than-64-levels-warned.json @@ -0,0 +1,22 @@ +{ + "area": "frontmatter", + "description": "AGSC-02-02 as amended for 1.1: block mappings and sequences nest to 64 levels, the frontmatter mapping itself being level 1; a frontmatter nested deeper that a tool can still read and write back is the warning AGSC-E105 and is processed as authored. Derivation: the vendor key x-acme-nest (AGSC-02-05a, so no AGSC-E207) opens a mapping at level 2 and each further key a:, indented two spaces more, opens one level more; the file below has 64 nested levels under the root, 65 in all, one more than the bound, so one warning and no error. The frontmatter parses: a conforming reader still reads it.", + "expected": { + "errors": [], + "warnings": [ + { + "code": "AGSC-E105", + "severity": "warn" + } + ] + }, + "id": "fm-0021", + "input": { + "markdown": "---\ntype: concept\ntitle: Account\ndescription: A term of the case on the domain keys; its keys are the point of the case.\nkind: term\nx-acme-nest:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a: leaf\nprov:\n origin: human\n operator: human:tester\n---\n\n## Intent\n\nText.\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-02" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0022-domain-keys-are-read.json b/tests/fixtures/vectors/frontmatter/fm-0022-domain-keys-are-read.json new file mode 100644 index 0000000..fbae5da --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0022-domain-keys-are-read.json @@ -0,0 +1,33 @@ +{ + "area": "frontmatter", + "description": "AGSC-02-25: an item may carry domain_type, domain_role, domain_context and warrant. Derivation: the frontmatter below carries all four with valid values (the role is one of the five, the warrant has a source and one of the three types), so it has no error, and the parsed frontmatter holds the four keys with the warrant as a nested mapping, every scalar a string (AGSC-02-03). A domain_type that names no class of a vocabulary file and a domain_context that names no declared context are AGSC-E418, which needs the configuration and is pinned by lint-0061, not here.", + "expected": { + "errors": [], + "frontmatter": { + "description": "A term of the case on the domain keys; its keys are the point of the case.", + "domain_context": "billing", + "domain_role": "aggregate-root", + "domain_type": "Account", + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "title": "Account", + "type": "concept", + "warrant": { + "source": "https://example.org/policy/accounts", + "type": "organisational" + } + } + }, + "id": "fm-0022", + "input": { + "markdown": "---\ntype: concept\ntitle: Account\ndescription: A term of the case on the domain keys; its keys are the point of the case.\nkind: term\ndomain_type: Account\ndomain_role: aggregate-root\ndomain_context: billing\nwarrant:\n source: https://example.org/policy/accounts\n type: organisational\nprov:\n origin: human\n operator: human:tester\n---\n\n## Intent\n\nText.\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-25" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0023-domain-role-outside-the-five-is-refused.json b/tests/fixtures/vectors/frontmatter/fm-0023-domain-role-outside-the-five-is-refused.json new file mode 100644 index 0000000..4574d2b --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0023-domain-role-outside-the-five-is-refused.json @@ -0,0 +1,17 @@ +{ + "area": "frontmatter", + "description": "AGSC-02-25: domain_role is one of aggregate-root, entity, value-object, domain-event and policy. Derivation: the frontmatter writes manager, which is none of them; the precedence paragraph of spec/09 section 9.4 gives every value outside an enumeration the code AGSC-E203. The key is on line 6, after type, title, description and kind (lines 2 to 5) and the opening line.", + "expected": { + "error": "AGSC-E203", + "line": 6 + }, + "id": "fm-0023", + "input": { + "markdown": "---\ntype: concept\ntitle: Account\ndescription: A term of the case on the domain keys; its keys are the point of the case.\nkind: term\ndomain_role: manager\nprov:\n origin: human\n operator: human:tester\n---\n\n## Intent\n\nText.\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-25" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0024-warrant-without-a-source-is-refused.json b/tests/fixtures/vectors/frontmatter/fm-0024-warrant-without-a-source-is-refused.json new file mode 100644 index 0000000..3fdc3d0 --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0024-warrant-without-a-source-is-refused.json @@ -0,0 +1,17 @@ +{ + "area": "frontmatter", + "description": "AGSC-02-25: a warrant needs a source and a type. Derivation: the warrant below has a type, literary, and no source, so it is AGSC-E512, the code that names a warrant without a source or with a type outside literary, user and organisational; AGSC-E512 is more specific than the AGSC-E201 a schema failure would otherwise give. The warrant key is on line 6.", + "expected": { + "error": "AGSC-E512", + "line": 6 + }, + "id": "fm-0024", + "input": { + "markdown": "---\ntype: concept\ntitle: Account\ndescription: A term of the case on the domain keys; its keys are the point of the case.\nkind: term\nwarrant:\n type: literary\nprov:\n origin: human\n operator: human:tester\n---\n\n## Intent\n\nText.\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-25" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0025-domain-keys-are-known-keys.json b/tests/fixtures/vectors/frontmatter/fm-0025-domain-keys-are-known-keys.json new file mode 100644 index 0000000..acde856 --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0025-domain-keys-are-known-keys.json @@ -0,0 +1,46 @@ +{ + "area": "frontmatter", + "description": "AGSC-02-25 with AGSC-00-21: from 1.1 the four domain keys are known keys, so a tool that implements 1.1 reports no AGSC-E207 for them, while a key it does not know, colour, is still the warning AGSC-E207 and is preserved. (A 1.0 tool reports AGSC-E207 for all five and preserves them; that is why the keys are safe to add.) The item is given pre-parsed, with its slug.", + "expected": { + "findings": [ + { + "code": "AGSC-E207", + "key": "colour", + "severity": "warn" + } + ], + "no_warning_for": [ + "domain_context", + "domain_role", + "domain_type", + "warrant" + ] + }, + "id": "fm-0025", + "input": { + "frontmatter": { + "colour": "blue", + "description": "A term of the case on the domain keys; its keys are the point of the case.", + "domain_context": "billing", + "domain_role": "entity", + "domain_type": "Account", + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "account", + "title": "Account", + "type": "concept", + "warrant": { + "source": "https://example.org/policy/accounts", + "type": "user" + } + } + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-25" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0026-nesting-of-64-levels-is-silent.json b/tests/fixtures/vectors/frontmatter/fm-0026-nesting-of-64-levels-is-silent.json new file mode 100644 index 0000000..3b03c6f --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0026-nesting-of-64-levels-is-silent.json @@ -0,0 +1,17 @@ +{ + "area": "frontmatter", + "description": "The near miss of fm-0021: the same frontmatter with one level less, 64 in all, is within the bound of AGSC-02-02 and gives no finding of any code. The case asserts that there is no error and that the number of warnings is 0.", + "expected": { + "errors": [], + "warning_count": 0 + }, + "id": "fm-0026", + "input": { + "markdown": "---\ntype: concept\ntitle: Account\ndescription: A term of the case on the domain keys; its keys are the point of the case.\nkind: term\nx-acme-nest:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a:\n a: leaf\nprov:\n origin: human\n operator: human:tester\n---\n\n## Intent\n\nText.\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-02" +} diff --git a/tests/fixtures/vectors/frontmatter/fm-0027-warrant-type-outside-the-three-is-refused.json b/tests/fixtures/vectors/frontmatter/fm-0027-warrant-type-outside-the-three-is-refused.json new file mode 100644 index 0000000..c15f911 --- /dev/null +++ b/tests/fixtures/vectors/frontmatter/fm-0027-warrant-type-outside-the-three-is-refused.json @@ -0,0 +1,17 @@ +{ + "area": "frontmatter", + "description": "AGSC-02-25: the type of a warrant is one of literary, user and organisational, the three kinds of warrant of ANSI/NISO Z39.19. Derivation: the warrant below has a source and the type personal, which is none of the three, so AGSC-E512 (not AGSC-E203, which AGSC-E512 is more specific than). The warrant key is on line 6.", + "expected": { + "error": "AGSC-E512", + "line": 6 + }, + "id": "fm-0027", + "input": { + "markdown": "---\ntype: concept\ntitle: Account\ndescription: A term of the case on the domain keys; its keys are the point of the case.\nkind: term\nwarrant:\n source: https://example.org/survey\n type: personal\nprov:\n origin: human\n operator: human:tester\n---\n\n## Intent\n\nText.\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-02-25" +} diff --git a/tests/fixtures/vectors/frontmatter/frontmatter-0030-length-in-code-points.json b/tests/fixtures/vectors/frontmatter/frontmatter-0030-length-in-code-points.json index 3d87742..c979e3c 100644 --- a/tests/fixtures/vectors/frontmatter/frontmatter-0030-length-in-code-points.json +++ b/tests/fixtures/vectors/frontmatter/frontmatter-0030-length-in-code-points.json @@ -31,7 +31,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-24" } diff --git a/tests/fixtures/vectors/frontmatter/frontmatter-0031-task-state.json b/tests/fixtures/vectors/frontmatter/frontmatter-0031-task-state.json index f2d7798..5356bd6 100644 --- a/tests/fixtures/vectors/frontmatter/frontmatter-0031-task-state.json +++ b/tests/fixtures/vectors/frontmatter/frontmatter-0031-task-state.json @@ -43,7 +43,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-99" } diff --git a/tests/fixtures/vectors/graph/graph-0003-blank-node-rejected.json b/tests/fixtures/vectors/graph/graph-0003-blank-node-rejected.json index 3f56814..ff86f05 100644 --- a/tests/fixtures/vectors/graph/graph-0003-blank-node-rejected.json +++ b/tests/fixtures/vectors/graph/graph-0003-blank-node-rejected.json @@ -11,7 +11,7 @@ }, "level": "withdrawn", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "reason": "Withdrawn for 1.0.0 (2026-10-02). The case expected AGSC-E605 for a blank node in a fenced block marked `export`, but AGSC-02-22 says such a block MUST NOT be extracted at 1.x and is the warning AGSC-E415, so no blank node from it can reach an export and AGSC-05-08 does not apply; the reference engine follows the rule, and the case passed only through a runner path that checked the block in isolation. By AGSC-00-03 the rule wins. Superseded by graph-0027, which runs the real lint and build.", "rule": "AGSC-05-08", diff --git a/tests/fixtures/vectors/graph/graph-0005-memory-alias-resolution.json b/tests/fixtures/vectors/graph/graph-0005-memory-alias-resolution.json index 4863173..31f025b 100644 --- a/tests/fixtures/vectors/graph/graph-0005-memory-alias-resolution.json +++ b/tests/fixtures/vectors/graph/graph-0005-memory-alias-resolution.json @@ -19,7 +19,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-04b" } diff --git a/tests/fixtures/vectors/graph/graph-0011-context-file-roundtrip.json b/tests/fixtures/vectors/graph/graph-0011-context-file-roundtrip.json index dbecdff..b876fcf 100644 --- a/tests/fixtures/vectors/graph/graph-0011-context-file-roundtrip.json +++ b/tests/fixtures/vectors/graph/graph-0011-context-file-roundtrip.json @@ -66,7 +66,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-32" } diff --git a/tests/fixtures/vectors/graph/graph-0012-nquads-escaping-and-datatypes.json b/tests/fixtures/vectors/graph/graph-0012-nquads-escaping-and-datatypes.json index 7f275c5..e437d22 100644 --- a/tests/fixtures/vectors/graph/graph-0012-nquads-escaping-and-datatypes.json +++ b/tests/fixtures/vectors/graph/graph-0012-nquads-escaping-and-datatypes.json @@ -25,7 +25,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-32" } diff --git a/tests/fixtures/vectors/graph/graph-0016-attachment-nodes-complete.json b/tests/fixtures/vectors/graph/graph-0016-attachment-nodes-complete.json index 9e521ef..15ca06c 100644 --- a/tests/fixtures/vectors/graph/graph-0016-attachment-nodes-complete.json +++ b/tests/fixtures/vectors/graph/graph-0016-attachment-nodes-complete.json @@ -40,7 +40,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-29" } diff --git a/tests/fixtures/vectors/graph/graph-0017-ports-and-task-state-whole-file.json b/tests/fixtures/vectors/graph/graph-0017-ports-and-task-state-whole-file.json index dca98c8..cac4711 100644 --- a/tests/fixtures/vectors/graph/graph-0017-ports-and-task-state-whole-file.json +++ b/tests/fixtures/vectors/graph/graph-0017-ports-and-task-state-whole-file.json @@ -40,7 +40,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-30" } diff --git a/tests/fixtures/vectors/graph/graph-0018-literal-forms-iri-order.json b/tests/fixtures/vectors/graph/graph-0018-literal-forms-iri-order.json index e5f28a9..9da60f5 100644 --- a/tests/fixtures/vectors/graph/graph-0018-literal-forms-iri-order.json +++ b/tests/fixtures/vectors/graph/graph-0018-literal-forms-iri-order.json @@ -38,7 +38,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-31" } diff --git a/tests/fixtures/vectors/graph/graph-0019-context-term-names.json b/tests/fixtures/vectors/graph/graph-0019-context-term-names.json index 4947009..050a2c1 100644 --- a/tests/fixtures/vectors/graph/graph-0019-context-term-names.json +++ b/tests/fixtures/vectors/graph/graph-0019-context-term-names.json @@ -90,7 +90,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-06-32" } diff --git a/tests/fixtures/vectors/graph/graph-0021-nquads-blank-node-free-sorted-named-graph.json b/tests/fixtures/vectors/graph/graph-0021-nquads-blank-node-free-sorted-named-graph.json index 034e29d..4daab35 100644 --- a/tests/fixtures/vectors/graph/graph-0021-nquads-blank-node-free-sorted-named-graph.json +++ b/tests/fixtures/vectors/graph/graph-0021-nquads-blank-node-free-sorted-named-graph.json @@ -29,7 +29,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-15" } diff --git a/tests/fixtures/vectors/graph/graph-0022-cluster-nesting-is-skos-member-named-graph.json b/tests/fixtures/vectors/graph/graph-0022-cluster-nesting-is-skos-member-named-graph.json index 240ed33..7c41755 100644 --- a/tests/fixtures/vectors/graph/graph-0022-cluster-nesting-is-skos-member-named-graph.json +++ b/tests/fixtures/vectors/graph/graph-0022-cluster-nesting-is-skos-member-named-graph.json @@ -43,7 +43,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-19" } diff --git a/tests/fixtures/vectors/graph/graph-0023-source-fragment-iri-named-graph.json b/tests/fixtures/vectors/graph/graph-0023-source-fragment-iri-named-graph.json index 3386343..925f6d4 100644 --- a/tests/fixtures/vectors/graph/graph-0023-source-fragment-iri-named-graph.json +++ b/tests/fixtures/vectors/graph/graph-0023-source-fragment-iri-named-graph.json @@ -30,7 +30,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-14" } diff --git a/tests/fixtures/vectors/graph/graph-0024-item-reachability-edges-named-graph.json b/tests/fixtures/vectors/graph/graph-0024-item-reachability-edges-named-graph.json index 4260ae8..ce56e09 100644 --- a/tests/fixtures/vectors/graph/graph-0024-item-reachability-edges-named-graph.json +++ b/tests/fixtures/vectors/graph/graph-0024-item-reachability-edges-named-graph.json @@ -34,7 +34,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-27" } diff --git a/tests/fixtures/vectors/graph/graph-0025-inline-link-mentions-named-graph.json b/tests/fixtures/vectors/graph/graph-0025-inline-link-mentions-named-graph.json index 3cfcd1a..bf2da44 100644 --- a/tests/fixtures/vectors/graph/graph-0025-inline-link-mentions-named-graph.json +++ b/tests/fixtures/vectors/graph/graph-0025-inline-link-mentions-named-graph.json @@ -32,7 +32,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-27" } diff --git a/tests/fixtures/vectors/graph/graph-0026-turtle-profile-whole-file-own-licence.json b/tests/fixtures/vectors/graph/graph-0026-turtle-profile-whole-file-own-licence.json index 8d7f10a..46e9913 100644 --- a/tests/fixtures/vectors/graph/graph-0026-turtle-profile-whole-file-own-licence.json +++ b/tests/fixtures/vectors/graph/graph-0026-turtle-profile-whole-file-own-licence.json @@ -30,7 +30,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-05-10" } diff --git a/tests/fixtures/vectors/graph/graph-0027-export-block-reserved-never-extracted.json b/tests/fixtures/vectors/graph/graph-0027-export-block-reserved-never-extracted.json index 468831f..eb1d5d3 100644 --- a/tests/fixtures/vectors/graph/graph-0027-export-block-reserved-never-extracted.json +++ b/tests/fixtures/vectors/graph/graph-0027-export-block-reserved-never-extracted.json @@ -26,7 +26,7 @@ "level": "required", "options": { "source_date_epoch": 1767225600, - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-22" } diff --git a/tests/fixtures/vectors/graph/graph-0029-derived-readings-with-because.json b/tests/fixtures/vectors/graph/graph-0029-derived-readings-with-because.json new file mode 100644 index 0000000..a80c55b --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0029-derived-readings-with-because.json @@ -0,0 +1,627 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-33: the readings of a small Link graph, each with its reasons. The graph holds a `broader` chain `a`, `b`, `c`; a `requires` chain `x`, `y`, `z`; a `supersedes` chain `p`, `q`, `r`; a `derived-from` chain from the lesson `l` through the episode `e1` to the episode `e0`; a `blocked-by` chain `t1`, `t2`, `t3`; and one `related` pair. Every authored edge gives an `inverse` reading, `related` gives a `symmetric` one, each chain of two edges gives a `transitive` reading (for `requires`, `closure`) in both directions through the computed inverse key, and a pair that already holds a direct edge is not a reading. Ordered by source, key and target. `graph_files_unchanged` states that the four graph files of the same input carry none of the transitive readings.", + "expected": { + "graph_files_unchanged": true, + "readings": [ + { + "because": [ + { + "from": [ + [ + "a", + "broader", + "b" + ], + [ + "b", + "broader", + "c" + ] + ], + "rule": "transitive" + } + ], + "key": "broader", + "source": "a", + "target": "c" + }, + { + "because": [ + { + "from": [ + [ + "a", + "broader", + "b" + ] + ], + "rule": "inverse" + } + ], + "key": "narrower", + "source": "b", + "target": "a" + }, + { + "because": [ + { + "from": [ + [ + "c", + "narrower", + "b" + ], + [ + "b", + "narrower", + "a" + ] + ], + "rule": "transitive" + } + ], + "key": "narrower", + "source": "c", + "target": "a" + }, + { + "because": [ + { + "from": [ + [ + "b", + "broader", + "c" + ] + ], + "rule": "inverse" + } + ], + "key": "narrower", + "source": "c", + "target": "b" + }, + { + "because": [ + { + "from": [ + [ + "e1", + "derived-from", + "e0" + ] + ], + "rule": "inverse" + } + ], + "key": "derivation-of", + "source": "e0", + "target": "e1" + }, + { + "because": [ + { + "from": [ + [ + "e0", + "derivation-of", + "e1" + ], + [ + "e1", + "derivation-of", + "l" + ] + ], + "rule": "transitive" + } + ], + "key": "derivation-of", + "source": "e0", + "target": "l" + }, + { + "because": [ + { + "from": [ + [ + "l", + "derived-from", + "e1" + ] + ], + "rule": "inverse" + } + ], + "key": "derivation-of", + "source": "e1", + "target": "l" + }, + { + "because": [ + { + "from": [ + [ + "l", + "derived-from", + "e1" + ], + [ + "e1", + "derived-from", + "e0" + ] + ], + "rule": "transitive" + } + ], + "key": "derived-from", + "source": "l", + "target": "e0" + }, + { + "because": [ + { + "from": [ + [ + "p", + "supersedes", + "q" + ], + [ + "q", + "supersedes", + "r" + ] + ], + "rule": "transitive" + } + ], + "key": "supersedes", + "source": "p", + "target": "r" + }, + { + "because": [ + { + "from": [ + [ + "p", + "supersedes", + "q" + ] + ], + "rule": "inverse" + } + ], + "key": "superseded-by", + "source": "q", + "target": "p" + }, + { + "because": [ + { + "from": [ + [ + "r", + "superseded-by", + "q" + ], + [ + "q", + "superseded-by", + "p" + ] + ], + "rule": "transitive" + } + ], + "key": "superseded-by", + "source": "r", + "target": "p" + }, + { + "because": [ + { + "from": [ + [ + "q", + "supersedes", + "r" + ] + ], + "rule": "inverse" + } + ], + "key": "superseded-by", + "source": "r", + "target": "q" + }, + { + "because": [ + { + "from": [ + [ + "t1", + "blocked-by", + "t2" + ], + [ + "t2", + "blocked-by", + "t3" + ] + ], + "rule": "transitive" + } + ], + "key": "blocked-by", + "source": "t1", + "target": "t3" + }, + { + "because": [ + { + "from": [ + [ + "t1", + "blocked-by", + "t2" + ] + ], + "rule": "inverse" + } + ], + "key": "blocks", + "source": "t2", + "target": "t1" + }, + { + "because": [ + { + "from": [ + [ + "t3", + "blocks", + "t2" + ], + [ + "t2", + "blocks", + "t1" + ] + ], + "rule": "transitive" + } + ], + "key": "blocks", + "source": "t3", + "target": "t1" + }, + { + "because": [ + { + "from": [ + [ + "t2", + "blocked-by", + "t3" + ] + ], + "rule": "inverse" + } + ], + "key": "blocks", + "source": "t3", + "target": "t2" + }, + { + "because": [ + { + "from": [ + [ + "s", + "related", + "u" + ] + ], + "rule": "symmetric" + } + ], + "key": "related", + "source": "u", + "target": "s" + }, + { + "because": [ + { + "from": [ + [ + "x", + "requires", + "y" + ], + [ + "y", + "requires", + "z" + ] + ], + "rule": "closure" + } + ], + "key": "requires", + "source": "x", + "target": "z" + }, + { + "because": [ + { + "from": [ + [ + "x", + "requires", + "y" + ] + ], + "rule": "inverse" + } + ], + "key": "required-by", + "source": "y", + "target": "x" + }, + { + "because": [ + { + "from": [ + [ + "z", + "required-by", + "y" + ], + [ + "y", + "required-by", + "x" + ] + ], + "rule": "closure" + } + ], + "key": "required-by", + "source": "z", + "target": "x" + }, + { + "because": [ + { + "from": [ + [ + "y", + "requires", + "z" + ] + ], + "rule": "inverse" + } + ], + "key": "required-by", + "source": "z", + "target": "y" + } + ] + }, + "id": "graph-0029", + "input": { + "items": [ + { + "broader": [ + "b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "a", + "title": "a", + "type": "concept" + }, + { + "broader": [ + "c" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "b", + "title": "b", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c", + "title": "c", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "derived-from": [ + "e1" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "related": [ + "u" + ], + "slug": "s", + "title": "s", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "u", + "title": "u", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-33" +} diff --git a/tests/fixtures/vectors/graph/graph-0030-question-1-requires-closure.json b/tests/fixtures/vectors/graph/graph-0030-question-1-requires-closure.json new file mode 100644 index 0000000..8e9b7d2 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0030-question-1-requires-closure.json @@ -0,0 +1,402 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 1. If I choose `x`, what else must I take? `x` requires `y`, which requires `z`: the answer is `y` and `z`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": [ + "y", + "z" + ] + }, + "id": "graph-0030", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 1, + "subject": "x" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0031-question-2-excludes-both-ways.json b/tests/fixtures/vectors/graph/graph-0031-question-2-excludes-both-ways.json new file mode 100644 index 0000000..cd3202d --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0031-question-2-excludes-both-ways.json @@ -0,0 +1,401 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 2. What can never go with `ex2`? `ex1` authors `excludes` toward `ex2`; AGSC-03-05 makes the edge run both ways, so `ex2` excludes `ex1`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": [ + "ex1" + ] + }, + "id": "graph-0031", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 2, + "subject": "ex2" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0032-question-3-what-replaced-it.json b/tests/fixtures/vectors/graph/graph-0032-question-3-what-replaced-it.json new file mode 100644 index 0000000..d494a69 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0032-question-3-what-replaced-it.json @@ -0,0 +1,402 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 3. What replaced `r`, directly or through a chain? `q` supersedes `r` and `p` supersedes `q`: the answer is `p` and `q`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": [ + "p", + "q" + ] + }, + "id": "graph-0032", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 3, + "subject": "r" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0033-question-4-ports-nobody-provides.json b/tests/fixtures/vectors/graph/graph-0033-question-4-ports-nobody-provides.json new file mode 100644 index 0000000..fa6ef50 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0033-question-4-ports-nobody-provides.json @@ -0,0 +1,404 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 4. What does `consumer` need that nobody in the selection provides? `consumer` consumes `cap-a` and `cap-b`; the selection holds `prod`, which produces `cap-a`: the answer is `cap-b`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": [ + "cap-b" + ] + }, + "id": "graph-0033", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 4, + "selection": [ + "prod" + ], + "subject": "consumer" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0034-question-5-verifies-both-ways.json b/tests/fixtures/vectors/graph/graph-0034-question-5-verifies-both-ways.json new file mode 100644 index 0000000..3035661 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0034-question-5-verifies-both-ways.json @@ -0,0 +1,404 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 5. What verifies `spec1`, and what does `spec1` verify? `ver` verifies `spec1`; `spec1` verifies nothing. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": { + "verified_by": [ + "ver" + ], + "verifies": [] + } + }, + "id": "graph-0034", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 5, + "subject": "spec1" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0035-question-6-blockers-through-a-chain.json b/tests/fixtures/vectors/graph/graph-0035-question-6-blockers-through-a-chain.json new file mode 100644 index 0000000..39e2ed6 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0035-question-6-blockers-through-a-chain.json @@ -0,0 +1,402 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 6. What blocks `t1`, directly or through a chain? `t1` is blocked by `t2`, which is blocked by `t3`: the answer is `t2` and `t3`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": [ + "t2", + "t3" + ] + }, + "id": "graph-0035", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 6, + "subject": "t1" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0036-question-7-lineage-to-an-episode.json b/tests/fixtures/vectors/graph/graph-0036-question-7-lineage-to-an-episode.json new file mode 100644 index 0000000..b5c7088 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0036-question-7-lineage-to-an-episode.json @@ -0,0 +1,409 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 7. Where did the lesson `l` come from? `l` derives from the episode `e1` and the concept `m`, and `e1` from the episode `e0`: the lineage is `e0`, `e1` and `m`, of which `e0` and `e1` are episodes. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": { + "episodes": [ + "e0", + "e1" + ], + "lineage": [ + "e0", + "e1", + "m" + ] + } + }, + "id": "graph-0036", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 7, + "subject": "l" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0037-question-8-items-under-a-cluster.json b/tests/fixtures/vectors/graph/graph-0037-question-8-items-under-a-cluster.json new file mode 100644 index 0000000..7b66737 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0037-question-8-items-under-a-cluster.json @@ -0,0 +1,407 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 8. Which items sit under the cluster `c-top` and its sub-clusters? `c-sub` nests under `c-top`; `i2` is listed by `c-top` and `i1` by `c-sub`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": { + "clusters": [ + "c-sub" + ], + "items": [ + "i1", + "i2" + ] + } + }, + "id": "graph-0037", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 8, + "subject": "c-top" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0038-question-9-stale-draft-deprecated.json b/tests/fixtures/vectors/graph/graph-0038-question-9-stale-draft-deprecated.json new file mode 100644 index 0000000..029374f --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0038-question-9-stale-draft-deprecated.json @@ -0,0 +1,431 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 9. Which of the selected items are stale, draft or deprecated at 2026-10-29? `st` is stale, `dr` is a draft, `dep` is deprecated and `ret` is retired; `ok` has no reason and is left out. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": [ + { + "reasons": [ + "deprecated" + ], + "slug": "dep" + }, + { + "reasons": [ + "draft" + ], + "slug": "dr" + }, + { + "reasons": [ + "retired" + ], + "slug": "ret" + }, + { + "reasons": [ + "stale" + ], + "slug": "st" + } + ] + }, + "id": "graph-0038", + "input": { + "at": "2026-10-29T00:00:00Z", + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 9, + "selection": [ + "st", + "dr", + "dep", + "ret", + "ok" + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0039-question-10-shared-sources.json b/tests/fixtures/vectors/graph/graph-0039-question-10-shared-sources.json new file mode 100644 index 0000000..eaa1983 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0039-question-10-shared-sources.json @@ -0,0 +1,418 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-34, question 10. Which sources back `s1`, and which other items share them? `s1` cites resources `a` and `b`; `s2` also cites `a` and `s3` also cites `b`; `c` is cited by `s3` alone and not by `s1`. The input is one fixture of 31 items shared by the ten question cases, the subject (and, for questions 4 and 9, the selection and the instant) and the question number; the answer has the shape the rule gives and is ordered by code point.", + "expected": { + "answer": { + "shared": [ + { + "items": [ + "s2" + ], + "resource": "https://example.org/a" + }, + { + "items": [ + "s3" + ], + "resource": "https://example.org/b" + } + ], + "sources": [ + "https://example.org/a", + "https://example.org/b" + ] + } + }, + "id": "graph-0039", + "input": { + "items": [ + { + "description": "The top cluster of the world fixture.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-top", + "title": "c-top", + "type": "cluster" + }, + { + "broader": [ + "c-top" + ], + "description": "A sub-cluster of the top cluster.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c-sub", + "title": "c-sub", + "type": "cluster" + }, + { + "clusters": [ + "c-sub" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i1", + "title": "i1", + "type": "concept" + }, + { + "clusters": [ + "c-top" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "i2", + "title": "i2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "y" + ], + "slug": "x", + "title": "x", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "requires": [ + "z" + ], + "slug": "y", + "title": "y", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "z", + "title": "z", + "type": "concept" + }, + { + "excludes": [ + "ex2" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex1", + "title": "ex1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ex2", + "title": "ex2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "p", + "supersedes": [ + "q" + ], + "title": "p", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "q", + "supersedes": [ + "r" + ], + "title": "q", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "r", + "title": "r", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ver", + "title": "ver", + "type": "concept", + "verifies": [ + "spec1" + ] + }, + { + "kind": "spec", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "spec1", + "title": "spec1", + "type": "concept" + }, + { + "blocked-by": [ + "t2" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t1", + "title": "t1", + "type": "concept" + }, + { + "blocked-by": [ + "t3" + ], + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t2", + "title": "t2", + "type": "concept" + }, + { + "kind": "task", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "t3", + "title": "t3", + "type": "concept" + }, + { + "derived-from": [ + "e1", + "m" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "l", + "title": "l", + "type": "lesson" + }, + { + "derived-from": [ + "e0" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e1", + "title": "e1", + "type": "episode" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e0", + "title": "e0", + "type": "episode" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "m", + "title": "m", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "st", + "stale_after": "2026-01-01T00:00:00Z", + "title": "st", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dr", + "status": "draft", + "title": "dr", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "dep", + "status": "deprecated", + "title": "dep", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ret", + "status": "retired", + "title": "ret", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ok", + "title": "ok", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s1", + "sources": [ + { + "resource": "https://example.org/a" + }, + { + "resource": "https://example.org/b" + } + ], + "title": "s1", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s2", + "sources": [ + { + "resource": "https://example.org/a" + } + ], + "title": "s2", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "s3", + "sources": [ + { + "resource": "https://example.org/b" + }, + { + "resource": "https://example.org/c" + } + ], + "title": "s3", + "type": "concept" + }, + { + "consumes": [ + "cap-a", + "cap-b" + ], + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "consumer", + "title": "consumer", + "type": "concept" + }, + { + "kind": "principle", + "produces": [ + "cap-a" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "prod", + "title": "prod", + "type": "concept" + } + ], + "question": 10, + "subject": "s1" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-34" +} diff --git a/tests/fixtures/vectors/graph/graph-0040-skos-view-whole-file.json b/tests/fixtures/vectors/graph/graph-0040-skos-view-whole-file.json new file mode 100644 index 0000000..cef7339 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0040-skos-view-whole-file.json @@ -0,0 +1,109 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-36: `export --skos` writes one Turtle file of the published projection with its own two-line prefix block. It copies the SKOS triples of the graph whose ends are in the view, and adds `a skos:ConceptScheme` for the Bundle, `a skos:Concept` for each concept and lesson, `a skos:Collection` for the cluster `grp`, `skos:hasTopConcept` and `skos:topConceptOf` for each concept with no `skos:broader` (`alpha`, `gamma` and the lesson `les`; `beta` has a broader), and the scheme record from `site.title`, `site.tagline`, `site.author` and `bundle.license_prose`. The episode `ep` is not a SKOS concept: it and the `skos:member` triple that names it are left out. The cluster has no `skos:inScheme`, because the graph gives none to a Collection. The stable-Turtle ordering of AGSC-05-10 applies, so the type of a Collection sorts before its other predicates and the dcterms predicates of the scheme sort before its type.", + "expected": { + "skos": "@prefix dcterms: .\n@prefix skos: .\n\n dcterms:creator \"Andrei N. Besleaga\" ;\n dcterms:description \"A node for the SKOS case.\" ;\n dcterms:license \"CC0-1.0\" ;\n dcterms:title \"Example node\" ;\n a skos:ConceptScheme ;\n skos:hasTopConcept , , ;\n skos:prefLabel \"Example node\" .\n\n a skos:Collection ;\n skos:definition \"A cluster of letters for the case.\"@en ;\n skos:member , ;\n skos:prefLabel \"Letters\"@en .\n\n a skos:Concept ;\n skos:altLabel \"A one\"@en ;\n skos:definition \"The first letter of the Greek alphabet.\"@en ;\n skos:inScheme ;\n skos:narrower ;\n skos:prefLabel \"Alpha\"@en ;\n skos:related ;\n skos:topConceptOf .\n\n a skos:Concept ;\n skos:broader ;\n skos:definition \"The second letter of the Greek alphabet.\"@en ;\n skos:inScheme ;\n skos:prefLabel \"Beta\"@en .\n\n a skos:Concept ;\n skos:inScheme ;\n skos:prefLabel \"Gamma\"@en ;\n skos:related ;\n skos:topConceptOf .\n\n a skos:Concept ;\n skos:inScheme ;\n skos:prefLabel \"A lesson\"@en ;\n skos:topConceptOf .\n" + }, + "id": "graph-0040", + "input": { + "bundle": { + "license_prose": "CC0-1.0", + "spec_version": "1.0.0" + }, + "items": [ + { + "aliases": [ + "A one" + ], + "clusters": [ + "grp" + ], + "description": "The first letter of the Greek alphabet.", + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "alpha", + "title": "Alpha", + "type": "concept" + }, + { + "broader": [ + "alpha" + ], + "clusters": [ + "grp" + ], + "description": "The second letter of the Greek alphabet.", + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "beta", + "title": "Beta", + "type": "concept" + }, + { + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "related": [ + "alpha" + ], + "slug": "gamma", + "title": "Gamma", + "type": "concept" + }, + { + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "les", + "title": "A lesson", + "type": "lesson" + }, + { + "description": "A cluster of letters for the case.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "grp", + "title": "Letters", + "type": "cluster" + }, + { + "actor": "human:tester", + "clusters": [ + "grp" + ], + "outcome": "success", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ep", + "started": "2026-01-01T00:00:00Z", + "title": "A run", + "type": "episode" + } + ], + "site": { + "author": "Andrei N. Besleaga", + "base": "https://a.example/", + "tagline": "A node for the SKOS case.", + "title": "Example node" + } + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-36" +} diff --git a/tests/fixtures/vectors/graph/graph-0041-closure-of-the-engine-vocabulary.json b/tests/fixtures/vectors/graph/graph-0041-closure-of-the-engine-vocabulary.json new file mode 100644 index 0000000..1e1ee5b --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0041-closure-of-the-engine-vocabulary.json @@ -0,0 +1,98 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-37: `export --closure` writes the triples that the RL subset (cax-sco, prp-dom, prp-rng, prp-spo1, prp-symp, prp-inv1, prp-inv2, prp-trp, with prp-irp as a check) entails from `graph.nq` and `ontology/agsc.ttl` and that `graph.nq` does not hold, as N-Triples (as amended 2026-11-10: the file is named `.nt`, so its lines carry no graph term). Here they are the superclass types (`asc:Concept` gives `skos:Concept`, the lesson gives both, the cluster `skos:Collection`, the episode `prov:Activity`, the Source `prov:Entity`, the Bundle `skos:ConceptScheme`) and the types the domain of `asc:kind`, `asc:grade` and the other properties gives. The inverses and symmetric partners are already in the graph, so they add nothing. Item `a` excludes itself: `asc:excludes` is irreflexive in the vocabulary, so prp-irp reports the warning AGSC-E313 and adds no triple. The file is sorted by bytes and ends with one LF.", + "expected": { + "closure": " .\n .\n .\n .\n .\n .\n .\n .\n", + "warnings": [ + "AGSC-E313" + ] + }, + "id": "graph-0041", + "input": { + "bundle": { + "license_prose": "CC0-1.0", + "spec_version": "1.0.0" + }, + "items": [ + { + "clusters": [ + "k" + ], + "excludes": [ + "a", + "c" + ], + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "a", + "sources": [ + { + "grade": "primary", + "resource": "https://example.org/p" + } + ], + "title": "a", + "type": "concept", + "uses": [ + "b" + ] + }, + { + "clusters": [ + "k" + ], + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "severity": "info", + "slug": "b", + "title": "b", + "type": "lesson" + }, + { + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "c", + "title": "c", + "type": "concept" + }, + { + "description": "A cluster for the closure case.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "k", + "title": "k", + "type": "cluster" + }, + { + "actor": "human:tester", + "outcome": "success", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "e", + "started": "2026-01-01T00:00:00Z", + "title": "e", + "type": "episode" + } + ], + "site": { + "base": "https://a.example/" + } + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-37" +} diff --git a/tests/fixtures/vectors/graph/graph-0042-closure-with-a-site-vocabulary.json b/tests/fixtures/vectors/graph/graph-0042-closure-with-a-site-vocabulary.json new file mode 100644 index 0000000..55b8a6d --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0042-closure-with-a-site-vocabulary.json @@ -0,0 +1,64 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-37 and AGSC-05-38: the closure also reads the site vocabulary in force. Over the graph of `graph-0044`, `dom:Engine` is a subclass of `asc:Concept`, so `engine-a`, which already has the item class `asc:Concept`, gains `skos:Concept` through it; `dom:controlled-by` and `dom:controls` are sub-properties of `asc:uses`, so each controller link gives an `asc:uses` edge, and the inverse of `asc:uses`, `asc:usedBy`, gives the edge back. The vocabulary's own triples add nothing new (prp-inv1 and prp-inv2 find the inverse pair already stated). The file is sorted by bytes and ends with one LF.", + "expected": { + "closure": " .\n .\n .\n .\n .\n .\n .\n .\n", + "warnings": [] + }, + "id": "graph-0042", + "input": { + "bundle": { + "license_prose": "CC0-1.0", + "spec_version": "1.0.0" + }, + "items": [ + { + "domain_context": "ctx", + "domain_links": { + "controlled-by": [ + "ctl" + ] + }, + "domain_role": "aggregate-root", + "domain_type": "Engine", + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "engine-a", + "title": "Engine A", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ctl", + "title": "Controller", + "type": "concept" + }, + { + "description": "The context that holds the engines.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ctx", + "title": "Propulsion", + "type": "cluster" + } + ], + "site": { + "base": "https://minimal.example/" + }, + "vocabulary": "@prefix asc: .\n@prefix dom: .\n@prefix owl: .\n@prefix rdfs: .\n@prefix skos: .\n\nasc:Concept\n a owl:Class .\n\nasc:Episode\n a owl:Class .\n\nasc:Cluster\n a owl:Class .\n\nasc:uses\n a owl:ObjectProperty .\n\nskos:definition\n a owl:AnnotationProperty .\n\n\n a owl:Ontology ;\n rdfs:label \"Minimal domain vocabulary\" .\n\ndom:Engine\n a owl:Class ;\n rdfs:label \"Engine\" ;\n rdfs:subClassOf asc:Concept ;\n skos:definition \"A machine that turns fuel into thrust.\"@en .\n\ndom:controlled-by\n a owl:ObjectProperty ;\n rdfs:label \"controlled by\" ;\n rdfs:subPropertyOf asc:uses ;\n owl:inverseOf dom:controls ;\n skos:definition \"This engine is run by the target controller.\"@en .\n\ndom:controls\n a owl:ObjectProperty ;\n rdfs:label \"controls\" ;\n rdfs:subPropertyOf asc:uses ;\n owl:inverseOf dom:controlled-by ;\n skos:definition \"This controller runs the target engine.\"@en .\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-37" +} diff --git a/tests/fixtures/vectors/graph/graph-0043-context-address-does-not-follow-the-ontology-version.json b/tests/fixtures/vectors/graph/graph-0043-context-address-does-not-follow-the-ontology-version.json new file mode 100644 index 0000000..01353cf --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0043-context-address-does-not-follow-the-ontology-version.json @@ -0,0 +1,35 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-09: the `@context` of `graph.jsonld` names the context version, a constant `1.0.0` at every version 1.x, and not the ontology version of AGSC-05-25. The case builds the same one-item Bundle twice, once with the vocabulary file reporting the ontology version `1.0.0` and once `1.1.0`: both documents name `https://w3id.org/agentic-system-core/ns/1.0.0/context.jsonld` and are byte-identical, so raising the ontology version changes no byte of any `graph.jsonld`.", + "expected": { + "context_url": "https://w3id.org/agentic-system-core/ns/1.0.0/context.jsonld", + "graph_jsonld_identical_across_ontology_versions": true + }, + "id": "graph-0043", + "input": { + "items": [ + { + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "alpha", + "title": "Alpha", + "type": "concept" + } + ], + "ontology_versions": [ + "1.0.0", + "1.1.0" + ], + "site": { + "base": "https://a.example/" + } + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-09" +} diff --git a/tests/fixtures/vectors/graph/graph-0044-site-vocabulary-and-domain-triples.json b/tests/fixtures/vectors/graph/graph-0044-site-vocabulary-and-domain-triples.json new file mode 100644 index 0000000..b8805b6 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0044-site-vocabulary-and-domain-triples.json @@ -0,0 +1,69 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-38 and AGSC-05-39: a node that declares a site vocabulary publishes every triple of the vocabulary file in the named graph of the Bundle, and an item that states a domain type, a role, a context and a domain link adds exactly the triples the rule names: a second `rdf:type` (the site class, the item keeps `asc:Concept`), `schema:additionalType` (the role), `dcterms:isPartOf` to the cluster that declares the context, the domain link as ` `, and the computed inverse the vocabulary declares. The input gives the vocabulary text, three items and the site base; the expected value is the whole `graph.nq`. `jsonld_type` states the `@type` of `engine-a` in `graph.jsonld`: an array of the two classes in code-point order of their IRIs, the site class first. A node that declares no vocabulary emits none of these lines (the cases `graph-0026` and `graph-0028` stay as they are).", + "expected": { + "jsonld_type": { + "https://minimal.example/concepts/engine-a/": [ + "https://minimal.example/ns/domain#Engine", + "Concept" + ] + }, + "nquads": " .\n .\n \"CC0-1.0\"^^ .\n \"CC0-1.0\"^^ .\n \"1.0.0\"^^ .\n .\n \"The context that holds the engines.\"@en .\n \"Propulsion\"@en .\n \"CC0-1.0\"^^ .\n \"CC0-1.0\"^^ .\n \"human:tester\"^^ .\n \"human\"^^ .\n .\n .\n \"Controller\"@en .\n .\n \"CC0-1.0\"^^ .\n \"CC0-1.0\"^^ .\n \"principle\"^^ .\n \"human:tester\"^^ .\n \"human\"^^ .\n .\n .\n .\n .\n \"Engine A\"@en .\n .\n \"aggregate-root\"^^ .\n \"CC0-1.0\"^^ .\n \"CC0-1.0\"^^ .\n \"principle\"^^ .\n \"human:tester\"^^ .\n \"human\"^^ .\n .\n \"Engine\"^^ .\n .\n \"A machine that turns fuel into thrust.\"@en .\n .\n \"controlled by\"^^ .\n .\n .\n \"This engine is run by the target controller.\"@en .\n .\n \"controls\"^^ .\n .\n .\n \"This controller runs the target engine.\"@en .\n .\n \"Minimal domain vocabulary\"^^ .\n .\n .\n .\n .\n" + }, + "id": "graph-0044", + "input": { + "bundle": { + "license_prose": "CC0-1.0", + "spec_version": "1.0.0" + }, + "items": [ + { + "domain_context": "ctx", + "domain_links": { + "controlled-by": [ + "ctl" + ] + }, + "domain_role": "aggregate-root", + "domain_type": "Engine", + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "engine-a", + "title": "Engine A", + "type": "concept" + }, + { + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ctl", + "title": "Controller", + "type": "concept" + }, + { + "description": "The context that holds the engines.", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ctx", + "title": "Propulsion", + "type": "cluster" + } + ], + "site": { + "base": "https://minimal.example/" + }, + "vocabulary": "@prefix asc: .\n@prefix dom: .\n@prefix owl: .\n@prefix rdfs: .\n@prefix skos: .\n\nasc:Concept\n a owl:Class .\n\nasc:Episode\n a owl:Class .\n\nasc:Cluster\n a owl:Class .\n\nasc:uses\n a owl:ObjectProperty .\n\nskos:definition\n a owl:AnnotationProperty .\n\n\n a owl:Ontology ;\n rdfs:label \"Minimal domain vocabulary\" .\n\ndom:Engine\n a owl:Class ;\n rdfs:label \"Engine\" ;\n rdfs:subClassOf asc:Concept ;\n skos:definition \"A machine that turns fuel into thrust.\"@en .\n\ndom:controlled-by\n a owl:ObjectProperty ;\n rdfs:label \"controlled by\" ;\n rdfs:subPropertyOf asc:uses ;\n owl:inverseOf dom:controls ;\n skos:definition \"This engine is run by the target controller.\"@en .\n\ndom:controls\n a owl:ObjectProperty ;\n rdfs:label \"controls\" ;\n rdfs:subPropertyOf asc:uses ;\n owl:inverseOf dom:controlled-by ;\n skos:definition \"This controller runs the target engine.\"@en .\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-39" +} diff --git a/tests/fixtures/vectors/graph/graph-0045-warrant-on-the-source.json b/tests/fixtures/vectors/graph/graph-0045-warrant-on-the-source.json new file mode 100644 index 0000000..234874d --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0045-warrant-on-the-source.json @@ -0,0 +1,43 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-40: a valid `warrant` adds two triples on the item, `dcterms:source` with the source string and `asc:warrant` with the type, both `xsd:string`. The term `ledger` carries a literary warrant grounded in a glossary address, and also cites that address as an entry of `sources[]`, so the file holds both the Source node of AGSC-05-14 and the two warrant triples on the item; they are independent. The expected value is the whole `graph.nq`.", + "expected": { + "nquads": " .\n \"CC0-1.0\"^^ .\n \"CC0-1.0\"^^ .\n \"1.0.0\"^^ .\n \"https://example.org/glossary\"^^ .\n .\n \"https://example.org/glossary\"^^ .\n .\n .\n \"Ledger\"@en .\n \"CC0-1.0\"^^ .\n \"CC0-1.0\"^^ .\n \"term\"^^ .\n \"human:tester\"^^ .\n \"human\"^^ .\n .\n \"literary\"^^ .\n" + }, + "id": "graph-0045", + "input": { + "bundle": { + "license_prose": "CC0-1.0", + "spec_version": "1.0.0" + }, + "items": [ + { + "kind": "term", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ledger", + "sources": [ + { + "resource": "https://example.org/glossary" + } + ], + "title": "Ledger", + "type": "concept", + "warrant": { + "source": "https://example.org/glossary", + "type": "literary" + } + } + ], + "site": { + "base": "https://minimal.example/" + } + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-40" +} diff --git a/tests/fixtures/vectors/graph/graph-0046-invariants-and-questions-over-the-closure.json b/tests/fixtures/vectors/graph/graph-0046-invariants-and-questions-over-the-closure.json new file mode 100644 index 0000000..af9a7c5 --- /dev/null +++ b/tests/fixtures/vectors/graph/graph-0046-invariants-and-questions-over-the-closure.json @@ -0,0 +1,96 @@ +{ + "area": "graph", + "description": "Derived from AGSC-05-41: the shapes and the competency questions are evaluated over one data graph, the published `graph.nq` together with the closure of AGSC-05-37. The shape asks every `dom:Engine` for a `dom:controlled-by`. `engine-b` has one because the computed inverse of the `dom:controls` link of `ctl` is a triple of `graph.nq` (AGSC-03-27); `engine-a` has none, so the result is one violation with the message and the shape that the file gives. Of the two questions, `has-an-engine` is answered `true` and agrees; `engines` lists only `engine-a` while the data has two engines, so it differs. The case works on the evaluation itself, below the `verify` verb that `lint-0057` and `lint-0059` run.", + "expected": { + "invariants": [ + { + "focus": "https://minimal.example/concepts/engine-a/", + "message": "Every engine needs a controller.", + "severity": "Violation", + "shape": "https://minimal.example/ns/domain-shapes#EngineControlled" + } + ], + "questions": [ + { + "id": "engines", + "result": "differs" + }, + { + "id": "has-an-engine", + "result": "agrees" + } + ] + }, + "id": "graph-0046", + "input": { + "items": [ + { + "domain_type": "Engine", + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "engine-a", + "title": "Engine a", + "type": "concept" + }, + { + "domain_type": "Engine", + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "engine-b", + "title": "Engine b", + "type": "concept" + }, + { + "domain_links": { + "controls": [ + "engine-b" + ] + }, + "kind": "principle", + "prov": { + "operator": "human:tester", + "origin": "human" + }, + "slug": "ctl", + "title": "Ctl", + "type": "concept" + } + ], + "questions": [ + { + "expected": true, + "id": "has-an-engine", + "query": "PREFIX dom: ASK { ?x a dom:Engine }", + "question": "Does the site describe at least one engine?" + }, + { + "expected": { + "rows": [ + [ + "" + ] + ] + }, + "id": "engines", + "query": "PREFIX dom: SELECT ?x WHERE { ?x a dom:Engine } ORDER BY ?x", + "question": "Which items are engines?" + } + ], + "shapes": "@prefix dom: .\n@prefix sh: .\n@prefix shp: .\n\nshp:EngineShape\n a sh:NodeShape ;\n sh:property shp:EngineControlled ;\n sh:targetClass dom:Engine .\n\nshp:EngineControlled\n a sh:PropertyShape ;\n sh:message \"Every engine needs a controller.\"@en ;\n sh:minCount 1 ;\n sh:path dom:controlled-by ;\n sh:severity sh:Violation .\n", + "site": { + "base": "https://minimal.example/" + }, + "vocabulary": "@prefix asc: .\n@prefix dom: .\n@prefix owl: .\n@prefix rdfs: .\n@prefix skos: .\n\nasc:Concept\n a owl:Class .\n\nasc:Episode\n a owl:Class .\n\nasc:Cluster\n a owl:Class .\n\nasc:uses\n a owl:ObjectProperty .\n\nskos:definition\n a owl:AnnotationProperty .\n\n\n a owl:Ontology ;\n rdfs:label \"Minimal domain vocabulary\" .\n\ndom:Engine\n a owl:Class ;\n rdfs:label \"Engine\" ;\n rdfs:subClassOf asc:Concept ;\n skos:definition \"A machine that turns fuel into thrust.\"@en .\n\ndom:controlled-by\n a owl:ObjectProperty ;\n rdfs:label \"controlled by\" ;\n rdfs:subPropertyOf asc:uses ;\n skos:definition \"This engine is run by the target controller.\"@en .\n\ndom:controls\n a owl:ObjectProperty ;\n rdfs:label \"controls\" ;\n rdfs:subPropertyOf asc:uses ;\n owl:inverseOf dom:controlled-by ;\n skos:definition \"This controller runs the target engine.\"@en .\n" + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-05-41" +} diff --git a/tests/fixtures/vectors/jcs/jcs-0001-canonical-output.json b/tests/fixtures/vectors/jcs/jcs-0001-canonical-output.json index 1bd2eaa..d753e73 100644 --- a/tests/fixtures/vectors/jcs/jcs-0001-canonical-output.json +++ b/tests/fixtures/vectors/jcs/jcs-0001-canonical-output.json @@ -21,7 +21,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-05" } diff --git a/tests/fixtures/vectors/jcs/jcs-0002-utf16-key-sort.json b/tests/fixtures/vectors/jcs/jcs-0002-utf16-key-sort.json index d9828da..31ca01f 100644 --- a/tests/fixtures/vectors/jcs/jcs-0002-utf16-key-sort.json +++ b/tests/fixtures/vectors/jcs/jcs-0002-utf16-key-sort.json @@ -13,7 +13,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-05" } diff --git a/tests/fixtures/vectors/jcs/jcs-0003-astral-member-order.json b/tests/fixtures/vectors/jcs/jcs-0003-astral-member-order.json index 2834406..03b6766 100644 --- a/tests/fixtures/vectors/jcs/jcs-0003-astral-member-order.json +++ b/tests/fixtures/vectors/jcs/jcs-0003-astral-member-order.json @@ -21,7 +21,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-05" } diff --git a/tests/fixtures/vectors/jcs/jcs-0004-negative-zero.json b/tests/fixtures/vectors/jcs/jcs-0004-negative-zero.json index 86f286f..025c64f 100644 --- a/tests/fixtures/vectors/jcs/jcs-0004-negative-zero.json +++ b/tests/fixtures/vectors/jcs/jcs-0004-negative-zero.json @@ -14,7 +14,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-05" } diff --git a/tests/fixtures/vectors/jcs/jcs-0005-nfc-before-sort.json b/tests/fixtures/vectors/jcs/jcs-0005-nfc-before-sort.json index 765b23e..022cc5e 100644 --- a/tests/fixtures/vectors/jcs/jcs-0005-nfc-before-sort.json +++ b/tests/fixtures/vectors/jcs/jcs-0005-nfc-before-sort.json @@ -14,7 +14,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-04-21" } diff --git a/tests/fixtures/vectors/links/links-0001-inverse-computation.json b/tests/fixtures/vectors/links/links-0001-inverse-computation.json index b2b66d2..b89e557 100644 --- a/tests/fixtures/vectors/links/links-0001-inverse-computation.json +++ b/tests/fixtures/vectors/links/links-0001-inverse-computation.json @@ -55,7 +55,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-04" } diff --git a/tests/fixtures/vectors/links/links-0002-requires-cycle-rejected.json b/tests/fixtures/vectors/links/links-0002-requires-cycle-rejected.json index 278962d..24e5ad3 100644 --- a/tests/fixtures/vectors/links/links-0002-requires-cycle-rejected.json +++ b/tests/fixtures/vectors/links/links-0002-requires-cycle-rejected.json @@ -37,7 +37,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-07" } diff --git a/tests/fixtures/vectors/links/links-0003-authored-inverse-rejected.json b/tests/fixtures/vectors/links/links-0003-authored-inverse-rejected.json index f543b08..d457f98 100644 --- a/tests/fixtures/vectors/links/links-0003-authored-inverse-rejected.json +++ b/tests/fixtures/vectors/links/links-0003-authored-inverse-rejected.json @@ -22,7 +22,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-04" } diff --git a/tests/fixtures/vectors/links/links-0004-anchor-edge-cases.json b/tests/fixtures/vectors/links/links-0004-anchor-edge-cases.json index 1dba83a..d83fd72 100644 --- a/tests/fixtures/vectors/links/links-0004-anchor-edge-cases.json +++ b/tests/fixtures/vectors/links/links-0004-anchor-edge-cases.json @@ -18,7 +18,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-13" } diff --git a/tests/fixtures/vectors/links/links-0005-cluster-depth-rejected.json b/tests/fixtures/vectors/links/links-0005-cluster-depth-rejected.json index e9b85a0..3275198 100644 --- a/tests/fixtures/vectors/links/links-0005-cluster-depth-rejected.json +++ b/tests/fixtures/vectors/links/links-0005-cluster-depth-rejected.json @@ -46,7 +46,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-08" } diff --git a/tests/fixtures/vectors/links/links-0006-cluster-multi-parent-rejected.json b/tests/fixtures/vectors/links/links-0006-cluster-multi-parent-rejected.json index d259a0a..86e221b 100644 --- a/tests/fixtures/vectors/links/links-0006-cluster-multi-parent-rejected.json +++ b/tests/fixtures/vectors/links/links-0006-cluster-multi-parent-rejected.json @@ -34,7 +34,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-08" } diff --git a/tests/fixtures/vectors/links/links-0007-body-link-unresolved.json b/tests/fixtures/vectors/links/links-0007-body-link-unresolved.json index 6991472..47f80a7 100644 --- a/tests/fixtures/vectors/links/links-0007-body-link-unresolved.json +++ b/tests/fixtures/vectors/links/links-0007-body-link-unresolved.json @@ -33,7 +33,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-11" } diff --git a/tests/fixtures/vectors/links/links-0008-broader-narrower-cycle-rejected.json b/tests/fixtures/vectors/links/links-0008-broader-narrower-cycle-rejected.json index 6b6025f..36760c2 100644 --- a/tests/fixtures/vectors/links/links-0008-broader-narrower-cycle-rejected.json +++ b/tests/fixtures/vectors/links/links-0008-broader-narrower-cycle-rejected.json @@ -38,7 +38,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-08" } diff --git a/tests/fixtures/vectors/links/links-0009-orphans-and-the-cluster-exception.json b/tests/fixtures/vectors/links/links-0009-orphans-and-the-cluster-exception.json index 9923e64..135fd93 100644 --- a/tests/fixtures/vectors/links/links-0009-orphans-and-the-cluster-exception.json +++ b/tests/fixtures/vectors/links/links-0009-orphans-and-the-cluster-exception.json @@ -81,7 +81,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-03-10" } diff --git a/tests/fixtures/vectors/links/links-0010-self-link-warns.json b/tests/fixtures/vectors/links/links-0010-self-link-warns.json new file mode 100644 index 0000000..0c60ff9 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0010-self-link-warns.json @@ -0,0 +1,43 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-23: an item whose value for a key other than `requires`, `broader` and `narrower` names the item itself is reported once per key as the warning AGSC-E313, carried by that item. Item `a` names itself under `related` and under `uses` (with an anchor that exists, `a#top`), which are two findings on `a`, one per key; `b` is linked from `a` so neither item is an orphan. Nothing is an error: the edges are still built.", + "expected": { + "errors": [], + "warnings": [ + { + "code": "AGSC-E313", + "slug": "a" + }, + { + "code": "AGSC-E313", + "slug": "a" + } + ] + }, + "id": "links-0010", + "input": { + "items": [ + { + "body": "# Top\n", + "related": [ + "a", + "b" + ], + "slug": "a", + "type": "concept", + "uses": [ + "a#top" + ] + }, + { + "slug": "b", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-23" +} diff --git a/tests/fixtures/vectors/links/links-0011-self-requires-and-self-broader-are-cycles.json b/tests/fixtures/vectors/links/links-0011-self-requires-and-self-broader-are-cycles.json new file mode 100644 index 0000000..abd36c3 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0011-self-requires-and-self-broader-are-cycles.json @@ -0,0 +1,46 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-23, near miss: a self-`requires` is the cycle error AGSC-E302 (AGSC-03-07) and a self-`broader` on a cluster is the cycle error AGSC-E303 (AGSC-03-08), and neither also raises AGSC-E313. Item `r` requires itself, cluster `k` names itself as its broader; `f` relates to `r` and lists `k` so that neither is an orphan. The two cycle errors are the only findings, so the list of warnings is empty.", + "expected": { + "errors": [ + "AGSC-E302", + "AGSC-E303" + ], + "warnings": [] + }, + "id": "links-0011", + "input": { + "items": [ + { + "requires": [ + "r" + ], + "slug": "r", + "type": "concept" + }, + { + "broader": [ + "k" + ], + "description": "A cluster that names itself.", + "slug": "k", + "type": "cluster" + }, + { + "clusters": [ + "k" + ], + "related": [ + "r" + ], + "slug": "f", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-23" +} diff --git a/tests/fixtures/vectors/links/links-0012-incompatible-pairs-warn.json b/tests/fixtures/vectors/links/links-0012-incompatible-pairs-warn.json new file mode 100644 index 0000000..887e833 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0012-incompatible-pairs-warn.json @@ -0,0 +1,140 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-24: a pair `(A, B)` that carries `requires` with `excludes`, `requires` with `supersedes`, `requires` with `contradicts`, or `uses` with `excludes` is reported once per combination as the warning AGSC-E314, carried by `A`, the item that authors the `requires`, `supersedes` or `uses`. The first four items each author both keys toward their `b` item. In the fifth and sixth pairs only the `b` item authors the `excludes`, which AGSC-03-05 materialises both ways, so `a5` holds `requires` and `excludes` toward `b5` (and `a6` holds `uses` and `excludes` toward `b6`) and each finding is still carried by the `a` item. `b2` is deprecated so that the `supersedes` raises no other warning. The hub item gives `a1` to `a5` an inbound link.", + "expected": { + "errors": [], + "warnings": [ + { + "code": "AGSC-E314", + "slug": "a1" + }, + { + "code": "AGSC-E314", + "slug": "a2" + }, + { + "code": "AGSC-E314", + "slug": "a3" + }, + { + "code": "AGSC-E314", + "slug": "a4" + }, + { + "code": "AGSC-E314", + "slug": "a5" + }, + { + "code": "AGSC-E314", + "slug": "a6" + } + ] + }, + "id": "links-0012", + "input": { + "items": [ + { + "excludes": [ + "b1" + ], + "requires": [ + "b1" + ], + "slug": "a1", + "type": "concept" + }, + { + "slug": "b1", + "type": "concept" + }, + { + "requires": [ + "b2" + ], + "slug": "a2", + "supersedes": [ + "b2" + ], + "type": "concept" + }, + { + "slug": "b2", + "status": "deprecated", + "type": "concept" + }, + { + "contradicts": [ + "b3" + ], + "requires": [ + "b3" + ], + "slug": "a3", + "type": "concept" + }, + { + "slug": "b3", + "type": "concept" + }, + { + "excludes": [ + "b4" + ], + "slug": "a4", + "type": "concept", + "uses": [ + "b4" + ] + }, + { + "slug": "b4", + "type": "concept" + }, + { + "requires": [ + "b5" + ], + "slug": "a5", + "type": "concept" + }, + { + "excludes": [ + "a5" + ], + "slug": "b5", + "type": "concept" + }, + { + "slug": "a6", + "type": "concept", + "uses": [ + "b6" + ] + }, + { + "excludes": [ + "a6" + ], + "slug": "b6", + "type": "concept" + }, + { + "related": [ + "a1", + "a2", + "a3", + "a4", + "a5", + "a6" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-24" +} diff --git a/tests/fixtures/vectors/links/links-0013-incompatible-pairs-near-misses.json b/tests/fixtures/vectors/links/links-0013-incompatible-pairs-near-misses.json new file mode 100644 index 0000000..0f21883 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0013-incompatible-pairs-near-misses.json @@ -0,0 +1,89 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-24, near misses: `requires` with `uses` is not a combination; two keys held toward two different items (`n2` requires `m2` and excludes `m3`) are not a combination; `uses` with `contradicts` is not a combination; `s1` requires `s2` while `s2` supersedes `s1`, which are two different ordered pairs, each holding one key; none of them is reported. The hub item gives the sources an inbound link; `s1` is deprecated so that the `supersedes` raises no other warning.", + "expected": { + "errors": [], + "warnings": [] + }, + "id": "links-0013", + "input": { + "items": [ + { + "requires": [ + "m1" + ], + "slug": "n1", + "type": "concept", + "uses": [ + "m1" + ] + }, + { + "slug": "m1", + "type": "concept" + }, + { + "excludes": [ + "m3" + ], + "requires": [ + "m2" + ], + "slug": "n2", + "type": "concept" + }, + { + "slug": "m2", + "type": "concept" + }, + { + "slug": "m3", + "type": "concept" + }, + { + "contradicts": [ + "m4" + ], + "slug": "n3", + "type": "concept", + "uses": [ + "m4" + ] + }, + { + "slug": "m4", + "type": "concept" + }, + { + "requires": [ + "s2" + ], + "slug": "s1", + "status": "deprecated", + "type": "concept" + }, + { + "slug": "s2", + "supersedes": [ + "s1" + ], + "type": "concept" + }, + { + "related": [ + "n1", + "n2", + "n3", + "s1" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-24" +} diff --git a/tests/fixtures/vectors/links/links-0014-unexpected-target-kind-warns.json b/tests/fixtures/vectors/links/links-0014-unexpected-target-kind-warns.json new file mode 100644 index 0000000..eec945d --- /dev/null +++ b/tests/fixtures/vectors/links/links-0014-unexpected-target-kind-warns.json @@ -0,0 +1,141 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-25: a resolved target that does not match the Expected target kinds cell of its key is the warning AGSC-E315, carried by the item that authors the key. Seven items each break one cell: `decided-by` toward a task, `blocked-by` toward a decision, a lesson `derived-from` a spec (an episode is expected), `verifies` toward an episode, `implements` toward a task, a concept that `supersedes` a lesson (the same `type` is expected), and `broader` toward an episode (the same family is expected). The lesson `q1` is deprecated so that the `supersedes` raises no other warning, and the hub item gives the sources an inbound link. The seven findings are in slug order.", + "expected": { + "errors": [], + "warnings": [ + { + "code": "AGSC-E315", + "slug": "b1" + }, + { + "code": "AGSC-E315", + "slug": "d1" + }, + { + "code": "AGSC-E315", + "slug": "i1" + }, + { + "code": "AGSC-E315", + "slug": "k1" + }, + { + "code": "AGSC-E315", + "slug": "l1" + }, + { + "code": "AGSC-E315", + "slug": "p1" + }, + { + "code": "AGSC-E315", + "slug": "v1" + } + ] + }, + "id": "links-0014", + "input": { + "items": [ + { + "decided-by": [ + "t1" + ], + "kind": "principle", + "slug": "d1", + "type": "concept" + }, + { + "blocked-by": [ + "dec1" + ], + "kind": "task", + "slug": "k1", + "type": "concept" + }, + { + "derived-from": [ + "sp1" + ], + "severity": "info", + "slug": "l1", + "type": "lesson" + }, + { + "kind": "task", + "slug": "v1", + "type": "concept", + "verifies": [ + "ep1" + ] + }, + { + "implements": [ + "t1" + ], + "kind": "task", + "slug": "i1", + "type": "concept" + }, + { + "kind": "principle", + "slug": "p1", + "supersedes": [ + "q1" + ], + "type": "concept" + }, + { + "broader": [ + "ep1" + ], + "kind": "principle", + "slug": "b1", + "type": "concept" + }, + { + "kind": "task", + "slug": "t1", + "type": "concept" + }, + { + "kind": "decision", + "slug": "dec1", + "type": "concept" + }, + { + "kind": "spec", + "slug": "sp1", + "type": "concept" + }, + { + "slug": "ep1", + "type": "episode" + }, + { + "severity": "info", + "slug": "q1", + "status": "deprecated", + "type": "lesson" + }, + { + "related": [ + "b1", + "d1", + "i1", + "k1", + "l1", + "p1", + "v1" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-25" +} diff --git a/tests/fixtures/vectors/links/links-0015-expected-target-kinds-near-misses.json b/tests/fixtures/vectors/links/links-0015-expected-target-kinds-near-misses.json new file mode 100644 index 0000000..3d5f217 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0015-expected-target-kinds-near-misses.json @@ -0,0 +1,160 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-25, near misses: every key here points at a kind its cell admits, so nothing is reported. `decided-by` toward a decision; `blocked-by` toward a task; a lesson `derived-from` an episode, and a concept `derived-from` a spec (the cell binds only a lesson); `verifies` toward a spec, a task, a procedure and a gate; `implements` toward a pattern and a spec; `broader` toward a concept and toward a lesson (one family); `supersedes` between two concepts; and `related`, `uses` and `covers`, whose cell is `any`, toward an episode and a procedure. The hub item gives the sources an inbound link; the superseded spec is deprecated.", + "expected": { + "errors": [], + "warnings": [] + }, + "id": "links-0015", + "input": { + "items": [ + { + "decided-by": [ + "dec1" + ], + "kind": "principle", + "slug": "d2", + "type": "concept" + }, + { + "blocked-by": [ + "t1" + ], + "kind": "task", + "slug": "k2", + "type": "concept" + }, + { + "derived-from": [ + "ep1" + ], + "severity": "info", + "slug": "l2", + "type": "lesson" + }, + { + "derived-from": [ + "sp1" + ], + "kind": "principle", + "slug": "c2", + "type": "concept" + }, + { + "kind": "task", + "slug": "v2", + "type": "concept", + "verifies": [ + "sp1", + "t1", + "proc1", + "g1" + ] + }, + { + "implements": [ + "pat1", + "sp1" + ], + "kind": "task", + "slug": "i2", + "type": "concept" + }, + { + "broader": [ + "sp1", + "les1" + ], + "kind": "principle", + "slug": "b2", + "type": "concept" + }, + { + "kind": "spec", + "slug": "p2", + "supersedes": [ + "sp2" + ], + "type": "concept" + }, + { + "covers": [ + "proc1" + ], + "kind": "principle", + "related": [ + "ep1" + ], + "slug": "r1", + "type": "concept", + "uses": [ + "ep1" + ] + }, + { + "kind": "decision", + "slug": "dec1", + "type": "concept" + }, + { + "kind": "task", + "slug": "t1", + "type": "concept" + }, + { + "kind": "spec", + "slug": "sp1", + "type": "concept" + }, + { + "kind": "pattern", + "slug": "pat1", + "type": "concept" + }, + { + "slug": "ep1", + "type": "episode" + }, + { + "slug": "proc1", + "type": "procedure" + }, + { + "level": "L1", + "slug": "g1", + "type": "gate" + }, + { + "severity": "info", + "slug": "les1", + "type": "lesson" + }, + { + "kind": "spec", + "slug": "sp2", + "status": "deprecated", + "type": "concept" + }, + { + "related": [ + "b2", + "c2", + "d2", + "i2", + "k2", + "l2", + "p2", + "r1", + "v2" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-25" +} diff --git a/tests/fixtures/vectors/links/links-0016-supersedes-a-stable-item-warns.json b/tests/fixtures/vectors/links/links-0016-supersedes-a-stable-item-warns.json new file mode 100644 index 0000000..fc7a1f8 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0016-supersedes-a-stable-item-warns.json @@ -0,0 +1,58 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-26: a `supersedes` target whose status is `stable`, authored or by default (AGSC-02-23), is the warning AGSC-E316, carried by the item that authors the `supersedes`. `n1` supersedes `o1`, which authors no status and so is stable by default; `n2` supersedes `o2`, which authors `status: stable`. Two findings. The warning changes neither item: the hiding step of composition is unchanged. The hub item gives `n1` and `n2` an inbound link.", + "expected": { + "errors": [], + "warnings": [ + { + "code": "AGSC-E316", + "slug": "n1" + }, + { + "code": "AGSC-E316", + "slug": "n2" + } + ] + }, + "id": "links-0016", + "input": { + "items": [ + { + "slug": "n1", + "supersedes": [ + "o1" + ], + "type": "concept" + }, + { + "slug": "o1", + "type": "concept" + }, + { + "slug": "n2", + "supersedes": [ + "o2" + ], + "type": "concept" + }, + { + "slug": "o2", + "status": "stable", + "type": "concept" + }, + { + "related": [ + "n1", + "n2" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-26" +} diff --git a/tests/fixtures/vectors/links/links-0017-supersedes-a-deprecated-retired-or-draft-item.json b/tests/fixtures/vectors/links/links-0017-supersedes-a-deprecated-retired-or-draft-item.json new file mode 100644 index 0000000..a408d57 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0017-supersedes-a-deprecated-retired-or-draft-item.json @@ -0,0 +1,63 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-26, near misses: a `supersedes` whose target is `deprecated`, `retired` or `draft` raises nothing. The first two already say they are replaced (AGSC-11-22 admits a retired target without a warning), and a draft is on no published surface (AGSC-06-30). The hub item gives the superseding items an inbound link.", + "expected": { + "errors": [], + "warnings": [] + }, + "id": "links-0017", + "input": { + "items": [ + { + "slug": "n3", + "supersedes": [ + "o3" + ], + "type": "concept" + }, + { + "slug": "o3", + "status": "deprecated", + "type": "concept" + }, + { + "slug": "n4", + "supersedes": [ + "o4" + ], + "type": "concept" + }, + { + "slug": "o4", + "status": "retired", + "type": "concept" + }, + { + "slug": "n5", + "supersedes": [ + "o5" + ], + "type": "concept" + }, + { + "slug": "o5", + "status": "draft", + "type": "concept" + }, + { + "related": [ + "n3", + "n4", + "n5" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-26" +} diff --git a/tests/fixtures/vectors/links/links-0018-domain-link-errors.json b/tests/fixtures/vectors/links/links-0018-domain-link-errors.json new file mode 100644 index 0000000..e9d6295 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0018-domain-link-errors.json @@ -0,0 +1,79 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-27: a node with a site vocabulary may state domain links under `domain_links`, and three faults are the error AGSC-E317. `x1` names a member, `owns`, that the vocabulary does not declare; `x2` authors `controlled-by`, the computed inverse of the declared property `controls`; the cluster `x3` uses `relates-to-term`, whose super-property is `skos:related`, which would make a `skos:Collection` a `skos:Concept` (AGSC-05-20). The vocabulary is given as `domain_properties`, each with its local name, the link property it specialises and, where the vocabulary declares them, an inverse or symmetry. The hub item and the cluster membership keep every item from being an orphan.", + "expected": { + "error": "AGSC-E317", + "errors": [ + "AGSC-E317", + "AGSC-E317", + "AGSC-E317" + ], + "warnings": [] + }, + "id": "links-0018", + "input": { + "domain_properties": [ + { + "inverse": "controlled-by", + "name": "controls", + "super": "uses" + }, + { + "name": "relates-to-term", + "super": "related", + "symmetric": true + } + ], + "items": [ + { + "domain_links": { + "owns": [ + "y1" + ] + }, + "slug": "x1", + "type": "concept" + }, + { + "domain_links": { + "controlled-by": [ + "y1" + ] + }, + "slug": "x2", + "type": "concept" + }, + { + "description": "A cluster that uses a related-type domain link.", + "domain_links": { + "relates-to-term": [ + "y1" + ] + }, + "slug": "x3", + "type": "cluster" + }, + { + "slug": "y1", + "type": "concept" + }, + { + "clusters": [ + "x3" + ], + "related": [ + "x1", + "x2", + "y1" + ], + "slug": "hub", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-27" +} diff --git a/tests/fixtures/vectors/links/links-0019-domain-links-are-edges-with-inverses.json b/tests/fixtures/vectors/links/links-0019-domain-links-are-edges-with-inverses.json new file mode 100644 index 0000000..09f0f3d --- /dev/null +++ b/tests/fixtures/vectors/links/links-0019-domain-links-are-edges-with-inverses.json @@ -0,0 +1,72 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-27: a declared domain property is an edge with its own key. `p` states `controls` toward `q` and `relates-to-term` toward `q`; the vocabulary declares `controlled-by` as the inverse of `controls` and `relates-to-term` as symmetric, so the inverse and the symmetric partner are computed, as AGSC-03-04 and AGSC-03-05 do for the fourteen keys, and both items have an inbound edge, so neither is an orphan. The edges are sorted by source, key and target.", + "expected": { + "edges": [ + { + "computed": false, + "key": "controls", + "source": "p", + "target": "q" + }, + { + "computed": false, + "key": "relates-to-term", + "source": "p", + "target": "q" + }, + { + "computed": true, + "key": "controlled-by", + "source": "q", + "target": "p" + }, + { + "computed": true, + "key": "relates-to-term", + "source": "q", + "target": "p" + } + ], + "errors": [], + "warnings": [] + }, + "id": "links-0019", + "input": { + "domain_properties": [ + { + "inverse": "controlled-by", + "name": "controls", + "super": "uses" + }, + { + "name": "relates-to-term", + "super": "related", + "symmetric": true + } + ], + "items": [ + { + "domain_links": { + "controls": [ + "q" + ], + "relates-to-term": [ + "q" + ] + }, + "slug": "p", + "type": "concept" + }, + { + "slug": "q", + "type": "concept" + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-27" +} diff --git a/tests/fixtures/vectors/links/links-0020-related-joining-a-cluster-warns.json b/tests/fixtures/vectors/links/links-0020-related-joining-a-cluster-warns.json new file mode 100644 index 0000000..708a6e3 --- /dev/null +++ b/tests/fixtures/vectors/links/links-0020-related-joining-a-cluster-warns.json @@ -0,0 +1,58 @@ +{ + "area": "links", + "description": "Derived from AGSC-03-25 and AGSC-05-20: the Expected target kinds cell of `related` reads any but a cluster, at either end, because a cluster is a `skos:Collection`, which AGSC-05-20 keeps out of `skos:related`, and the graph files leave such an edge out. The warning AGSC-E315 is carried by the item that authors the key: `note-a` names the cluster `grp`, and `grp` names the note `note-b`. Near misses that stay silent: `note-c` is related to `note-b` (two notes), and `note-b` uses the cluster (the cell of `uses` reads any, and `asc:uses` is no SKOS relation). The two findings are in slug order.", + "expected": { + "errors": [], + "warnings": [ + { + "code": "AGSC-E315", + "slug": "grp" + }, + { + "code": "AGSC-E315", + "slug": "note-a" + } + ] + }, + "id": "links-0020", + "input": { + "items": [ + { + "kind": "principle", + "related": [ + "grp" + ], + "slug": "note-a", + "type": "concept" + }, + { + "related": [ + "note-b" + ], + "slug": "grp", + "type": "cluster" + }, + { + "kind": "principle", + "related": [ + "note-b" + ], + "slug": "note-c", + "type": "concept" + }, + { + "kind": "principle", + "slug": "note-b", + "type": "concept", + "uses": [ + "grp" + ] + } + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-03-25" +} diff --git a/tests/fixtures/vectors/slug/slug-0001-accept.json b/tests/fixtures/vectors/slug/slug-0001-accept.json index dab40aa..16d6bc0 100644 --- a/tests/fixtures/vectors/slug/slug-0001-accept.json +++ b/tests/fixtures/vectors/slug/slug-0001-accept.json @@ -20,7 +20,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-10" } diff --git a/tests/fixtures/vectors/slug/slug-0002-reject-double-hyphen.json b/tests/fixtures/vectors/slug/slug-0002-reject-double-hyphen.json index 730e2b0..ca90d7d 100644 --- a/tests/fixtures/vectors/slug/slug-0002-reject-double-hyphen.json +++ b/tests/fixtures/vectors/slug/slug-0002-reject-double-hyphen.json @@ -10,7 +10,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-10" } diff --git a/tests/fixtures/vectors/slug/slug-0003-reject-edge-hyphen-and-case.json b/tests/fixtures/vectors/slug/slug-0003-reject-edge-hyphen-and-case.json index 5cc6c9e..fe089d5 100644 --- a/tests/fixtures/vectors/slug/slug-0003-reject-edge-hyphen-and-case.json +++ b/tests/fixtures/vectors/slug/slug-0003-reject-edge-hyphen-and-case.json @@ -15,7 +15,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-10" } diff --git a/tests/fixtures/vectors/slug/slug-0004-unique-per-bundle.json b/tests/fixtures/vectors/slug/slug-0004-unique-per-bundle.json index ec3d6ff..40d78a5 100644 --- a/tests/fixtures/vectors/slug/slug-0004-unique-per-bundle.json +++ b/tests/fixtures/vectors/slug/slug-0004-unique-per-bundle.json @@ -13,7 +13,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-11" } diff --git a/tests/fixtures/vectors/slug/slug-0006-portable-pattern.json b/tests/fixtures/vectors/slug/slug-0006-portable-pattern.json index 39a0af6..8566411 100644 --- a/tests/fixtures/vectors/slug/slug-0006-portable-pattern.json +++ b/tests/fixtures/vectors/slug/slug-0006-portable-pattern.json @@ -37,7 +37,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-01-10" } diff --git a/tests/fixtures/vectors/slug/slug-0007-slugify-ascii-lower-case.json b/tests/fixtures/vectors/slug/slug-0007-slugify-ascii-lower-case.json index 72b37f7..24d5fdf 100644 --- a/tests/fixtures/vectors/slug/slug-0007-slugify-ascii-lower-case.json +++ b/tests/fixtures/vectors/slug/slug-0007-slugify-ascii-lower-case.json @@ -22,7 +22,7 @@ }, "level": "required", "options": { - "spec_version": "1.0.0" + "spec_version": "1.1.0" }, "rule": "AGSC-02-91" } diff --git a/tests/fixtures/vectors/slug/slug-0008-windows-device-names-are-valid-slugs.json b/tests/fixtures/vectors/slug/slug-0008-windows-device-names-are-valid-slugs.json new file mode 100644 index 0000000..b469dd3 --- /dev/null +++ b/tests/fixtures/vectors/slug/slug-0008-windows-device-names-are-valid-slugs.json @@ -0,0 +1,36 @@ +{ + "area": "slug", + "description": "AGSC-01-10 and AGSC-01-40: the slug grammar is unchanged at 1.1. The nine device names below match it and are valid slugs; AGSC-01-40 reports them as warnings where they become file names, which a slug check does not do.", + "expected": { + "valid": [ + true, + true, + true, + true, + true, + true, + true, + true, + true + ] + }, + "id": "slug-0008", + "input": { + "slugs": [ + "con", + "prn", + "aux", + "nul", + "com1", + "com9", + "lpt1", + "lpt9", + "con-notes" + ] + }, + "level": "required", + "options": { + "spec_version": "1.1.0" + }, + "rule": "AGSC-01-10" +} diff --git a/tests/fixtures/wellknown/card-not-served/.well-known/knowledge-linkset b/tests/fixtures/wellknown/card-not-served/.well-known/knowledge-linkset new file mode 100644 index 0000000..45e22d7 --- /dev/null +++ b/tests/fixtures/wellknown/card-not-served/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-surface":["a2a-card"],"agsc-surface-version":["1.0"],"href":"https://example.org/.well-known/agent-card.json","type":"application/json"},{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/card-not-served/chunks.jsonl b/tests/fixtures/wellknown/card-not-served/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/card-not-served/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/card-not-served/graph.jsonld b/tests/fixtures/wellknown/card-not-served/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/card-not-served/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/card-not-served/ledger.jsonl b/tests/fixtures/wellknown/card-not-served/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/card-not-served/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/card-not-served/llms.txt b/tests/fixtures/wellknown/card-not-served/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/card-not-served/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/card-other-origin/.well-known/knowledge-linkset b/tests/fixtures/wellknown/card-other-origin/.well-known/knowledge-linkset new file mode 100644 index 0000000..5f94a8e --- /dev/null +++ b/tests/fixtures/wellknown/card-other-origin/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-surface":["a2a-card"],"agsc-surface-version":["1.0"],"href":"https://agents.example/.well-known/agent-card.json","type":"application/json"},{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/card-other-origin/chunks.jsonl b/tests/fixtures/wellknown/card-other-origin/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/card-other-origin/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/card-other-origin/graph.jsonld b/tests/fixtures/wellknown/card-other-origin/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/card-other-origin/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/card-other-origin/ledger.jsonl b/tests/fixtures/wellknown/card-other-origin/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/card-other-origin/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/card-other-origin/llms.txt b/tests/fixtures/wellknown/card-other-origin/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/card-other-origin/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/card-served/.well-known/agent-card.json b/tests/fixtures/wellknown/card-served/.well-known/agent-card.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tests/fixtures/wellknown/card-served/.well-known/agent-card.json @@ -0,0 +1 @@ +{} diff --git a/tests/fixtures/wellknown/card-served/.well-known/knowledge-linkset b/tests/fixtures/wellknown/card-served/.well-known/knowledge-linkset new file mode 100644 index 0000000..45e22d7 --- /dev/null +++ b/tests/fixtures/wellknown/card-served/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-surface":["a2a-card"],"agsc-surface-version":["1.0"],"href":"https://example.org/.well-known/agent-card.json","type":"application/json"},{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/card-served/chunks.jsonl b/tests/fixtures/wellknown/card-served/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/card-served/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/card-served/graph.jsonld b/tests/fixtures/wellknown/card-served/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/card-served/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/card-served/ledger.jsonl b/tests/fixtures/wellknown/card-served/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/card-served/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/card-served/llms.txt b/tests/fixtures/wellknown/card-served/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/card-served/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-count-wrong/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-count-wrong/.well-known/knowledge-linkset new file mode 100644 index 0000000..ca2f58b --- /dev/null +++ b/tests/fixtures/wellknown/chunks-count-wrong/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-chunk-count":["4"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-count-wrong/chunks.jsonl b/tests/fixtures/wellknown/chunks-count-wrong/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-count-wrong/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-count-wrong/graph.jsonld b/tests/fixtures/wellknown/chunks-count-wrong/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-count-wrong/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-count-wrong/ledger.jsonl b/tests/fixtures/wellknown/chunks-count-wrong/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-count-wrong/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-count-wrong/llms.txt b/tests/fixtures/wellknown/chunks-count-wrong/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-count-wrong/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-credential-not-served/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-credential-not-served/.well-known/knowledge-linkset new file mode 100644 index 0000000..c8544f8 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-credential-not-served/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["credential"],"agsc-surface":["chunks"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-credential-not-served/graph.jsonld b/tests/fixtures/wellknown/chunks-credential-not-served/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-credential-not-served/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-credential-not-served/ledger.jsonl b/tests/fixtures/wellknown/chunks-credential-not-served/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-credential-not-served/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-credential-not-served/llms.txt b/tests/fixtures/wellknown/chunks-credential-not-served/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-credential-not-served/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-facts-complete/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-facts-complete/.well-known/knowledge-linkset new file mode 100644 index 0000000..4ce9c6c --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-complete/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-facts-complete/chunks.jsonl b/tests/fixtures/wellknown/chunks-facts-complete/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-complete/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-facts-complete/graph.jsonld b/tests/fixtures/wellknown/chunks-facts-complete/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-complete/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-facts-complete/ledger.jsonl b/tests/fixtures/wellknown/chunks-facts-complete/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-complete/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-facts-complete/llms.txt b/tests/fixtures/wellknown/chunks-facts-complete/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-complete/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-facts-earlier/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-facts-earlier/.well-known/knowledge-linkset new file mode 100644 index 0000000..b7ab0a9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-earlier/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.0.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-surface":["chunks"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-facts-earlier/chunks.jsonl b/tests/fixtures/wellknown/chunks-facts-earlier/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-earlier/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-facts-earlier/graph.jsonld b/tests/fixtures/wellknown/chunks-facts-earlier/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-earlier/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-facts-earlier/ledger.jsonl b/tests/fixtures/wellknown/chunks-facts-earlier/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-earlier/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-facts-earlier/llms.txt b/tests/fixtures/wellknown/chunks-facts-earlier/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-earlier/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-facts-missing/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-facts-missing/.well-known/knowledge-linkset new file mode 100644 index 0000000..c253b43 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-missing/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-surface":["chunks"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-facts-missing/chunks.jsonl b/tests/fixtures/wellknown/chunks-facts-missing/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-missing/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-facts-missing/graph.jsonld b/tests/fixtures/wellknown/chunks-facts-missing/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-missing/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-facts-missing/ledger.jsonl b/tests/fixtures/wellknown/chunks-facts-missing/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-missing/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-facts-missing/llms.txt b/tests/fixtures/wellknown/chunks-facts-missing/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-facts-missing/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-lines-not-json/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-lines-not-json/.well-known/knowledge-linkset new file mode 100644 index 0000000..b74d32e --- /dev/null +++ b/tests/fixtures/wellknown/chunks-lines-not-json/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:piXCiQPkAfv6Hx+MaGO/iZWFJhK+XOgVU78V8gbxdPc=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-lines-not-json/chunks.jsonl b/tests/fixtures/wellknown/chunks-lines-not-json/chunks.jsonl new file mode 100644 index 0000000..6556997 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-lines-not-json/chunks.jsonl @@ -0,0 +1 @@ +not a chunk line diff --git a/tests/fixtures/wellknown/chunks-lines-not-json/graph.jsonld b/tests/fixtures/wellknown/chunks-lines-not-json/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-lines-not-json/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-lines-not-json/ledger.jsonl b/tests/fixtures/wellknown/chunks-lines-not-json/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-lines-not-json/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-lines-not-json/llms.txt b/tests/fixtures/wellknown/chunks-lines-not-json/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-lines-not-json/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-set-wrong/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-set-wrong/.well-known/knowledge-linkset new file mode 100644 index 0000000..6f176fc --- /dev/null +++ b/tests/fixtures/wellknown/chunks-set-wrong/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:2lEnLAqg58f5SGPSWy60fzDo6gOd3mpIFWAG7L1UJbw=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-set-wrong/chunks.jsonl b/tests/fixtures/wellknown/chunks-set-wrong/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-set-wrong/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-set-wrong/graph.jsonld b/tests/fixtures/wellknown/chunks-set-wrong/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-set-wrong/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-set-wrong/ledger.jsonl b/tests/fixtures/wellknown/chunks-set-wrong/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-set-wrong/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-set-wrong/llms.txt b/tests/fixtures/wellknown/chunks-set-wrong/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-set-wrong/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/chunks-sharded/.well-known/knowledge-linkset b/tests/fixtures/wellknown/chunks-sharded/.well-known/knowledge-linkset new file mode 100644 index 0000000..81b18f1 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["1"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:R3ooh3S4GXPKeKAhaXb96gRrTnIL2UhEGP6ntOmZE0c=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/chunks-sharded/chunks-0001.jsonl b/tests/fixtures/wellknown/chunks-sharded/chunks-0001.jsonl new file mode 100644 index 0000000..3a5e85c --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/chunks-0001.jsonl @@ -0,0 +1 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-sharded/chunks-0002.jsonl b/tests/fixtures/wellknown/chunks-sharded/chunks-0002.jsonl new file mode 100644 index 0000000..d9cece4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/chunks-0002.jsonl @@ -0,0 +1,2 @@ +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/chunks-sharded/chunks.jsonl b/tests/fixtures/wellknown/chunks-sharded/chunks.jsonl new file mode 100644 index 0000000..9bbce58 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/chunks.jsonl @@ -0,0 +1 @@ +{"shards":["chunks-0001.jsonl","chunks-0002.jsonl"]} diff --git a/tests/fixtures/wellknown/chunks-sharded/graph.jsonld b/tests/fixtures/wellknown/chunks-sharded/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/chunks-sharded/ledger.jsonl b/tests/fixtures/wellknown/chunks-sharded/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/chunks-sharded/llms.txt b/tests/fixtures/wellknown/chunks-sharded/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/chunks-sharded/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/fixtures/wellknown/ledger-length-wrong/.well-known/knowledge-linkset b/tests/fixtures/wellknown/ledger-length-wrong/.well-known/knowledge-linkset new file mode 100644 index 0000000..f740e53 --- /dev/null +++ b/tests/fixtures/wellknown/ledger-length-wrong/.well-known/knowledge-linkset @@ -0,0 +1 @@ +{"linkset":[{"alternate":[{"digest":["sha-256=:jvCwSK1RqdLMr5F3cW18gxWaHYwi/TeqK30DwRshtA0=:"],"href":"https://example.org/llms.txt","type":"text/plain"}],"anchor":"https://example.org/","describedby":[{"agsc-bundle-hash":["sha-256=:Hm7WXXfWNk7q7Vp0W6XEmFritwDdhdfPfwJ73ylKM/w=:"],"agsc-bundle-version":["v1.4.0"],"agsc-counts":["clusters=0","concepts=1","episodes=0","gates=0","lessons=0","procedures=0"],"agsc-generated-at":["2026-10-29T00:00:00Z"],"agsc-spec-version":["1.1.0"],"digest":["sha-256=:uM+tyWY5SKewy6ymkOZYgR5PSko+78x9OJyIvcs4TU4=:"],"href":"https://example.org/graph.jsonld","type":"application/ld+json"}],"https://w3id.org/agentic-system-core/rel#ledger":[{"agsc-ledger-head":["bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"],"agsc-ledger-length":["2"],"digest":["sha-256=:mblIY47isvOBNvXpJSaluqVbopmCqjOLEgQ4e5oDowo=:"],"href":"https://example.org/ledger.jsonl","type":"application/jsonl"}],"https://w3id.org/agentic-system-core/rel#surface":[{"agsc-access":["none"],"agsc-chunk-count":["3"],"agsc-chunk-set":["sha-256=:wVzZiMjxoN5RC3qE+tDAr4CVRfLFldqWDZMf1KLxoCA=:"],"agsc-surface":["chunks"],"digest":["sha-256=:zHBOOnB/p2NgIt7gbICZE3dcXWIki9wc0doUXlGkk00=:"],"href":"https://example.org/chunks.jsonl","type":"application/jsonl"}]}]} diff --git a/tests/fixtures/wellknown/ledger-length-wrong/chunks.jsonl b/tests/fixtures/wellknown/ledger-length-wrong/chunks.jsonl new file mode 100644 index 0000000..5eca946 --- /dev/null +++ b/tests/fixtures/wellknown/ledger-length-wrong/chunks.jsonl @@ -0,0 +1,3 @@ +{"digest":"05f1a99236280abb69e26c14f8ba132827935c3f89a39d6d52d504de282855b3","id":"848605af4f37ec13cd570127eb9aafe2d2876c734ab127187dabe7b725890536","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"Intro paragraph.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"f06d38fc6bf3920390daa6d7057f02efbbde8c993345e2813ae8c9e35f86df94","id":"b91b7cf751ac9e2834e5d295079d84fad992ae8dba90ea23ac06d8f63d95cd05","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"intent","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Intent\n\nCoordinate workers.\n","title":"Supervisor","trust":"untrusted","type":"text"} +{"digest":"0050032f1fce0a18a854fb977288802f4635199baf89ce767ca391c02258dfd5","id":"04daced57d83ce28d1b83d2df073d4d57fb7d220245121edd36970870bf607ed","iri":"https://example.org/concepts/supervisor/","item":"supervisor","kind":"concept","license":"LicenseRef-AgenticSystemCore-Content-Use-1.0","links":{"requires":["worker"]},"ordinal":0,"section":"structure","subkind":"pattern","terms":"LicenseRef-AgenticSystemCore-Content-Use-1.0","text":"## Structure\n\n```text\ncode stays\n```\n","title":"Supervisor","trust":"untrusted","type":"text"} diff --git a/tests/fixtures/wellknown/ledger-length-wrong/graph.jsonld b/tests/fixtures/wellknown/ledger-length-wrong/graph.jsonld new file mode 100644 index 0000000..79673b9 --- /dev/null +++ b/tests/fixtures/wellknown/ledger-length-wrong/graph.jsonld @@ -0,0 +1 @@ +{"@graph":[]} diff --git a/tests/fixtures/wellknown/ledger-length-wrong/ledger.jsonl b/tests/fixtures/wellknown/ledger-length-wrong/ledger.jsonl new file mode 100644 index 0000000..5f76e47 --- /dev/null +++ b/tests/fixtures/wellknown/ledger-length-wrong/ledger.jsonl @@ -0,0 +1 @@ +{"hash":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"} diff --git a/tests/fixtures/wellknown/ledger-length-wrong/llms.txt b/tests/fixtures/wellknown/ledger-length-wrong/llms.txt new file mode 100644 index 0000000..b4f04f4 --- /dev/null +++ b/tests/fixtures/wellknown/ledger-length-wrong/llms.txt @@ -0,0 +1 @@ +# Example diff --git a/tests/test_actor_pattern.py b/tests/test_actor_pattern.py index b843d6d..0805c6c 100644 --- a/tests/test_actor_pattern.py +++ b/tests/test_actor_pattern.py @@ -3,7 +3,8 @@ The specification's ledger ends with a ``build`` entry whose actor is ``process:agsc/`` (AGSC-08-20a), so the grammar admits a process actor followed by ``/``. The engine's item schema carries the same pattern; when -the engine is beside this repository, the two are compared on every case below. +the engine checkout is here (``../agentic-system-core``, or the one +``AGSC_ENGINE_DIR`` names), the two are compared on every case below. """ import json @@ -13,6 +14,7 @@ import pytest from agentic_system_core import frontmatter +from conftest import ENGINE PROV = {"origin": "human", "operator": "human:x"} GOOD = ["human:ada", "process:ci", "process:agsc/1.0.0", "process:agsc/1.0.0-rc.7", @@ -20,8 +22,7 @@ BAD = ["agent:x", "ada", "human:Ada", "human:", "/1.0", "process:", "process:/1.0", "process:agsc/", "process:agsc/1.0/2", "process:Agsc/1.0", "human:ada/1.0", "process:agsc/-1"] -ENGINE_SCHEMA = os.path.join(os.path.dirname(__file__), "..", "..", "agentic-system-core", - "schema", "item.schema.json") +ENGINE_SCHEMA = str(ENGINE / "schema" / "item.schema.json") def episode(actor): @@ -49,7 +50,7 @@ def test_generated_by_takes_the_same_grammar(): assert frontmatter.check(data) == [] -@pytest.mark.skipif(not os.path.isfile(ENGINE_SCHEMA), reason="the engine is not beside this repository") +@pytest.mark.skipif(not os.path.isfile(ENGINE_SCHEMA), reason="the engine checkout is not here") def test_the_engine_schema_agrees_on_every_case(): with open(ENGINE_SCHEMA, encoding="utf-8") as handle: pattern = re.compile(json.load(handle)["$defs"]["actor"]["pattern"]) diff --git a/tests/test_architecture.py b/tests/test_architecture.py new file mode 100644 index 0000000..0597bcc --- /dev/null +++ b/tests/test_architecture.py @@ -0,0 +1,121 @@ +"""Fitness functions for the package's shape, read from the source with ``ast``. + +Four rules the README and docs/ARCHITECTURE.md state: the package imports nothing but +the standard library and itself (``dependencies = []``); only ``cli.py`` starts a +process (it forwards the engine verbs to Node), so a checker of a built tree reads files +another writer built and never builds one itself; the relation table of AGSC-03-01 +has one source, ``data/relations.json``, which only ``relations.py`` reads; and only +``net.py`` opens a connection, so every request is guarded and counted against the +run's request budget (AGSC-11-07 to AGSC-11-10). +""" + +import ast +import importlib.util +import pathlib +import sys +import sysconfig + +PACKAGE = pathlib.Path(__file__).resolve().parent.parent / "src" / "agentic_system_core" +MODULES = sorted(PACKAGE.rglob("*.py")) +_STDLIB = tuple(str(pathlib.Path(sysconfig.get_paths()[key]).resolve()) + for key in ("stdlib", "platstdlib")) + + +def _imports(path): + """The top-level names a module imports absolutely (relative imports are the package).""" + names = set() + for node in ast.walk(ast.parse(path.read_text(encoding="utf-8"))): + if isinstance(node, ast.Import): + names.update(alias.name.split(".")[0] for alias in node.names) + elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module: + names.add(node.module.split(".")[0]) + return names + + +def _is_standard_library(name): + if name in sys.builtin_module_names: + return True + spec = importlib.util.find_spec(name) + if spec is None: + return False + if spec.origin in (None, "built-in", "frozen"): + return True + return str(pathlib.Path(spec.origin).resolve()).startswith(_STDLIB) \ + and "site-packages" not in spec.origin + + +def test_the_package_imports_only_the_standard_library_and_itself(): + outside = {} + for path in MODULES: + foreign = sorted(name for name in _imports(path) + if name != "agentic_system_core" and not _is_standard_library(name)) + if foreign: + outside[str(path.relative_to(PACKAGE))] = foreign + assert outside == {} + + +def test_a_third_party_name_would_be_caught(): + assert _is_standard_library("json") and _is_standard_library("sys") + assert not _is_standard_library("pytest") + assert not _is_standard_library("no_such_module_anywhere") + + +def test_only_the_command_line_starts_a_process(): + starters = sorted(str(path.relative_to(PACKAGE)) for path in MODULES + if _imports(path) & {"subprocess", "multiprocessing"}) + assert starters == ["cli.py"] + + +def _string_constants(path): + return set(node.value for node in ast.walk(ast.parse(path.read_text(encoding="utf-8"))) + if isinstance(node, ast.Constant) and isinstance(node.value, str)) + + +def test_the_relation_table_has_one_source(): + # AGSC-03-01: the fourteen keys, their inverses and their RDF properties are read + # from data/relations.json (derived from the engine), never typed in a module. + # A computed inverse name is the table's own fact, so no module spells one out, + # and only relations.py names the data file. + from agentic_system_core import relations + spelled = dict((str(path.relative_to(PACKAGE)), + sorted(_string_constants(path) & set(relations.COMPUTED_KEYS))) + for path in MODULES) + assert dict((name, found) for name, found in spelled.items() if found) == {} + readers = sorted(str(path.relative_to(PACKAGE)) for path in MODULES + if "relations.json" in _string_constants(path)) + assert readers == ["relations.py"] + + +#: The standard-library packages that open a connection: a socket, TLS, an HTTP client, +#: an event loop's transports, or urllib's opener. +_NETWORK = ("socket", "ssl", "http", "asyncio") + + +def _network_imports(path): + """The connection-opening modules a module imports, by dotted name.""" + found = set() + for node in ast.walk(ast.parse(path.read_text(encoding="utf-8"))): + if isinstance(node, ast.Import): + names = [alias.name for alias in node.names] + elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module: + names = [node.module] + [node.module + "." + alias.name for alias in node.names] + else: + continue + found.update(name for name in names + if name.split(".")[0] in _NETWORK or name == "urllib.request") + return found + + +def test_only_the_guarded_reader_opens_a_connection(): + # AGSC-11-07 to AGSC-11-10: every request goes through net.py, where the address is + # classified, the redirects, the deadline and the caps hold, and the run's request + # budget is spent (AGSC-11-10(c)); no other module may open a connection of its own. + openers = sorted(str(path.relative_to(PACKAGE)) for path in MODULES if _network_imports(path)) + assert openers == ["net.py"] + + +def test_a_connection_import_would_be_caught(tmp_path): + module = tmp_path / "probe.py" + module.write_text("import http.client\nfrom urllib import request\nimport json\n", + encoding="utf-8") + assert _network_imports(module) == {"http.client", "urllib.request"} diff --git a/tests/test_area_handlers.py b/tests/test_area_handlers.py index f2191d9..d5eb395 100644 --- a/tests/test_area_handlers.py +++ b/tests/test_area_handlers.py @@ -18,20 +18,20 @@ def vector(identifier): raise KeyError(identifier) -def _needs_build(data): - """A vector whose input is a whole Bundle, or which states the publisher's JSON-LD - files, is reported not run, never judged.""" - given = data["input"] - if data["area"] == "build": - return any(k in given for k in ("bundle", "files")) - if data["area"] == "graph": - return ("bundle" in given and isinstance(given.get("item"), dict)) or "graph_jsonld" in data["expected"] - return data["area"] == "discovery" and "bundle" in given and "items" not in given +def _not_run(data): + """A vector this package reports as not run, with its reason, is never judged, and nor + is a withdrawn one, which the runner skips before any handler. A handler that raises + is judged: the runner reports the raise as a failure.""" + if data.get("level") == "withdrawn": + return True + try: + return AREA_RUNNERS[data["area"]](copy.deepcopy(data))["status"] == "not-run" + except Exception: + return False RUN = [one for one in sorted(VECTORS.rglob("*.json")) - if json.loads(one.read_bytes().decode("utf-8"))["area"] not in ("jcs", "slug") - and not _needs_build(json.loads(one.read_bytes().decode("utf-8")))] + if not _not_run(json.loads(one.read_bytes().decode("utf-8")))] def test_a_vector_that_needs_a_whole_build_is_reported_not_run(): @@ -42,11 +42,27 @@ def test_a_vector_that_needs_a_whole_build_is_reported_not_run(): assert "whole Bundle" in result["detail"] or "full Bundle build" in result["detail"] -def test_the_publishers_json_ld_files_are_reported_not_run(): +def test_the_publishers_json_ld_files_are_written_and_compared_whole(): + # graph-0028 (AGSC-05-09): graph.jsonld and every per-item file, after JCS. data = vector("graph-0028") result = AREA_RUNNERS[data["area"]](data) - assert result["status"] == "not-run" - assert "graph.jsonld writer" in result["detail"] + assert result["status"] == "pass", result["detail"] + + +@pytest.mark.parametrize("member", ["graph_jsonld", "per_item"]) +def test_a_changed_json_ld_expectation_fails(member): + data = vector("graph-0028") + document = data["expected"]["graph_jsonld"] if member == "graph_jsonld" \ + else data["expected"]["per_item"]["beta"] + document["@graph"][1]["prefLabel"]["@value"] = "Changed" + result = AREA_RUNNERS[data["area"]](data) + assert result["status"] == "fail" + + +def test_a_per_item_file_the_vector_does_not_state_fails(): + data = vector("graph-0028") + del data["expected"]["per_item"]["group"] + assert AREA_RUNNERS[data["area"]](data)["status"] == "fail" @pytest.mark.parametrize("path", RUN, ids=[one.stem for one in RUN]) @@ -91,6 +107,76 @@ def test_the_portable_pattern_case_asserts_lookahead_in_either_polarity(): assert "lookahead" in result["detail"] +def test_the_portable_pattern_case_asserts_the_engine_features_it_states(): + # slug-0006: the non-portable features the pattern uses (none), as the engine's + # handler reads them from the pattern source; a case stating one fails. + data = vector("slug-0006") + assert data["expected"]["engine_features_used"] == [] + mutated = copy.deepcopy(data) + mutated["expected"]["engine_features_used"] = ["lookahead"] + result = AREA_RUNNERS["slug"](mutated) + assert result["status"] == "fail", result + assert "engine-features-used" in result["detail"] + + +@pytest.mark.parametrize("source, used", [ + ("^[a-z0-9]+(?:-[a-z0-9]+)*$", []), + ("^(?=a)(?x)(?>y)a++\\u0041\\p{L}$", + ["lookahead", "lookbehind", "backreference", "named group", "atomic group", + "possessive quantifier", "unicode escape", "property escape"]), +]) +def test_the_non_portable_features_are_named_as_the_engine_names_them(source, used): + from agentic_system_core.areas import slug_area + assert slug_area.features_used(source) == used + + +def test_a_pass_that_left_an_expected_member_unread_is_a_fail(): + # The engine's guard (tests/conformance/areas/_expected-reads.js): a handler that + # never read a member of `expected` asserted nothing about it. + from agentic_system_core.areas._expected_reads import guarded + + def reads_a(data): + return {"status": "pass" if data["expected"]["a"] == 1 else "fail", "detail": ""} + + assert guarded(reads_a)({"id": "x-0001", "expected": {"a": 1}})["status"] == "pass" + result = guarded(reads_a)({"id": "x-0001", "expected": {"a": 1, "b": 2}}) + assert result == {"status": "fail", "detail": 'x-0001: no branch of the handler reads "b"'} + nothing = guarded(lambda data: {"status": "pass", "detail": ""})({"id": "x-0002", + "expected": {}}) + assert nothing["status"] == "fail" and "states no expected member" in nothing["detail"] + # Presence tests, `get` and listing the members count as reads, as in the engine. + for handler in (lambda data: "a" in data["expected"], lambda data: data["expected"].get("a"), + lambda data: list(data["expected"]), lambda data: dict(data["expected"]), + lambda data: data["expected"].keys(), lambda data: data["expected"].items(), + lambda data: data["expected"].values()): + def run(data, handler=handler): + handler(data) + return {"status": "pass", "detail": ""} + assert guarded(run)({"id": "x-0003", "expected": {"a": 1}})["status"] == "pass" + # A fail and a not-run pass through unchanged, and the vector is not changed. + own = {"status": "fail", "detail": "own"} + case = {"id": "x-0004", "expected": {"a": 1}} + assert guarded(lambda data: own)(case) is own + assert guarded(lambda data: {"status": "not-run", "detail": "r"})(case)["status"] == "not-run" + assert type(case["expected"]) is dict + # A case whose `expected` is not an object is the handler's to judge. + assert guarded(lambda data: {"status": "pass", "detail": ""})( + {"id": "x-0005", "expected": None})["status"] == "pass" + + +@pytest.mark.parametrize("index", [0, 1, 2, 3]) +def test_a_forbidden_form_the_handler_does_not_know_fails(index): + # graph-0018: each entry of `forbidden` is a prose statement of a form the rules + # exclude, checked by its own reading; an entry no reading knows fails, as in the + # engine's `forbiddenCheck`. + data = vector("graph-0018") + assert AREA_RUNNERS["graph"](data)["status"] == "pass" + data["expected"]["forbidden"][index] = "zz a clause no handler knows" + result = AREA_RUNNERS["graph"](data) + assert result["status"] == "fail", result + assert "does not implement that clause" in result["detail"] + + @pytest.mark.parametrize("area", ["build", "discovery", "frontmatter", "graph"]) def test_an_input_shape_no_handler_knows_fails(area): result = AREA_RUNNERS[area]({"expected": {}, "input": {"zz": 1}}) @@ -118,8 +204,9 @@ def test_case_lists_with_missing_or_extra_cases_fail(): def test_wrong_bytes_are_caught(): for identifier, member in (("graph-0026", "turtle"), ("graph-0021", "nquads"), - ("disc-0013", "output"), ("build-0003", "output"), - ("fm-0008", "output")): + ("disc-0024", "output"), ("disc-0034", "output"), + ("build-0003", "output"), ("fm-0008", "output"), + ("graph-0040", "skos")): data = vector(identifier) data["expected"][member] = data["expected"][member] + "x" assert AREA_RUNNERS[data["area"]](data)["status"] == "fail", identifier @@ -139,3 +226,58 @@ def test_the_links_area_reports_errors_on_a_clean_case(): data = vector("links-0004") data["expected"]["errors"] = ["AGSC-E301"] assert AREA_RUNNERS["links"](data)["status"] == "fail" + + +@pytest.mark.parametrize("identifier, reason", [ + ("build-0031", "writes no HTML"), ("build-0032", "writes no HTML"), + ("build-0037", "chunk"), + ("disc-0020", "whole link table"), ("disc-0021", "whole link table"), + ("fm-0022", "domain layer: engine only in 1.1"), + ("graph-0044", "domain layer: engine only in 1.1"), + ("links-0019", "domain layer: engine only in 1.1"), +]) +def test_a_case_this_package_cannot_run_is_reported_not_run_with_its_reason(identifier, + reason): + data = vector(identifier) + result = AREA_RUNNERS[data["area"]](data) + assert result["status"] == "not-run" + assert reason in result["detail"] + + +@pytest.mark.parametrize("identifier", ["links-0010", "links-0012", "links-0014", + "links-0016"]) +def test_a_warning_the_case_does_not_state_fails(identifier): + data = vector(identifier) + assert AREA_RUNNERS["links"](data)["status"] == "pass" + data["expected"]["warnings"] = data["expected"]["warnings"][1:] + assert AREA_RUNNERS["links"](data)["status"] == "fail" + + +@pytest.mark.parametrize("identifier", ["graph-0029", "graph-0030", "graph-0035", + "graph-0038"]) +def test_a_changed_reading_or_answer_fails(identifier): + data = vector(identifier) + assert AREA_RUNNERS["graph"](data)["status"] == "pass" + member = "readings" if "readings" in data["expected"] else "answer" + value = data["expected"][member] + data["expected"][member] = value[1:] if isinstance(value, list) else {} + assert AREA_RUNNERS["graph"](data)["status"] == "fail" + + +def test_the_nesting_cases_count_their_warnings(): + data = vector("fm-0026") + assert AREA_RUNNERS["frontmatter"](data)["status"] == "pass" + data["expected"]["warning_count"] = 1 + assert AREA_RUNNERS["frontmatter"](data)["status"] == "fail" + data = vector("fm-0021") + data["expected"]["warnings"] = [{"code": "AGSC-E105", "severity": "error"}] + assert AREA_RUNNERS["frontmatter"](data)["status"] == "fail" + + +def test_the_disclosure_page_and_the_restricted_now_line_are_asserted(): + data = vector("build-0035") + data["expected"]["cases"][0]["text"] = data["expected"]["cases"][1]["text"] + assert AREA_RUNNERS["build"](data)["status"] == "fail" + data = vector("build-0036") + data["expected"]["cases"][1]["line"] = data["expected"]["cases"][0]["line"] + assert AREA_RUNNERS["build"](data)["status"] == "fail" diff --git a/tests/test_build_cross_check.py b/tests/test_build_cross_check.py new file mode 100644 index 0000000..e414a13 --- /dev/null +++ b/tests/test_build_cross_check.py @@ -0,0 +1,277 @@ +"""The nine ``build`` cases over a whole build, checked by this package (build-0020 to +build-0028). + +This package writes no site, so ``run-vectors`` reports these cases as not run. Their +expectations are facts about the files a build writes, and this package checks them: +the engine builds the vector's Bundle exactly as its own handler does +(``tests/conformance/areas/_build-surfaces.js``, ``onBuild``) and +``areas/build_tree.py`` reads what was written. One test per case; each needs Node and +the engine checkout and is skipped with a message without them. The fixed-data tests +below show that every kind of expectation fails when the tree does not meet it. +""" + +import hashlib +import json +import shutil +import subprocess + +import pytest + +from agentic_system_core.areas import build_tree +from conftest import ENGINE, engine_available + +CASES = ["build-%04d" % number for number in range(20, 29)] + +_SCRIPT = r""" +const path = require('node:path'); +const [ROOT, bundle, argv, env, specVersion] = process.argv.slice(1); +const { main } = require(path.join(ROOT, 'src/application/cli/main.js')); +const { createFileSystem } = require(path.join(ROOT, 'src/adapters/node-fs.js')); +const stream = () => { const chunks = []; return { write(s) { chunks.push(s); return true; }, text: () => chunks.join('') }; }; +const stdout = stream(); +const stderr = stream(); +const exit = main(JSON.parse(argv), { env: JSON.parse(env), ports: { fs: createFileSystem(bundle) }, + root: bundle, specVersion, stderr, stdout, version: specVersion }); +process.stdout.write(JSON.stringify({ exit, stdout: stdout.text() })); +""" + + +def _walk(folder): + if not folder.is_dir(): + return [] + return sorted(one.relative_to(folder).as_posix() for one in folder.rglob("*") if one.is_file()) + + +class EngineBuild(object): + """``build(sub_case)``: the engine's ``agsc build`` over a scratch copy of the + vector's Bundle with the case's files written over it, the file-system port alone + (so no git history) and exactly the environment the case states.""" + + def __init__(self, vector, scratch): + self.vector = vector + self.scratch = scratch + + def __call__(self, sub): + given = self.vector["input"] + root = self.scratch / ((sub or {}).get("name") or "build") + shutil.copytree(str(ENGINE / "tests" / given["bundle"]), str(root)) + adds = dict(given.get("add_files") or {}) + adds.update((sub or {}).get("add_files") or {}) + for relative, text in adds.items(): + (root / relative).parent.mkdir(parents=True, exist_ok=True) + (root / relative).write_bytes(text.encode("utf-8")) + before = set(_walk(root)) + options = self.vector["options"] + environment = {"SOURCE_DATE_EPOCH": str(options["source_date_epoch"])} + environment.update((sub or {}).get("environment") or {}) + argv = (sub or {}).get("argv") or given.get("argv") or ["build", "--json"] + done = subprocess.run(["node", "-e", _SCRIPT, str(ENGINE), str(root), json.dumps(argv), + json.dumps(environment), options["spec_version"]], + capture_output=True, text=True, cwd=str(ENGINE)) + assert done.returncode == 0, done.stderr[-2000:] + result = json.loads(done.stdout) + try: + envelope = json.loads(result["stdout"]) + except ValueError: + envelope = None + out = (json.loads((root / "agsc.config.json").read_text(encoding="utf-8")) + .get("build", {}).get("out") or "www").rstrip("/") + return {"exit": result["exit"], + "findings": (envelope or {}).get("findings") or [], + "files": dict(("/" + one, (root / out / one).read_bytes()) + for one in _walk(root / out)), + "written": [one for one in _walk(root) if one not in before]} + + +def _engine_vector(identifier): + path = next((ENGINE / "tests" / "vectors" / "build").glob(identifier + "-*.json")) + return json.loads(path.read_bytes().decode("utf-8")) + + +needs_engine = pytest.mark.skipif( + not (engine_available() and (ENGINE / "src" / "application" / "cli" / "main.js").is_file()), + reason="the build cross-check needs Node and the engine checkout beside this one", +) + + +@needs_engine +@pytest.mark.parametrize("identifier", CASES) +def test_this_package_agrees_with_the_engine_build(identifier, tmp_path): + vector = _engine_vector(identifier) + if vector.get("level") == "withdrawn": + pytest.skip("%s is withdrawn in the engine's vector set (superseded by %s)" + % (identifier, vector.get("superseded_by"))) + result = build_tree.check(vector, EngineBuild(vector, tmp_path)) + assert result["status"] == "pass", result["detail"] + + +# --- on fixed data ------------------------------------------------------------------ + +def _run(files, findings=(), exit_code=0, written=()): + return {"exit": exit_code, "findings": list(findings), "written": list(written), + "files": dict((route, data if isinstance(data, bytes) else data.encode("utf-8")) + for route, data in files.items())} + + +def _check(identifier, expected, runs, cases=None): + vector = {"id": identifier, "input": {"cases": cases} if cases else {}, "expected": expected} + return build_tree.check(vector, lambda sub: runs[(sub or {}).get("name")]) + + +TREE = {"/index.html": "

handoff

", "/graph.nq": " birch .", + "/pages/birch.md": "---\ntitle: Birch\n---\n"} + + +def test_each_surface_expectation_is_read_from_the_tree(): + expected = {"no_error_finding": True, "routes_present": ["/", "/pages/birch.md"], + "routes_absent": ["/pages/alder.md"], "carried_by": {"/graph.nq": ["birch"]}, + "not_carried_by": {"/": ["birch"]}, "files_contain": {"/": ["handoff"]}, + "in_no_file": ["alder"], "route_bytes": {"/pages/birch.md": TREE["/pages/birch.md"]}} + assert _check("build-0020", expected, {None: _run(TREE)})["status"] == "pass" + + +@pytest.mark.parametrize("member, value", [ + ("routes_present", ["/pages/alder.md"]), ("routes_absent", ["/"]), + ("carried_by", {"/": ["birch"]}), ("carried_by", {"/absent/": ["birch"]}), + ("not_carried_by", {"/graph.nq": ["birch"]}), ("files_contain", {"/": ["alder"]}), + ("in_no_file", ["birch"]), ("in_no_file", ["pages"]), + ("route_bytes", {"/pages/birch.md": "other"}), ("no_error_finding", False), +]) +def test_a_surface_expectation_the_tree_does_not_meet_fails(member, value): + assert _check("build-0022", {member: value}, {None: _run(TREE)})["status"] == "fail" + + +def test_an_error_finding_or_a_failed_exit_is_not_a_clean_build(): + errors = [{"code": "AGSC-E901", "severity": "error"}] + for run in (_run(TREE, findings=errors, exit_code=1), _run(TREE, exit_code=1)): + assert _check("build-0023", {"no_error_finding": True}, {None: run})["status"] == "fail" + + +def test_an_expected_member_no_check_reads_fails(): + assert _check("build-0028", {"zz_unknown": True}, {None: _run(TREE)})["status"] == "fail" + + +def test_a_case_this_module_does_not_check_is_not_run(): + result = build_tree.check({"id": "build-0001", "input": {}, "expected": {}}, None) + assert result["status"] == "not-run" + + +def test_a_withdrawn_case_is_reported_withdrawn(): + vector = {"id": "build-0024", "level": "withdrawn", "input": {}, "expected": {"withdrawn": True}} + assert build_tree.check(vector, None) == {"status": "skip", "withdrawn": True, + "detail": "withdrawn (AGSC-00-16)"} + + +REFUSED = {"name": "content", "exit_one_of": [1, 2], "nothing_written": True, + "findings": [{"code": "AGSC-E204", "severity": "error"}]} +ACCEPTED = {"name": "slash", "exit": 0, "codes_absent": ["AGSC-E204"], "written_only_under": "www/"} + + +def test_the_build_out_cases_read_exit_findings_and_what_was_written(): + runs = {"content": _run({}, findings=[{"code": "AGSC-E204", "severity": "error", "line": 1}], + exit_code=1), + "slash": _run(TREE, written=["www/index.html"])} + cases = [{"name": "content"}, {"name": "slash"}] + assert _check("build-0021", {"cases": [REFUSED, ACCEPTED]}, runs, cases)["status"] == "pass" + runs = {"content": _run({}, exit_code=0, written=["content/x.md"]), + "slash": _run(TREE, findings=[{"code": "AGSC-E204", "severity": "error"}], exit_code=1, + written=["dist/index.html"])} + detail = _check("build-0021", {"cases": [REFUSED, ACCEPTED]}, runs, cases)["detail"] + for part in ("content exit", "content findings", "content nothing written", "slash exit", + "slash no AGSC-E204", "slash writes only under www/"): + assert part in detail + + +def test_a_sub_case_the_vector_does_not_expect_fails(): + result = _check("build-0021", {"cases": []}, {}, [{"name": "content"}]) + assert result["status"] == "fail" and "no expected case" in result["detail"] + + +def test_a_sub_case_member_no_check_reads_fails(): + runs = {"content": _run({})} + result = _check("build-0021", {"cases": [{"name": "content", "zz": 1}]}, runs, [{"name": "content"}]) + assert result["status"] == "fail" and "zz" in result["detail"] + + +def _skills_index(index): + return json.dumps(index, sort_keys=True, separators=(",", ":")) + "\n" + + +SKILL = b"# Agent patterns\n" +PACK = {"description": "d", "members": ["handoff"], "name": "agent-patterns", + "path": "/skills/agent-patterns/SKILL.md"} +INDEX = {"bundle_version": "0.0.0+20260101T000000Z", "license": "L", "spec_version": "1.0.0", + "terms": "L", "packs": [dict(PACK, lock={"SKILL.md": hashlib.sha256(SKILL).hexdigest()})]} +SKILLS = {"/skills/index.json": _skills_index(INDEX), "/skills/agent-patterns/SKILL.md": SKILL} +WANT_INDEX = {"name": "terms", "jcs_with_one_lf": True, "bundle_version": INDEX["bundle_version"], + "license": "L", "spec_version": "1.0.0", "terms": "L", + "members": ["bundle_version", "license", "packs", "spec_version", "terms"], + "pack_members": ["description", "lock", "members", "name", "path"], "packs": [PACK]} + + +def test_the_skills_index_is_read_member_by_member(): + runs = {"terms": _run(SKILLS)} + assert _check("build-0025", {"cases": [WANT_INDEX]}, runs, [{"name": "terms"}])["status"] == "pass" + unlocked = dict(INDEX, packs=[PACK], license="M") + runs = {"terms": _run({"/skills/index.json": json.dumps(unlocked, indent=1)})} + detail = _check("build-0025", {"cases": [WANT_INDEX]}, runs, [{"name": "terms"}])["detail"] + for part in ("JCS and one LF", "terms license", "pack 0 members", "pack 0 has a lock"): + assert part in detail + runs = {"terms": _run({})} + detail = _check("build-0025", {"cases": [WANT_INDEX]}, runs, [{"name": "terms"}])["detail"] + assert "terms packs" in detail and "terms members" in detail + + +def test_each_lock_is_the_hash_of_the_served_skill_file(): + want = {"packs_count": 1, "lock_members": ["SKILL.md"], "lock_is_sha256_of_skill_md": True, + "no_lock_route": True} + assert _check("build-0026", want, {None: _run(SKILLS)})["status"] == "pass" + changed = dict(SKILLS, **{"/skills/agent-patterns/SKILL.md": b"other\n", + "/skills/agent-patterns.lock": b"x"}) + detail = _check("build-0026", want, {None: _run(changed)})["detail"] + assert "lock is the hash" in detail and "no lock route" in detail + detail = _check("build-0026", want, {None: _run({"/skills/index.json": "[]"})})["detail"] + assert "packs_count" in detail + + +ROBOTS = ("User-agent: GPTBot\nDisallow: /\n\nUser-agent: CCBot\nUser-agent: ClaudeBot\n" + "Disallow: /\n\nUser-agent: *\nAllow: / # everyone else\n") +TDM = '[{"location":"/*","tdm-reservation":1}]\n' +WANT_TDM = {"name": "terms", "jcs_with_one_lf": True, "routes_absent": ["/tdmrep.json"], + "reservation_for_paths": {"/": 1, "/graph.nq": 1}, + "robots_disallow_all_groups": ["GPTBot", "CCBot", "ClaudeBot"]} + + +def test_the_reservation_file_and_the_robots_groups(): + runs = {"terms": _run({"/.well-known/tdmrep.json": TDM, "/robots.txt": ROBOTS})} + assert _check("build-0027", {"cases": [WANT_TDM]}, runs, [{"name": "terms"}])["status"] == "pass" + runs = {"terms": _run({"/tdmrep.json": TDM, "/robots.txt": "User-agent: *\nDisallow: /x\n"})} + detail = _check("build-0027", {"cases": [WANT_TDM]}, runs, [{"name": "terms"}])["detail"] + for part in ("JCS and one LF", "terms /graph.nq", "terms no /tdmrep.json", "robots groups"): + assert part in detail + + +def test_a_tdm_location_is_a_prefix_pattern_with_an_optional_end(): + assert build_tree.tdm_matches("/*", "/a/b") + assert build_tree.tdm_matches("/pages/", "/pages/handoff.md") + assert not build_tree.tdm_matches("/pages/$", "/pages/handoff.md") + assert build_tree.tdm_matches("/*.md$", "/pages/handoff.md") + assert not build_tree.tdm_matches("/a.b", "/axb") + + +ROUTE_SET = {"/index.html": '' + '', + "/concepts/index.html": '', + "/assets/site.css": "", "/assets/page.js": "", "/graph.nq": ""} +WANT_ROUTES = {"routes": ["/", "/concepts/", "/graph.nq"], "page_assets_required": ["/assets/site.css"], + "other_files_are_page_assets": True} + + +def test_the_route_set_leaves_out_the_assets_the_pages_load(): + vector = {"id": "build-0024", "input": {"deployment_profile": "cloudflare-pages"}, + "expected": WANT_ROUTES} + assert build_tree.check(vector, lambda sub: _run(ROUTE_SET))["status"] == "pass" + vector["input"]["deployment_profile"] = "netlify" + extra = dict(ROUTE_SET, **{"/extra.js": ""}) + detail = build_tree.check(vector, lambda sub: _run(extra))["detail"] + assert "the route set" in detail and "deployment profile" in detail diff --git a/tests/test_cli.py b/tests/test_cli.py index be68f27..e4b7532 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -21,7 +21,7 @@ def run(argv): def test_version(): code, out, _ = run(["--version"]) assert code == 0 - assert out.strip() == "agsc 1.0.1 (Python package; specification 1.0.0)" + assert out.strip() == "agsc 1.1.0 (Python package; specification 1.1.0)" def test_release_metadata(): @@ -31,8 +31,8 @@ def test_release_metadata(): root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) with open(os.path.join(root, "pyproject.toml"), encoding="utf-8") as handle: pyproject = handle.read() - assert (pkg.__version__, pkg.SEMVER_VERSION, pkg.SPEC_VERSION) == ("1.0.1", "1.0.1", "1.0.0") - assert '\nversion = "1.0.1"\n' in pyproject + assert (pkg.__version__, pkg.SEMVER_VERSION, pkg.SPEC_VERSION) == ("1.1.0", "1.1.0", "1.1.0") + assert '\nversion = "1.1.0"\n' in pyproject assert '"Development Status :: 5 - Production/Stable",' in pyproject assert "Development Status :: 4" not in pyproject @@ -91,7 +91,7 @@ def test_validate_wellknown_peer_and_dev_flags(): def test_validate_vectors(): code, out, _ = run(["validate-vectors", str(VECTORS)]) assert code == 0 - assert "94 input file(s) read" in out + assert "156 input file(s) read" in out code, out, _ = run(["validate-vectors", str(VECTORS), "--json"]) assert code == 0 assert parse_ijson(out)["verb"] == "validate-vectors" @@ -101,12 +101,18 @@ def test_validate_vectors(): def test_validate_vectors_usage_faults(): assert run(["validate-vectors"])[0] == 2 - assert run(["validate-vectors", "/no/such/dir"])[0] == 2 assert run(["validate-vectors", "--bogus"])[0] == 2 assert run(["validate-vectors", "--spec"])[0] == 2 assert run(["validate-vectors", "--help"])[0] == 0 +def test_validate_vectors_reports_a_missing_folder_in_the_envelope(): + # AGSC-09-90: exit 1 with AGSC-E901, as the engine's tool does; exit 2 is for usage. + code, out, err = run(["validate-vectors", "/no/such/dir", "--json"]) + assert code == 1 + assert [one["code"] for one in parse_ijson(out)["findings"]] == ["AGSC-E901"] + + def test_validate_vectors_with_a_live_spec_directory(tmp_path): spec = tmp_path / "spec" spec.mkdir() @@ -128,7 +134,7 @@ def test_validate_vectors_root_option(tmp_path): def test_run_vectors(): code, out, _ = run(["run-vectors", str(VECTORS)]) assert code == 0 - assert "78 pass" in out + assert "115 pass" in out assert "not run by this package: build-0015" in out code, out, _ = run(["run-vectors", str(VECTORS), "--json"]) assert parse_ijson(out)["areas_run"] == [ @@ -311,7 +317,7 @@ def test_allow_network_is_accepted_with_a_file_argument(): def test_validate_vectors_prints_findings_in_plain_form(tmp_path): area = tmp_path / "jcs" area.mkdir() - (area / "a.json").write_bytes(b'{"area":"jcs"}\n') + (area / "jcs-9100.json").write_bytes(b'{"area":"jcs"}\n') code, out, err = run(["validate-vectors", str(tmp_path)]) assert code == 1 assert "AGSC-E202" in err diff --git a/tests/test_community_files.py b/tests/test_community_files.py index 765e686..e558e76 100644 --- a/tests/test_community_files.py +++ b/tests/test_community_files.py @@ -4,7 +4,8 @@ second, never to a public issue; an outside contribution signs off under the contributor agreement ``CA-v1``. GitHub shows these files on the repository's pages, so a missing or wrong file sends a reporter to the wrong place. The files are repository -files: a source distribution does not carry them, and there the tests are skipped. +files: a source distribution carries only ``SECURITY.md`` of them, and there the tests +are skipped. """ import re diff --git a/tests/test_context_url.py b/tests/test_context_url.py index 766093d..8a123fe 100644 --- a/tests/test_context_url.py +++ b/tests/test_context_url.py @@ -1,11 +1,13 @@ """The versioned context address this package writes (AGSC-05-09, AGSC-05-25). -AGSC-05-09 names one persistent context address per vocabulary version, -``https://w3id.org/agentic-system-core/ns//context.jsonld``, and -AGSC-05-25 takes the version from the vocabulary's ``owl:versionIRI``. The -engine derives the address from ``ontology/agsc.ttl``; this package carries it -as a constant. When the engine is beside this repository, the constant is -compared with the address the engine's vocabulary gives. +AGSC-05-09 names one persistent context address, +``https://w3id.org/agentic-system-core/ns//context.jsonld``. As amended for +1.1, the version in it is a constant ``1.0.0`` at every version 1.x and no longer the +ontology version that AGSC-05-25 takes from ``owl:versionIRI`` (vector graph-0043): +raising the ontology version changes no byte of any ``graph.jsonld``. The engine holds +the constant as ``CONTEXT_VERSION`` in ``src/knowledge/jsonld.js``; this package as +``context.CONTEXT_VERSION``. When the engine is beside this repository, the two are +compared. No network, no clock: the test reads one file of the engine checkout. """ @@ -18,22 +20,25 @@ from agentic_system_core.rdf import IRI, RDF_TYPE from conftest import ENGINE -ONTOLOGY = ENGINE / "ontology" / "agsc.ttl" +JSONLD = ENGINE / "src" / "knowledge" / "jsonld.js" NAMESPACE = "https://w3id.org/agentic-system-core/ns" -def _version_iri(): - text = ONTOLOGY.read_text(encoding="utf-8") - found = re.findall(r"^\s*owl:versionIRI <([^>]+)>\s*[;.]\s*$", text, re.M) - assert len(found) == 1, "the engine's vocabulary carries %d owl:versionIRI" % len(found) +def _engine_context_version(): + text = JSONLD.read_text(encoding="utf-8") + found = re.findall(r"^const CONTEXT_VERSION = '([^']+)';$", text, re.M) + assert len(found) == 1, "the engine's jsonld.js states CONTEXT_VERSION %d times" % len(found) return found[0] -@pytest.mark.skipif(not ONTOLOGY.is_file(), reason="the engine is not beside this repository") -def test_the_context_address_is_the_one_the_engine_vocabulary_gives(): - version_iri = _version_iri() - assert version_iri.startswith(NAMESPACE + "/") - assert context.CONTEXT_URL == version_iri + "/context.jsonld" +@pytest.mark.skipif(not JSONLD.is_file(), reason="the engine is not beside this repository") +def test_the_context_address_names_the_engines_context_version(): + assert context.CONTEXT_VERSION == _engine_context_version() + assert context.CONTEXT_URL == "%s/%s/context.jsonld" % (NAMESPACE, context.CONTEXT_VERSION) + + +def test_the_context_version_is_the_constant_of_every_1x_version(): + assert context.CONTEXT_VERSION == "1.0.0" def test_the_address_is_the_persistent_form_of_the_rule(): @@ -46,3 +51,9 @@ def test_a_compacted_document_names_that_address(): built = context.build([{"kind": "object", "term": "uses"}], ["skos:prefLabel"]) document = context.compact(triples, built) assert document["@context"] == context.CONTEXT_URL + + +def test_the_1_0_name_of_the_context_version_still_imports(): + """A MINOR removes nothing (AGSC-00-14): 1.0's ``ONTOLOGY_VERSION`` stays, the same value.""" + from agentic_system_core.context import CONTEXT_VERSION, ONTOLOGY_VERSION + assert ONTOLOGY_VERSION == CONTEXT_VERSION == "1.0.0" diff --git a/tests/test_engine_path.py b/tests/test_engine_path.py new file mode 100644 index 0000000..429712a --- /dev/null +++ b/tests/test_engine_path.py @@ -0,0 +1,50 @@ +"""Where the suite looks for the engine checkout. + +The equivalence and cross-check tests run the engine beside this repository, at +``../agentic-system-core``. A maintainer who keeps a second engine worktree (a +release branch, say) points the suite at it with the environment variable +``AGSC_ENGINE_DIR``; without it, nothing changes. +""" + +import pathlib +import re + +import conftest + + +def test_without_the_variable_the_engine_is_the_sibling_checkout(): + assert conftest.engine_dir({}) == conftest.NEIGHBOURS / "agentic-system-core" + + +def test_an_empty_variable_counts_as_unset(): + assert conftest.engine_dir({"AGSC_ENGINE_DIR": ""}) == conftest.NEIGHBOURS / "agentic-system-core" + + +def test_the_variable_names_another_engine_checkout(tmp_path): + assert conftest.engine_dir({"AGSC_ENGINE_DIR": str(tmp_path)}) == tmp_path.resolve() + + +def test_a_relative_value_is_read_from_the_working_directory(tmp_path, monkeypatch): + monkeypatch.chdir(tmp_path) + assert conftest.engine_dir({"AGSC_ENGINE_DIR": "engine"}) == (tmp_path / "engine").resolve() + + +def test_the_suite_uses_the_value_of_this_run(): + import os + + assert conftest.ENGINE == conftest.engine_dir(os.environ) + assert isinstance(conftest.ENGINE, pathlib.Path) + + +#: A path to the sibling engine folder spelled out in a test, not read from ``ENGINE``. +_HARD_WIRED = re.compile(r"""(/\s*|,\s*)["']agentic-system-core["']\s*[,)/]?""") + + +def test_no_test_module_hard_wires_the_engine_path(): + # Fitness function: every test that reads the engine reads it from conftest.ENGINE, so + # AGSC_ENGINE_DIR reaches it (docs/MAINTAINING.md, "the engine checkout"). + here = pathlib.Path(__file__).parent + offenders = [path.name for path in sorted(here.glob("test_*.py")) + if path.name != pathlib.Path(__file__).name + and _HARD_WIRED.search(path.read_text(encoding="utf-8"))] + assert offenders == [] diff --git a/tests/test_equivalence.py b/tests/test_equivalence.py index a79baa8..851a095 100644 --- a/tests/test_equivalence.py +++ b/tests/test_equivalence.py @@ -4,17 +4,24 @@ engine checkout is not on this machine the whole module is skipped with a message that says so, because a silent skip would look like a pass. +The inputs are every fixture case, the built discovery files of the two sites +when their checkouts are here, and two nodes the engine builds for the run: its +own minimal fixture and, when its checkout is beside this one, the demonstration +node ``agsc-demo-node`` (with its git history, so the build writes the ledger and +the 1.1 chunk and ledger facts the checkers recompute). + Nothing in this module touches the network: every input is a file on disk. """ import json import os +import shutil import subprocess import sys import pytest -from conftest import ENGINE, SITE_DOCUMENTS, WELLKNOWN, engine_available +from conftest import ENGINE, NEIGHBOURS, SITE_DOCUMENTS, WELLKNOWN, engine_available pytestmark = pytest.mark.skipif( not engine_available(), @@ -97,3 +104,86 @@ def test_both_checkers_agree(args): python_code, python_shape = python(args) assert node_code == python_code assert node_shape == python_shape + + +@pytest.mark.parametrize("level", ["0", "1", "2", "3"]) +def test_both_checkers_agree_when_the_card_target_is_a_directory(tmp_path, level): + # A target path that names a directory is read as a target that is not served. + copy = tmp_path / "card-served" + shutil.copytree(str(WELLKNOWN / "card-served"), str(copy)) + card = copy / ".well-known" / "agent-card.json" + card.unlink() + card.mkdir() + args = [str(copy / ".well-known" / "knowledge-linkset"), "--level", level, "--json"] + python_code, python_shape = python(args) + assert python_shape is not None + assert (python_code, python_shape) == node(args) + + +#: The build instant of every node built here (docs/MAINTAINING.md, the reference builds). +SOURCE_DATE_EPOCH = "1767225600" +DEMO_NODE = NEIGHBOURS / "agsc-demo-node" + + +def _build(source, out, ignore=()): + """Copy one Bundle and build it with the engine; the discovery file it wrote.""" + shutil.copytree(str(source), str(out), ignore=shutil.ignore_patterns(*ignore)) + # The engine refuses an AGSC_* variable it does not know (AGSC-01-37), this suite's + # AGSC_ENGINE_DIR among them, and AGSC_DOI would change the bytes: the build sees + # the search path, the home folder (git reads it) and the build instant only. + environment = {"PATH": os.environ.get("PATH", ""), "HOME": os.environ.get("HOME", ""), + "SOURCE_DATE_EPOCH": SOURCE_DATE_EPOCH} + done = subprocess.run(["node", str(ENGINE / "bin" / "agsc.js"), "build"], cwd=str(out), + capture_output=True, text=True, env=environment) + assert done.returncode == 0, done.stdout[-2000:] + done.stderr[-2000:] + return out / "www" / ".well-known" / "knowledge-linkset" + + +@pytest.fixture(scope="module") +def built_nodes(tmp_path_factory): + root = tmp_path_factory.mktemp("built") + nodes = {"minimal": _build(ENGINE / "tests" / "fixtures" / "minimal", root / "minimal")} + if (DEMO_NODE / "agsc.config.json").is_file(): + nodes["agsc-demo-node"] = _build(DEMO_NODE, root / "agsc-demo-node", ("www", "dist")) + return nodes + + +@pytest.mark.parametrize("node_name", ["minimal", "agsc-demo-node"]) +@pytest.mark.parametrize("level", ["0", "1", "2", "3"]) +def test_both_checkers_agree_on_a_node_the_engine_builds(built_nodes, node_name, level): + if node_name not in built_nodes: + pytest.skip("the demonstration node is not checked out beside this repository at %s" + % DEMO_NODE) + args = [str(built_nodes[node_name]), "--level", level, "--json"] + node_code, node_shape = node(args) + python_code, python_shape = python(args) + assert (node_code, node_shape) == (python_code, python_shape) + assert node_shape is not None + + +@pytest.mark.parametrize("level", ["0", "2"]) +def test_the_known_difference_when_a_digest_target_or_the_ledger_is_a_directory( + built_nodes, tmp_path, level): + # The one difference the README names: the engine reports Node's own error name + # EISDIR, which is not a registered code, where this package reports AGSC-E901 (a + # target not found on disk). Exit code, status and counts agree. This test fails once + # the engine reports a registered code there; then the README note comes out. + if "agsc-demo-node" not in built_nodes: + pytest.skip("the demonstration node is not checked out beside this repository at %s" + % DEMO_NODE) + site = tmp_path / "www" + shutil.copytree(str(built_nodes["agsc-demo-node"].parent.parent), str(site)) + for name in ("llms.txt", "ledger.jsonl"): + (site / name).unlink() + (site / name).mkdir() + args = [str(site / ".well-known" / "knowledge-linkset"), "--level", level, "--json"] + node_code, node_shape = node(args) + python_code, python_shape = python(args) + assert node_code == python_code == 1 + assert (node_shape["status"], node_shape["counts"]) == \ + (python_shape["status"], python_shape["counts"]) + theirs = [one[3] for one in node_shape["findings"]] + ours = [one[3] for one in python_shape["findings"]] + assert theirs.count("EISDIR") == ours.count("AGSC-E901") == 3 + assert [code for code in theirs if code != "EISDIR"] == \ + [code for code in ours if code != "AGSC-E901"] diff --git a/tests/test_frontmatter.py b/tests/test_frontmatter.py index d5e076e..6aab837 100644 --- a/tests/test_frontmatter.py +++ b/tests/test_frontmatter.py @@ -147,6 +147,13 @@ def test_key_names_vendor_keys_unknown_keys_and_inverses(): assert found == [("AGSC-E204", "Bad"), ("AGSC-E207", "odd"), ("AGSC-E306", "used-by")] +def test_a_link_shaped_key_is_the_one_warning_e304_never_e207(): + """AGSC-03-03: peer-ref, mentions and the foreign names are AGSC-E304; one key, one code.""" + found = frontmatter.check(with_(**{"peer-ref": ["b"], "mentions": ["b"], "odd": "1"})) + assert sorted((one["code"], one.get("key"), one["severity"]) for one in found) == [ + ("AGSC-E207", "odd", "warn"), ("AGSC-E304", "mentions", "warn"), ("AGSC-E304", "peer-ref", "warn")] + + def test_common_key_patterns(): found = codes_of(with_(description="short", status="gone", release="Bad Slug", id="x", iri="http://x/", spec_version="1", lang="e", date="2026-1-1", @@ -273,3 +280,35 @@ def test_adoption_defaults_and_edge_cases(): ]) def test_slugify_lower_cases_a_to_z_only(stem, expected): assert frontmatter.slugify(stem) == expected + + +# --- the nesting bound of AGSC-02-02 (1.1) ----------------------------------------- + +ITEM_HEAD = ("type: concept\ntitle: Nested\ndescription: A case of the nesting bound of the frontmatter reader.\n" + "kind: term\nprov:\n origin: human\n operator: human:x\n") + + +def nested(levels): + """A frontmatter whose deepest block collection is ``levels`` deep, the mapping + itself being level 1: ``x-acme-nest`` (a vendor key) opens level 2, each further ``a:`` one more.""" + lines = ["x-acme-nest:"] + [" " * depth + "a:" for depth in range(1, levels - 1)] + lines.append(" " * (levels - 1) + "leaf: end") + return "---\n" + ITEM_HEAD + "\n".join(lines) + "\n---\nBody.\n" + + +def test_the_depth_counts_block_collections_and_not_flow_sequences(): + assert yamlsubset.depth(yamlsubset.load("a: x\n")) == 1 + assert yamlsubset.depth(yamlsubset.load("a:\n b: x\n")) == 2 + assert yamlsubset.depth(yamlsubset.load("a: [x, y]\n")) == 1 + assert yamlsubset.depth(yamlsubset.load("a:\n - x\n - b: y\n")) == 3 + assert yamlsubset.depth(yamlsubset.Mapping()) == 1 + + +def test_sixty_four_levels_are_silent_and_sixty_five_warn_and_still_read(): + data, _, findings = frontmatter.read(nested(64)) + assert [one for one in findings if one["severity"] == "warn"] == [] + data, _, findings = frontmatter.read(nested(65)) + warned = [one for one in findings if one["code"] == "AGSC-E105"] + assert [(one["severity"], one["line"]) for one in warned] == [("warn", 1)] + assert [one for one in findings if one["severity"] == "error"] == [] + assert data is not None and "x-acme-nest" in data diff --git a/tests/test_graph_jsonld.py b/tests/test_graph_jsonld.py new file mode 100644 index 0000000..7ea0491 --- /dev/null +++ b/tests/test_graph_jsonld.py @@ -0,0 +1,164 @@ +"""The ``graph.jsonld`` writer and the per-item files (AGSC-05-09, AGSC-05-06, AGSC-06-02). + +Three proofs. On fixed data, each compaction form of AGSC-05-31 the writer can meet. +Against the engine, when it is beside this repository with Node: the published context +this package ships is the bytes the engine's ``tools/gen-ns`` derives from +``ontology/agsc.ttl``, and for every graph vector that states a dataset the writer's +documents are the engine's ``toJsonLd`` and ``restrictTo``, after JCS. No network. +""" + +import json +import subprocess + +import pytest + +from agentic_system_core import context, graph +from agentic_system_core.areas import CASES_NOT_RUN +from agentic_system_core.jcs import canonicalize +from agentic_system_core.rdf import ASC, DCTERMS, IRI, RDFS, SKOS, XSD_DATETIME, Literal +from conftest import ENGINE, VECTORS, engine_available + +BASE = "https://a.example/" +ITEM = {"slug": "alpha", "type": "concept", "title": "Alpha", "lang": "en"} + + +def _node(document, iri): + return next(one for one in document["@graph"] if one["@id"] == iri) + + +# --- on fixed data -------------------------------------------------------------- + +def test_the_published_context_is_one_jcs_object_with_one_lf(): + raw = context.published_bytes() + assert raw.endswith(b"\n") and not raw.endswith(b"\n\n") + assert canonicalize(json.loads(raw)) + "\n" == raw.decode("utf-8") + assert context.published()["@context"]["@version"] == 1.1 + + +def test_one_value_is_bare_and_several_are_sorted(): + items = [dict(ITEM, aliases=["Zeta", "Beta"]), {"slug": "beta", "type": "concept", + "title": "Beta", "related": ["alpha"]}] + node = _node(graph.to_jsonld(items, BASE), BASE + "concepts/alpha/") + assert node["@type"] == "Concept" + assert node["inScheme"] == BASE + assert node["related"] == BASE + "concepts/beta/" + assert node["altLabel"] == [{"@language": "en", "@value": "Beta"}, + {"@language": "en", "@value": "Zeta"}] + + +def test_a_document_without_a_context_url_names_none(): + document = graph.to_jsonld([ITEM], BASE) + assert "@context" not in document + named = graph.to_jsonld([ITEM], BASE, context_url=context.CONTEXT_URL) + assert named["@context"] == context.CONTEXT_URL + + +def test_a_typed_literal_under_its_own_datatype_is_its_lexical_form(): + node = _node(graph.to_jsonld([dict(ITEM, date="2026-01-01")], BASE), BASE + "concepts/alpha/") + assert node["created"] == "2026-01-01T00:00:00Z" + + +def test_each_compaction_form_without_a_term(): + table = graph.compaction_table(context.published()) + assert graph.compact_name(ASC + "warrant", table) == "asc:warrant" + assert graph.compact_name("https://site.example/ns#thing", table) == "https://site.example/ns#thing" + assert graph.compact_name(SKOS + "prefLabel", table) == "prefLabel" + term = table["terms"][SKOS + "related"] + assert graph.json_value(IRI(RDFS + "Class"), term, table) == "rdfs:Class" + assert graph.json_value(IRI(BASE), None, table) == {"@id": BASE} + assert graph.json_value(Literal("x", datatype=XSD_DATETIME), term, table) == \ + {"@type": "xsd:dateTime", "@value": "x"} + untyped = table["terms"][DCTERMS + "title"] + assert graph.json_value(Literal("x", datatype=XSD_DATETIME), untyped, table) == \ + {"@type": "xsd:dateTime", "@value": "x"} + assert graph.json_value(Literal("x"), untyped, table) == "x" + assert graph.json_value(Literal("x", lang="en"), untyped, table) == \ + {"@language": "en", "@value": "x"} + + +def test_a_per_item_file_takes_each_node_from_the_whole_graph(): + items = [ITEM, {"slug": "beta", "type": "concept", "title": "Beta", "requires": ["alpha"]}] + whole = graph.to_jsonld(items, BASE) + single = graph.to_jsonld([ITEM], BASE) + one = graph.restrict_to(whole, single) + assert [node["@id"] for node in one["@graph"]] == [BASE + "concepts/alpha/"] + assert one["@graph"][0]["isRequiredBy"] == BASE + "concepts/beta/" + lone = {"@graph": [{"@id": "https://b.example/"}]} + assert graph.restrict_to(whole, lone) == lone + + +# --- against the engine ----------------------------------------------------------- + +needs_engine = pytest.mark.skipif( + not (engine_available() and (ENGINE / "tools" / "gen-ns").is_file() + and (ENGINE / "src" / "knowledge" / "jsonld.js").is_file()), + reason="the JSON-LD parity proof needs Node and the engine checkout beside this one", +) + +def _states_a_dataset(vector): + """Items and a base, and not a domain-layer case (a site vocabulary or a warrant + adds triples the engine alone writes in 1.1, CASES_NOT_RUN).""" + given = vector["input"] + base = (given.get("site") or {}).get("base") or given.get("base") + return isinstance(given.get("items"), list) and base is not None \ + and vector["id"] not in CASES_NOT_RUN + + +#: The graph vectors that state a dataset. +DATASETS = sorted(one for one in (VECTORS / "graph").glob("*.json") + if _states_a_dataset(json.loads(one.read_bytes()))) + +_SCRIPT = r""" +const path = require('node:path'); +const fs = require('node:fs'); +const crypto = require('node:crypto'); +const ROOT = process.argv[1]; +const jsonld = require(path.join(ROOT, 'src/knowledge/jsonld.js')); +const turtle = require(path.join(ROOT, 'src/knowledge/turtle.js')); +const jcs = require(path.join(ROOT, 'src/knowledge/jcs.js')); +const links = require(path.join(ROOT, 'src/knowledge/links.js')); +const input = JSON.parse(fs.readFileSync(process.argv[2], 'utf8')).input; +const context = jsonld.context( + turtle.ontologyTerms(fs.readFileSync(path.join(ROOT, 'ontology', 'agsc.ttl'), 'utf8')), + jsonld.allExternalProperties()); +// The inline-link edges are resolved by the Links module and injected, as the build does. +const mentions = links.resolve(input.items.map((item) => ({ ...item, path: `content/concepts/${item.slug}.md` }))) + .edges.filter((edge) => edge.key === 'mentions' && edge.source !== edge.target) + .map((edge) => ({ source: edge.source, target: edge.target })); +const options = { mentions, base: (input.site && input.site.base) || input.base, context, + contextUrl: input.context_url, + sha256: (bytes) => crypto.createHash('sha256').update(bytes).digest('hex'), + ...(input.bundle ? { bundle: input.bundle } : {}), + ...(input.attachment_bytes ? { attachmentBytes: input.attachment_bytes } : {}) }; +const whole = jsonld.toJsonLd(input.items, options); +const out = { whole: jcs.canonicalize(whole), per_item: {} }; +for (const item of input.items) { + out.per_item[item.slug] = jcs.canonicalize(jsonld.restrictTo(whole, jsonld.toJsonLd([item], options))); +} +process.stdout.write(JSON.stringify(out)); +""" + + +@needs_engine +def test_the_shipped_context_is_the_one_the_engine_derives(tmp_path): + done = subprocess.run(["node", str(ENGINE / "tools" / "gen-ns"), "--quiet", "--out", + str(tmp_path)], capture_output=True, cwd=str(ENGINE)) + assert done.returncode == 0, done.stderr[-2000:] + assert (tmp_path / "context.jsonld").read_bytes() == context.published_bytes() + + +@needs_engine +@pytest.mark.parametrize("path", DATASETS, ids=[one.stem for one in DATASETS]) +def test_the_writer_agrees_with_the_engine(path): + done = subprocess.run(["node", "-e", _SCRIPT, str(ENGINE), str(path)], + capture_output=True, text=True, cwd=str(ENGINE)) + assert done.returncode == 0, done.stderr[-2000:] + theirs = json.loads(done.stdout) + given = json.loads(path.read_bytes())["input"] + base = (given.get("site") or {}).get("base") or given.get("base") + arguments = (base, given.get("bundle"), given.get("attachment_bytes")) + whole = graph.to_jsonld(given["items"], *arguments, context_url=given.get("context_url")) + assert canonicalize(whole) == theirs["whole"] + for item in given["items"]: + single = graph.to_jsonld([item], *arguments, context_url=given.get("context_url")) + assert canonicalize(graph.restrict_to(whole, single)) == theirs["per_item"][item["slug"]] diff --git a/tests/test_graph_site.py b/tests/test_graph_site.py index aac7b89..98c30e5 100644 --- a/tests/test_graph_site.py +++ b/tests/test_graph_site.py @@ -154,6 +154,33 @@ def test_security_txt_every_fault(): assert text is not None and found[0]["severity"] == "warn" +def test_security_txt_policy_follows_the_declared_disclosure_page(): + # AGSC-06-36 as amended for 1.1 (build-0035): a declared page wins over /legal/, + # and an authored Policy wins over both. + good = "Contact: mailto:a@b\n" + base = "https://a.example/" + now = "2026-01-01T00:00:00Z" + page = "https://a.example/disclosure/" + assert site.security_txt(good, now, base, True, policy=page)[0].endswith( + "Policy: https://a.example/disclosure/\n") + assert site.security_txt(good, now, base, False, policy=page)[0].endswith( + "Policy: https://a.example/disclosure/\n") + assert site.security_txt(good, now, base, True, policy="")[0].endswith( + "Policy: https://a.example/legal/\n") + kept = site.security_txt(good + "Policy: p\n", now, base, True, policy=page)[0] + assert "Policy: p\n" in kept and "disclosure" not in kept + assert "Policy" not in site.security_txt(good, now, base, False)[0] + + +def test_the_now_line_of_a_restricted_node_states_neither_version_nor_fingerprint(): + # AGSC-06-22 with AGSC-11-20 (build-0036). + line = site.now_line("v1", "2026-01-01T00:00:00Z", "f" * 64, "1.0.0") + assert line.startswith("content version v1, built at 2026-01-01T00:00:00Z, fingerprint ") + assert site.now_line("v1", "2026-01-01T00:00:00Z", "f" * 64, "1.0.0", + visibility="restricted") \ + == "built at 2026-01-01T00:00:00Z, specification 1.0.0" + + def test_content_version_branches_and_ledger_kinds(): log = [{"sha": "a" * 40, "tag": "bad tag"}, {"sha": "b" * 40}] assert site.content_version(log, 5)[0] == "0.0.0+2.gbbbbbbbbbbbb" @@ -176,6 +203,25 @@ def test_llms_files_neutralise_comment_closers_and_handle_cluster_items(): assert discovery.reachability("- [x](y): z\n") == {} +def test_llms_txt_1_1_order_escapes_and_the_restricted_header(): + # AGSC-06-13a as amended for 1.1 (disc-0024, disc-0034): the blockquote follows the + # H1, the provenance comment follows the blockquote, a link line escapes the + # backslash, `[`, `]` and `(`, and a restricted node has no bundle_version line. + bundle = {"base": "https://a.example/", "title": "T", "description": "D"} + items = [{"slug": "i", "title": "A [b] (c)\\", "description": "x](y"}] + text = discovery.llms_txt(bundle, items, bundle_version="v1", generated_at="G") + assert text.startswith("# T\n\n> D\n\n