diff --git a/docs/architecture/05-building-block-view.md b/docs/architecture/05-building-block-view.md index 25652a8..dd3b9e6 100644 --- a/docs/architecture/05-building-block-view.md +++ b/docs/architecture/05-building-block-view.md @@ -144,8 +144,9 @@ The brief is what an adopter would type: - the domain in one line, naming discount rules, tax jurisdictions and customers -- the stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite, uv, ruff, mypy - strict, pytest +- the stack the spec fixes: Python 3.12, Flask 3, Jinja, HTMX, SQLite; no + tooling, which is the project's own choice and would reach only the arms + that copy it - personal data: customers are people with a name, email and address; the GDPR applies, so a customer may ask for erasure or a copy of their data; one administrator signs in diff --git a/docs/coverage.md b/docs/coverage.md index b9b0081..1628ac1 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -187,6 +187,7 @@ when: | FR-13-04 | Self-test | `archive.py` "a reading changed after the stamp is a problem"
`archive.py` "the report refuses docs/audits/ without a current stamp"
`report.py` "a report into a templates source's docs/audits needs the stamp" | | FR-13-05 | Self-test | `archive.py` "the restored root reads as the original does"
`archive.py` "a restored record points at the restored tarball and void"
`archive.py` "a restored transcript keeps its time" | | FR-13-06 | Self-test | `generate_arm.py` "the two map arms name the same moments in the chain's order"
`generate_arm.py` "the reading map names every template of the chain once, under docs/solid-ai-templates/"
`generate_arm.py` "each template skill is its template verbatim, named by the manifest"
`generate_arm.py` "a chain file the manifest does not describe is refused" | +| FR-13-07 | Self-test | `generate_arm.py` "every fixed-text root opens with the brief, verbatim"
`generate_arm.py` "the brief and the facts name the stack and no tooling" | ## 14 One run at a time diff --git a/docs/requirements.md b/docs/requirements.md index 9a3e740..ab4950e 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -194,7 +194,8 @@ | FR-13-03 | The benchmark shall archive every reading, judging, map and lock, with a hash per file, and fail the verify on a changed one. | Archive | | FR-13-04 | The benchmark shall refuse to write a report under `docs/audits/` once a reading changed since the archive was verified. | Archive, Report | | FR-13-05 | The benchmark shall restore an archive so it reads as the original root does, its records pointing at the restored files. | Archive | -| FR-13-06 | The benchmark shall build a map arm's root from the chain and the templates' manifest alone, the same moments in the same order for both map arms, and each `lazyskills` skill holding one template verbatim. | Arm generator | +| FR-13-06 | The benchmark shall build a map arm's root from the brief, the chain and the templates' manifest alone, the same moments in the same order for both map arms, and each `lazyskills` skill holding one template verbatim. | Arm generator | +| FR-13-07 | The benchmark shall give every arm's root the same project facts: the brief, which names the stack the spec fixes and no tooling. | Arm generator | ### 14 One run at a time diff --git a/tests/efficacy/brief.txt b/tests/efficacy/brief.txt index ebbc8c1..21bbf3d 100644 --- a/tests/efficacy/brief.txt +++ b/tests/efficacy/brief.txt @@ -1,8 +1,7 @@ `tariff` — Imbra Ltd — a pricing and invoicing web application: a product catalog, discount rules of several kinds, tax jurisdictions, customers, and invoices assembled from them — Python 3.12 / Flask 3 / -Jinja / HTMX / SQLite — uv, ruff, mypy strict, pytest — runs locally, no -deployment target +Jinja / HTMX / SQLite — runs locally, no deployment target Personal data: customers are people, stored with their name, email and postal address and named on the invoices billed to them. The business is diff --git a/tests/efficacy/generate_arm.py b/tests/efficacy/generate_arm.py index 01e526c..4bfef12 100644 --- a/tests/efficacy/generate_arm.py +++ b/tests/efficacy/generate_arm.py @@ -176,10 +176,15 @@ def record_path(arm): % (VENDORED["into"], VENDORED["path"], VENDORED["path"])), } -# The `reference` arm's whole file: the chain named, nothing copied in. +# The `reference` arm's whole file: the brief, then the chain named, no rule +# copied in. Every arm's root states the same project facts, so the arms +# differ in how they hand over the rules and in nothing the project says of +# itself. REFERENCE = """\ # tariff +{brief} + Before starting work, read each template below and apply every rule it holds that fits this project. They are vendored at `{into}/`, at the revision the project adopted. @@ -198,9 +203,8 @@ def record_path(arm): "{{owner}}": "Imbra Ltd", "{{repository}}": "this repository", "{{the commands to build, test and run the project}}": - "Python 3.12, Flask 3, Jinja, HTMX and SQLite, managed with uv; " - "check with ruff, mypy strict and pytest. It runs locally; there is " - "no deployment target.", + "Python 3.12, Flask 3, Jinja, HTMX and SQLite; the brief names no " + "tooling. It runs locally; there is no deployment target.", "{{approver}}": "not stated in the brief", "{{tracker}}": "not stated in the brief", "{{release}}": "not stated in the brief; the application runs locally", @@ -338,11 +342,13 @@ def build_prompt(tree, arm, files): read_chain(tree, files)) -def reference_text(files): - """The `reference` arm's file for a chain, the same for the same chain.""" +def reference_text(files, brief): + """The `reference` arm's file for a chain and a brief, the same for the + same two.""" listed = "\n".join("- `%s/%s`" % (VENDORED["into"], name) for name in files) - return REFERENCE.format(into=VENDORED["into"], files=listed) + return REFERENCE.format(brief=brief.strip(), into=VENDORED["into"], + files=listed) # The templates' manifest: one entry per template, with the file it lives in @@ -399,10 +405,13 @@ def moments(tree, files): # The map arms' root file. The two differ in one column and one verb: what # the agent does when a moment arrives, read a vendored file or load a skill. # Everything before the table says the same thing in both, so the arms -# measure the mechanism and not the wording. +# measure the mechanism and not the wording. The brief comes first, as in +# every arm's root. MAP = """\ # tariff +{brief} + {paragraph} | When the work first touches | {column} | @@ -431,9 +440,9 @@ def moments(tree, files): } -def map_text(rows, load): - """A map arm's root file: the same moments, in the same order, for - either way of loading.""" +def map_text(rows, load, brief): + """A map arm's root file for a brief: the same moments, in the same + order, for either way of loading.""" words = MAP_LOAD[load] into = VENDORED["into"] table = "\n".join( @@ -443,7 +452,8 @@ def map_text(rows, load): paragraph = textwrap.fill( MAP_PARAGRAPH.format(when=words["when"], act=words["act"].format(into=into)), width=79) - return MAP.format(paragraph=paragraph, column=words["column"], rows=table) + return MAP.format(brief=brief.strip(), paragraph=paragraph, + column=words["column"], rows=table) def template_skills(tree, rows): @@ -581,9 +591,22 @@ def self_test(): return 1 print("the leak scan reports a planted token and passes clean text") + # The brief and the emitter's facts name the stack the spec fixes and no + # tooling: a tool the project chose would reach only the arms that copy + # it, and the arms would then differ in what they were told. + tooling = ("mypy", "ruff", "pytest", "uv,", " uv ", "uv;") + told = [read_brief()] + list(FACTS.values()) + named = [tool for tool in tooling for fact in told if tool in fact] + if named or "Python 3.12" not in told[0]: + print("FAIL: the brief or the facts name tooling, or drop the " + "stack: %r" % named) + return 1 + print("the brief and the facts name the stack and no tooling") + files = ["templates/core/quality.md", "templates/backend/api.md"] - text = reference_text(files) - if text != reference_text(files) or not all( + planted_brief = "`tariff` - a planted brief - Python 3.12 / Flask 3\n" + text = reference_text(files, planted_brief) + if text != reference_text(files, planted_brief) or not all( "`%s/%s`" % (VENDORED["into"], f) in text for f in files): print("FAIL: the reference text is not the chain under the vendored " "path, the same every time") @@ -615,8 +638,18 @@ def self_test(): " - id: backend-api\n file: templates/backend/api.md\n" " description: API-first, contracts, versioning\n") rows = moments(tree, chain) - reading = map_text(rows, "read") - loading = map_text(rows, "skill") + reading = map_text(rows, "read", planted_brief) + loading = map_text(rows, "skill", planted_brief) + + # Every root the generator builds from fixed text states the same + # project facts as the model arms are given: the brief, verbatim, + # under the title and before any rule. + opening = "# tariff\n\n%s\n" % planted_brief.strip() + if not all(root.startswith(opening) + for root in (text, reading, loading)): + print("FAIL: a fixed-text root does not open with the brief") + return 1 + print("every fixed-text root opens with the brief, verbatim") first = [line.split(" | ")[0] for line in reading.splitlines() if line.startswith("| ") and not line.startswith("| ---")] second = [line.split(" | ")[0] for line in loading.splitlines() @@ -752,13 +785,13 @@ def main(argv): record["resolved_files"] = files skills = {} if entry["kind"] == "fixed": - document = reference_text(files) + document = reference_text(files, read_brief()) elif entry["kind"] == "emit": document, skills = emit_arm(tree, ROUND5_ROOTS) record["declined"] = ROUND5_DECLINED elif entry["kind"] == "map": rows = moments(tree, files) - document = map_text(rows, entry["load"]) + document = map_text(rows, entry["load"], read_brief()) if entry["load"] == "skill": skills = template_skills(tree, rows) record["load"] = entry["load"]