feat(consume): carry every source_* key by prefix, and generate a skill per bundle
Two changes, one theme: what a reader needs in order to cite is a property of
the PRODUCER, so neither the excerpt nor the skill may hard-code a list of the
producers someone thought of.
The pass-through rule is now the `source_` PREFIX, not the five keys this
library writes. Measured on the N500 bundle currently on disk: 269 of 274
concepts carry `source_element_id`, a locator that repository chose under this
chain's own rule ("the key says what it indexes") and that this library never
writes. The allowlist dropped it, and an excerpt that names a document without
naming the place in it is the defect this work exists to close. A prefix and
never a substring - `resource_owner` contains the literal and is not a locator,
and promoting it would be fabricated provenance produced by a matching bug. The
known-negative is tested: `bundle_id`, `type` and `ingested_at` do not travel.
Contract 8.5 states the rule as a prefix rather than a list.
K2 control, re-measured against the frozen tool at b6a8c8b, same question and
same k: the RANKING is untouched - same 8 ids in the same order, identical
`text_sha256`, identical `withheld`, denominators 629 = 621 + 8. The FIELD moved:
payload 108 877 -> 113 143 B (+3.92 %), spent 18 606 -> 22 210 (+450.5 B per
excerpt), excerpt members 9 -> 17, 99 changed lines. Known-positive follows the
contract document's bytes again: 12 049 -> 12 563 measured, 11 719 -> 12 227
raw, delta 330 -> 336.
`tools/okf_skill.py` instantiates the template for one bundle: id, ref, concept
count, the conditional-field table with a denominator per field (the `source_*`
rows DISCOVERED from the bundle, not listed), the whole-bundle cost by the gate's
own instrument, the share one measured answer spent, the concept count at which
the withheld bookkeeping alone reaches the limit, and the index-walk-against-
directory control - run once at generation time, never on the question path.
The form was chosen on a measurement that came out against the obvious gate:
the contract checker passes the UNFILLED template against a real payload, and
passes a skill built for a different bundle against this one's. It cannot tell
the two forms apart, so conformance could not decide it. What decides it is that
5's denominators, 6.4's conditional fields and 7.6's breaking point are
per-bundle numbers - a generic skill either leaves them as holes (the template's
own definition of unfinished) or states another corpus's numbers, which is worse
than a gap. Every gate the checker lacks is therefore a test here: no placeholder
survives, the skill names its own bundle's id and ref and not another's, its
commands are absolute and point at files that exist, and it refuses a directory
with no index (exit 1, `bundle_unreadable`), an index with no `bundle_id`
(`bundle_id_missing`), an empty bundle, and an occupied target without --force.
It lives in `tools/` for the reason `okf_consume.py` and `okf_contract_check.py`
state for themselves - outside `src/`, so no consumer's install surface changes -
and because a wheel-installed `okf skill` would emit a command pointing at
`tools/okf_consume.py`, which the wheel does not contain.
Suite 1372 (1347 before), ruff clean, mypy src clean.
Co-Authored-By: Claude <claude-opus-5>
This commit is contained in:
parent
17c49fc04b
commit
c95d18905a
9 changed files with 957 additions and 44 deletions
|
|
@ -155,7 +155,7 @@ other states is a claim about the fixture rather than about this corpus.
|
|||
| Limit | `120000` |
|
||||
| Unit | `utf-8 bytes of emitted JSON` |
|
||||
| Instrument | `okf_consume.measure` — `len(json.dumps(value, ensure_ascii=False).encode("utf-8"))` |
|
||||
| Known-positive | `docs/consumption-contract.md, encoded as a JSON string` at `12049` |
|
||||
| Known-positive | `docs/consumption-contract.md, encoded as a JSON string` at `12563` |
|
||||
|
||||
The instrument reproduces the known-positive figure before any of its own
|
||||
numbers are believed. Report what the run actually spent.
|
||||
|
|
@ -164,8 +164,8 @@ The known-positive is a **shipped artefact rather than this bundle**, and the
|
|||
reason is that a per-bundle one cannot work: it would be either a constant wrong
|
||||
for every bundle but one, or the instrument's own output, which makes
|
||||
`expected == measured` true by construction and § 7.4 decorative. It is checked
|
||||
by a **second, independent route**: `wc -c` reports 11 719 raw bytes for the same
|
||||
file, and the 330-byte difference is that file's JSON quoting and escaping
|
||||
by a **second, independent route**: `wc -c` reports 12 227 raw bytes for the same
|
||||
file, and the 336-byte difference is that file's JSON quoting and escaping
|
||||
overhead. The delta moves the moment the instrument changes what it counts.
|
||||
|
||||
`spent` is the cost of the **delivered set**, per § 7.2 — not of the whole
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
"unit": "utf-8 bytes of emitted JSON",
|
||||
"instrument": "okf_consume.measure (len of the ensure_ascii=False JSON encoding, utf-8)",
|
||||
"limit": 120000,
|
||||
"spent": 1774,
|
||||
"spent": 2125,
|
||||
"known_positive": {
|
||||
"case": "docs/consumption-contract.md, encoded as a JSON string",
|
||||
"expected": 12049,
|
||||
"measured": 12049,
|
||||
"raw_bytes": 11719,
|
||||
"encoding_delta": 330
|
||||
"expected": 12563,
|
||||
"measured": 12563,
|
||||
"raw_bytes": 12227,
|
||||
"encoding_delta": 336
|
||||
}
|
||||
},
|
||||
"denominators": {
|
||||
|
|
@ -38,6 +38,8 @@
|
|||
"title": "veiledning.md"
|
||||
}
|
||||
],
|
||||
"source_file": "veiledning.md",
|
||||
"source_sha256": "6906ec0acbcfc246e825bda9863c716eb5611b465020e8204eeb448c32343f7d",
|
||||
"source_lines": "[5, 8]",
|
||||
"source_offset": "[94, 176]",
|
||||
"text_sha256": "08447c690087834883a78fb9f40d474c68b2526ed57d0dafe01c4868db3c04f0",
|
||||
|
|
@ -58,6 +60,8 @@
|
|||
"title": "veiledning.md"
|
||||
}
|
||||
],
|
||||
"source_file": "veiledning.md",
|
||||
"source_sha256": "6906ec0acbcfc246e825bda9863c716eb5611b465020e8204eeb448c32343f7d",
|
||||
"source_lines": "[1, 4]",
|
||||
"source_offset": "[0, 94]",
|
||||
"text_sha256": "82d67ff01367a1a56532130e077956048004ac047e6062eae2143d96704c4a92",
|
||||
|
|
@ -78,6 +82,8 @@
|
|||
"title": "veiledning.md"
|
||||
}
|
||||
],
|
||||
"source_file": "veiledning.md",
|
||||
"source_sha256": "6906ec0acbcfc246e825bda9863c716eb5611b465020e8204eeb448c32343f7d",
|
||||
"source_lines": "[9, 11]",
|
||||
"source_offset": "[176, 253]",
|
||||
"text_sha256": "4c181e1debb141d3cb1a7bd47249fdac1c0b2c5db1b47cf255ef8f04f83ec840",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue