diff --git a/docs/architecture/05-building-block-view.md b/docs/architecture/05-building-block-view.md index 9edfa97..7c27d48 100644 --- a/docs/architecture/05-building-block-view.md +++ b/docs/architecture/05-building-block-view.md @@ -15,7 +15,7 @@ dependency with its keyword. | Block | Responsibility | Reads | Writes | | ----- | -------------- | ----- | ------ | -| `generate_arm.py` | Makes one arm's file once: fixed text, one non-interactive generation from `agents.md`, or the emitter. Scans prompt and output for leaks | `brief.txt`, the templates source | `arms//CLAUDE.md`, `generation.json` | +| `generate_arm.py` | Makes one arm's file once: fixed text, one non-interactive generation from `agents.md`, under a line budget where the arm has one, or the emitter. Scans prompt and output for leaks, and refuses a file over its budget | `brief.txt`, the templates source | `arms//CLAUDE.md`, `generation.json` | | `harness.py` | Prepares each workspace, runs the agent in isolation, catches reach, freezes the result, keeps the run record current | The specs, the arm files, the change prompt | The run root | | `reuse.py` | Copies an earlier round's trials and readings into a new root, with their tool lock | An earlier root | The run root, the scoring area | | `progress.py` | Watches a run: one bar per arm, its voided tries, its cost and the trial running, redrawn every 30 s. Read-only | The run records | The console | @@ -87,7 +87,7 @@ Every arm starts from an empty git repository holding `SPEC.md`. All but |---|---|---|---| | `none` | nothing: the bare agent | — | the baseline every file is compared with | | `full` | the file the interview generates, inline | none | do the templates help as shipped | -| `short` | the file the interview generates, inline, under a budget | ≤ 40 lines, ≤ 88 characters wide | does a short generated file help | +| `short` | one generation from `agents.md`, inline, under a budget | ≤ 40 lines, ≤ 88 characters wide | does a short generated file help | | `hybrid` | the file the interview generates in its hybrid model, with the templates vendored into the workspace | none | does the model the owner's projects use help | | `hand` | a hand-written file | ≤ 40 lines | is the effect the templates, or merely having a file | diff --git a/docs/rounds/README.md b/docs/rounds/README.md index c48ea82..cce1662 100644 --- a/docs/rounds/README.md +++ b/docs/rounds/README.md @@ -11,6 +11,7 @@ trial of that round has run. The rules every round shares are in | [Round 5](round-5.md) | 2026-10-26, amended 2026-10-27, 2026-10-28 and 2026-10-29; stopped after its first start | Which way of delivering the rules gives the best and most consistent code | | [Round 5b](round-5b.md) | 2026-10-29, after round 5 stopped; stopped after its first start | Round 5's question, with a prompt that tells every arm the spec is the approved plan | | [Round 5c](round-5c.md) | 2026-10-29, after round 5b stopped | Round 5b's question, with each trial's workspace in a pen of its own | +| [Round 5d](round-5d.md) | 2026-10-31, while round 5c ran | Whether a person's short file does what the templates do, at their length and at its own | ## Reports @@ -27,3 +28,4 @@ repository existed. | 5 | Stopped 2026-10-29, after four trials | Context file: how the rules are delivered | — | | 5b | Stopped 2026-10-29, after four trials | Context file: how the rules are delivered | — | | 5c | Not run yet | Context file: how the rules are delivered | — | +| 5d | Not run yet | Context file: a hand-written one and a 40-line one, against 5c | — | diff --git a/docs/rounds/round-5d.md b/docs/rounds/round-5d.md new file mode 100644 index 0000000..001f91b --- /dev/null +++ b/docs/rounds/round-5d.md @@ -0,0 +1,160 @@ +# Round 5d registration + +Registered on 2026-10-31, while round 5c ran and before any round-5d trial ran. +Round 5c keeps its registration as it was when its first trial ran; this one is +a registration of its own. + +## 13d. Round 5d: a person's file and a 40-line file, against round 5c + +### 13d.1 What it takes from round 5c + +Round 5d runs [round 5c's registration](round-5c.md) as it stood at `07d1641`: +block A, the spec at its registered sha256, `claude-sonnet-5` at effort `high`, +round 5b's prompt, the pen, the judge, the scoring and the code size rows, and +the margins of round 5's H1. + +Three things differ: the arms, the order, and a reuse of round 5c's `none`. + +### 13d.2 The arms + +| Arm | Trials | Where they come from | +| --- | --- | --- | +| `hand` | 15, fresh | `tests/efficacy/arms/hand/CLAUDE.md` as it is at `010ee36` | +| `short` | 15, fresh | `tests/efficacy/arms/short/CLAUDE.md`, made for 5d | +| `none` | 3, fresh | The bare agent, as a check on drift | +| `none`, from 5c | 15, reused | Round 5c's `none-1` to `none-15`, scored and read | + +**`hand`** is a person's file, written for round 3's brief. + +- 39 lines and 1,376 bytes, sha256 + `25459854949f648837ac5ef37fca5d7472923b544dffb694cd40f8b8a53ec748`. +- Kept verbatim. It is not edited for round 5's brief. + +**`short`** is round 3's arm made again from round 5's chain. + +- One generation by `claude-sonnet-5` at effort `high`, in `agents.md`'s inline + model, from the templates at `9086e0ff`, the brief and round 5's roots, with + no interview: the way `inline` was made. +- Held to round 3's budget: at most 40 lines, none over 88 characters. The + generator refuses a file over either bound rather than trimming it. +- 40 lines and 2,173 bytes, sha256 + `8abbcf098312e768e5e01fb6266ec230c13877fa71f40a0bc3ec06e89cd63aea`, with its + generation record beside it. +- It replaces round 3's file, made from round 1's templates. An earlier round + is re-run from the benchmark at its own commit, so its files need not stay. + +**The reused `none`** comes with round 5c's tool lock, so both rounds are +measured with one ruler. + +Why `hand`: it is the only arm that separates the templates from having a file +at all (the decision of 2026-09-12). Round 5 left it out because each of its +arms is made from the templates at `9086e0ff`, and a person's file is not. + +Why `short`: round 5c's templates files are 22 to 57 KB, and `hand` is 1.4 KB, +so `hand` against them changes the content and the size at once. `short` and +`hand` sit within a line of each other, so `short` minus `hand` compares the +content at one length, as round 2's `short` minus `hand` did. + +### 13d.3 The order + +Two runs, in one run root of round 5d's own: + +| Run | Arms | Trials, in order | +| --- | --- | --- | +| 1 | `none`, `hand`, `short`, K = 3 | the rotated order, 9 trials | +| 2 | `hand`, `short`, K = 15, from `short-4` | blocks 4 to 15, 24 trials | + +- Run 1 starts `none-1`, `hand-1`, `short-1`, and each block starts one arm + later. +- `hand` and `short` share every block, so `short` minus `hand` is paired. +- The fresh `none` trials share blocks 1 to 3 with them, so they see the same + days as the round's start. +- Drift after block 3 goes unchecked for the contrasts with round 5c. The CLI + is pinned (13d.5), which holds the one source of drift known to have moved. + +Why the pin: the Claude CLI updated itself from 2.1.312 to 2.1.314 at 03:13 on +2026-10-30, in the middle of round 5c. Round 5c's interleaving spreads that +across its arms. Round 5d runs days later, so nothing would spread a further +update across the two rounds. + +### 13d.4 Hypotheses + +A contrast with a round 5c arm is unpaired: they never ran in one block. An +unpaired interval is wider than the paired one round 5 sized K on, so at K = 15 +a row is harder to show as held. + +**The drift check.** Round 5c's `none` stands in for a `none` run beside the +round's arms. + +| | | +| --- | --- | +| Measure | each fresh `none` trial against round 5c's 15 | +| Holds | each trial's primary rows sit within the range of 5c's 15 | +| Fails | H4 and H5 read inconclusive, and the report says why | + +**H4, a file at all.** A person's short file improves on no file. + +| | | +| --- | --- | +| Contrast | `hand` minus round 5c's `none`, unpaired | +| Primary rows | as round 5's H1 | +| Supported | some primary row is better, and none is worse | +| Refuted | any primary row is worse | +| Otherwise | inconclusive | + +**H5, the templates against a person's file.** Each templates arm, `inline`, +`hybrid`, `reference` and `skills`, delivers at least what a person's file +delivers. + +| | | +| --- | --- | +| Contrast | each templates arm of round 5c, minus `hand`, unpaired | +| Primary rows | as round 5's H1 | +| Supported, per arm | every primary row is held or better | +| Refuted, per arm | any primary row is worse | + +**H6, the templates' content at a person's length.** A 40-line file from the +templates delivers at least what a person's file of the same length delivers. + +| | | +| --- | --- | +| Contrast | `short` minus `hand`, paired within the block | +| Primary rows | as round 5's H1 | +| Supported | every primary row is held or better | +| Refuted | any primary row is worse | + +**Secondary, no verdict:** every metric of [ch. +8.6](../architecture/08-crosscutting-concepts.md) for `hand` and `short` +against round 5c's `none`; `short` against round 5c's `inline`, the same +generation without the budget; the fresh `none` against round 5c's `none`; +cost, turns, tokens and wall time; and the words each arm puts in context on +every turn, beside each 5c arm's. + +### 13d.5 Before the first trial + +Done with this registration: + +- `generate_arm.py` makes `short` under its budget, and refuses a file over it +- `short` is generated and committed with its record +- the harness reads `short` from its new file +- the report already computes H6's contrast, `short` minus `hand`, paired, as + it did for round 2 + +The harness and the report still gain, each with a self-test: + +- K up to 15 for a run of `hand` and `short`, with round 5's spec check; today + a run with no round-5 arm is capped at K = 5 and its spec is not checked +- the Claude CLI pinned at 2.1.314 for the round, with auto-update off and the + version recorded on every trial +- round 5c's `none` trials read with their scores, judgings, security readings + and tool lock, kept apart from round 5d's `none-1` to `none-3`, whose names + they share +- the unpaired contrasts of H4 and H5, and the drift check + +### 13d.6 When it runs + +After round 5c's last trial is in, scored and judged. Its 33 trials take about +22 hours at round 5c's pace and spend the plan's limit, so the run waits for +the owner's go. + +Nothing in this registration changes once a round-5d trial has run. diff --git a/tests/efficacy/arms/short/CLAUDE.md b/tests/efficacy/arms/short/CLAUDE.md index 960265d..b17acb2 100644 --- a/tests/efficacy/arms/short/CLAUDE.md +++ b/tests/efficacy/arms/short/CLAUDE.md @@ -1,39 +1,40 @@ -# tariff — CLAUDE.md - -Owner: Imbra Ltd. Pricing and invoicing web app: catalog, discounts, tax, invoices. -Stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite. Tools: uv, ruff, mypy strict, pytest. -Runs locally; no deployment target; nothing reaches the network. - -## Structure -- The pricing engine is a library that imports without Flask; Flask is one caller. -- Flask app uses `create_app()`, blueprints, thin routes; logic lives in services. -- Layout is in README.md; do not duplicate it here. - -## Personal data (GDPR) -- Customers hold name, email, postal address; invoices name them. -- Support erasure and export of one customer's data; keep invoice totals intact. -- Never log or print personal data; never put it in fixtures, commits or errors. -- One administrator signs in; CSRF on every state-changing request. - -## Code -- Money is integer cents or Decimal, never float; timestamps in UTC. -- Errors raised on purpose derive from one package base error. -- Parameterized SQL only; migrations versioned, never edited once merged. -- HTMX endpoints return partials when `HX-Request` is set; 422 on invalid forms. -- Config from environment, validated at startup; `.env` is never committed. -- Names carry meaning; no debug prints, no commented-out code. - -## Quality -- Gates: `ruff check`, `ruff format`, `mypy --strict`, `pytest`; all must pass. -- Test the engine without Flask; use a real SQLite file, not a mock. -- Every public function has type hints and a Google-style docstring. - -## Git -- Work on a branch, never on `main`; conventional commit prefixes, subject under 80. -- Update README, CLAUDE.md and docs in the same commit as the change. - -## Off-limits without an approved plan -- Auth and session code, migrations, `.env*`, and invoice export formats. -- Propose the change with rollback and test coverage first. - - +# tariff +Pricing and invoicing web app for Imbra Ltd: catalog, discounts, tax +jurisdictions, customers, invoices. Python 3.12, Flask 3, Jinja, HTMX, +SQLite, uv. One administrator; runs locally only, no deployment target. +The pricing engine is a library another program may import directly. +- Model: inline +## 1. Project +See README.md for the directory map; place code beside its layer. +```bash +uv run flask run # start the app +uv run ruff check . && uv run ruff format --check . # lint +uv run mypy --strict . && uv run pytest # types + tests +``` +## 2. Code conventions +- Work on a branch; never commit to `main`. Commit `uv.lock`, never + `.env`, secrets, or build output. +- Off-limits without approval: auth/session code, migrations, `.env*`. +- Parameterize every SQL query; never interpolate input into SQL. +- Store money as integer minor units or `Decimal`, never `float`. +- Hash the administrator's password with bcrypt, scrypt, or Argon2. +- Regenerate the session ID on login; expire idle sessions; set + `HttpOnly`, `Secure`, `SameSite=Lax` cookies. +- Give every state-changing HTMX/form request a CSRF token. +- Encode all template output for context; never bypass autoescaping. +- Run schema changes through a migration with up/down steps; never + edit the SQLite file by hand. +- Never log a customer's name, email, address, or any secret value. +- Classify customer PII (name, email, postal address); export or erase + it on request: hard delete or anonymize, never soft-delete alone. +- Cover pricing, discount, and tax logic with edge-case unit tests. +## 3. Review process +Review in order: security, correctness, clarity, conventions. +- [ ] No secret or PII value in a committed file or log. +- [ ] Every SQL query parameterized; every migration has up/down. +- [ ] Money uses integer minor units or `Decimal`, never `float`. +## 4. Session protocol +- Approver: the repository owner. Tracking: open, no tracker named. +- Release: a tagged commit on `main` after lint, types, tests pass. +- End of session, run in order: `ruff check .`, `mypy --strict .`, + `pytest`; report any that did not run as not run, never as passed. diff --git a/tests/efficacy/arms/short/generation.json b/tests/efficacy/arms/short/generation.json index 6d26b7e..7862623 100644 --- a/tests/efficacy/arms/short/generation.json +++ b/tests/efficacy/arms/short/generation.json @@ -1,60 +1,44 @@ { "arm": "short", + "kind": "model", "output_model": "inline", - "budget": [ - 40, - 88 - ], - "ref": "v2.90.0", - "commit": "4b1be7d8dec1186cc63d22f01969fc0c93ac822b", + "ref": "9086e0ff", + "source": { + "remote": "https://github.com/solid-ai-dev/solid-ai-templates.git", + "ref": "9086e0ff", + "commit": "9086e0ffc454fbff1d234601822257ce5e40a004" + }, "roots": [ - "stack-flask", - "stack-htmx", + "backend-api", + "backend-auth", + "backend-database", "frontend-ux", - "frontend-quality" + "base-security", + "base-data-governance" ], + "started_at": "2026-10-31T13:22:29", + "commit": "9086e0ffc454fbff1d234601822257ce5e40a004", "resolved_files": [ - "templates/base/core/quality.md", - "templates/base/core/git.md", - "templates/base/core/docs.md", - "templates/base/core/readme.md", - "templates/base/core/testing.md", - "templates/base/core/review.md", - "templates/base/core/oop.md", - "templates/base/core/config.md", + "templates/core/quality.md", + "templates/core/git.md", + "templates/core/docs.md", + "templates/core/testing.md", + "templates/core/review.md", "templates/backend/http.md", + "templates/backend/api.md", + "templates/security/security.md", + "templates/backend/auth.md", "templates/backend/database.md", - "templates/backend/observability.md", - "templates/base/security/security.md", - "templates/base/infra/containers.md", - "templates/backend/quality.md", - "templates/backend/features.md", - "templates/backend/messaging.md", - "templates/base/infra/cicd.md", - "templates/base/security/devsecops.md", - "templates/base/data/data-modeling.md", - "templates/base/data/data-quality.md", - "templates/base/language/python.md", - "templates/base/core/cli.md", - "templates/base/workflow/quality-gates.md", - "templates/base/core/examples.md", - "templates/stack/python-lib.md", - "templates/stack/python-service.md", - "templates/stack/python-flask.md", - "templates/backend/templating.md", - "templates/stack/htmx.md", "templates/frontend/ux.md", - "templates/frontend/quality.md" + "templates/data/data-modeling.md", + "templates/data/data-governance.md" ], - "prompt_chars": 586564, - "model": "claude-sonnet-5", - "effort": "high", - "started_at": "2026-09-26T14:28:59", + "prompt_chars": 83803, "prompt_leak": null, - "prompt_file": "C:/efficacy/gen-r3-short-3\\arm-short-prompt.txt", + "prompt_file": "C:/efficacy/gen-short\\arm-short-prompt.txt", "auth_probe": "ready", "command": [ - "C:\\Users\\braboj\\AppData\\Roaming\\npm\\claude.CMD", + "C:\\Users\\bgeorgiev\\.local\\bin\\claude.EXE", "-p", "--output-format", "json", @@ -67,26 +51,28 @@ "--setting-sources", "", "--settings", - "C:/efficacy/gen-r3-short-3\\home\\settings.json", + "C:/efficacy/gen-short\\home\\settings.json", "--strict-mcp-config", "--disallowed-tools", "WebSearch", "WebFetch" ], - "elapsed_s": 11.7, + "model": "claude-sonnet-5", + "effort": "high", + "elapsed_s": 200.3, "exit_status": 0, "result": { - "duration_api_ms": 9944, + "duration_api_ms": 193738, "stop_reason": "end_turn", - "session_id": "4d857594-2f51-4a34-a266-6a766229ab49", - "total_cost_usd": 0.941656, + "session_id": "d648277b-ed48-47a3-8e32-165e689f9c29", + "total_cost_usd": 0.5512856, "usage": { - "input_tokens": 2, - "cache_creation_input_tokens": 233598, - "cache_read_input_tokens": 0, - "output_tokens": 726, + "input_tokens": 14, + "cache_creation_input_tokens": 60568, + "cache_read_input_tokens": 495278, + "output_tokens": 20993, "output_tokens_details": { - "thinking_tokens": 0 + "thinking_tokens": 17757 }, "server_tool_use": { "web_search_requests": 0, @@ -94,36 +80,39 @@ }, "service_tier": "standard", "cache_creation": { - "ephemeral_1h_input_tokens": 233598, + "ephemeral_1h_input_tokens": 60568, "ephemeral_5m_input_tokens": 0 }, - "inference_geo": "not_available", + "inference_geo": "global", "iterations": [ { "input_tokens": 2, - "output_tokens": 726, - "cache_read_input_tokens": 0, - "cache_creation_input_tokens": 233598, + "output_tokens": 1058, + "cache_read_input_tokens": 84624, + "cache_creation_input_tokens": 1044, "cache_creation": { "ephemeral_5m_input_tokens": 0, - "ephemeral_1h_input_tokens": 233598 + "ephemeral_1h_input_tokens": 1044 }, "type": "message" } ], - "speed": "standard" + "speed": "standard", + "fallback_credit": null }, "modelUsage": { "claude-sonnet-5": { - "inputTokens": 2, - "outputTokens": 726, - "cacheReadInputTokens": 0, - "cacheCreationInputTokens": 233598, + "inputTokens": 14, + "outputTokens": 20993, + "cacheReadInputTokens": 495278, + "cacheCreationInputTokens": 60568, "webSearchRequests": 0, - "costUSD": 0.941656, + "costUSD": 0.5512856, "contextWindow": 1000000, - "maxOutputTokens": 128000, - "thinkingTokens": 0, + "maxOutputTokens": 64000, + "thinkingTokens": 17757, + "cacheCreationEphemeral5mInputTokens": 0, + "cacheCreationEphemeral1hInputTokens": 60568, "canonicalModel": "claude-sonnet-5", "provider": "firstParty", "costBasis": "list" @@ -157,26 +146,29 @@ }, "by_type": {} }, + "safety_stops": 0, "is_error": false, - "num_turns": 1, + "num_turns": 7, "subtype": "success", "api_error_status": null, - "result": "# tariff \u2014 CLAUDE.md\n\nOwner: Imbra Ltd. Pricing and invoicing web app: catalog, discounts, tax, invoices.\nStack: Python 3.12, Flask 3, Jinja, HTMX, SQLite. Tools: uv, ruff, mypy strict, pytest.\nRuns locally; no deployment target; nothing reaches the network.\n\n## Structure\n- The pricing engine is a library that imports without Flask; Flask is one caller.\n- Flask app uses `create_app()`, blueprints, thin routes; logic lives in services.\n- Layout is in README.md; do not duplicate it here.\n\n## Personal data (GDPR)\n- Customers hold name, email, postal address; invoices name them.\n- Support erasure and export of one customer's data; keep invoice totals intact.\n- Never log or print personal data; never put it in fixtures, commits or errors.\n- One administrator signs in; CSRF on every state-changing request.\n\n## Code\n- Money is integer cents or Decimal, never float; timestamps in UTC.\n- Errors raised on purpose derive from one package base error.\n- Parameterized SQL only; migrations versioned, never edited once merged.\n- HTMX endpoints return partials when `HX-Request` is set; 422 on invalid forms.\n- Config from environment, validated at startup; `.env` is never committed.\n- Names carry meaning; no debug prints, no commented-out code.\n\n## Quality\n- Gates: `ruff check`, `ruff format`, `mypy --strict`, `pytest`; all must pass.\n- Test the engine without Flask; use a real SQLite file, not a mock.\n- Every public function has type hints and a Google-style docstring.\n\n## Git\n- Work on a branch, never on `main`; conventional commit prefixes, subject under 80.\n- Update README, CLAUDE.md and docs in the same commit as the change.\n\n## Off-limits without an approved plan\n- Auth and session code, migrations, `.env*`, and invoice export formats.\n- Propose the change with rollback and test coverage first.\n\n", - "ttft_ms": 9999, + "result": "# tariff\nPricing and invoicing web app for Imbra Ltd: catalog, discounts, tax\njurisdictions, customers, invoices. Python 3.12, Flask 3, Jinja, HTMX,\nSQLite, uv. One administrator; runs locally only, no deployment target.\nThe pricing engine is a library another program may import directly.\n- Model: inline\n## 1. Project\nSee README.md for the directory map; place code beside its layer.\n```bash\nuv run flask run # start the app\nuv run ruff check . && uv run ruff format --check . # lint\nuv run mypy --strict . && uv run pytest # types + tests\n```\n## 2. Code conventions\n- Work on a branch; never commit to `main`. Commit `uv.lock`, never\n `.env`, secrets, or build output.\n- Off-limits without approval: auth/session code, migrations, `.env*`.\n- Parameterize every SQL query; never interpolate input into SQL.\n- Store money as integer minor units or `Decimal`, never `float`.\n- Hash the administrator's password with bcrypt, scrypt, or Argon2.\n- Regenerate the session ID on login; expire idle sessions; set\n `HttpOnly`, `Secure`, `SameSite=Lax` cookies.\n- Give every state-changing HTMX/form request a CSRF token.\n- Encode all template output for context; never bypass autoescaping.\n- Run schema changes through a migration with up/down steps; never\n edit the SQLite file by hand.\n- Never log a customer's name, email, address, or any secret value.\n- Classify customer PII (name, email, postal address); export or erase\n it on request: hard delete or anonymize, never soft-delete alone.\n- Cover pricing, discount, and tax logic with edge-case unit tests.\n## 3. Review process\nReview in order: security, correctness, clarity, conventions.\n- [ ] No secret or PII value in a committed file or log.\n- [ ] Every SQL query parameterized; every migration has up/down.\n- [ ] Money uses integer minor units or `Decimal`, never `float`.\n## 4. Session protocol\n- Approver: the repository owner. Tracking: open, no tracker named.\n- Release: a tagged commit on `main` after lint, types, tests pass.\n- End of session, run in order: `ruff check .`, `mypy --strict .`,\n `pytest`; report any that did not run as not run, never as passed.", + "ttft_ms": 128419, "type": "result", - "duration_ms": 10068, - "uuid": "6303e425-2c4c-4318-a754-54f062a8aa2d", - "ttft_stream_ms": 3125, - "time_to_request_ms": 121, - "first_content_frame_ms": 3125, + "duration_ms": 197972, + "uuid": "b711c13a-688b-4a75-a566-6125baae94ef", + "ttft_stream_ms": 1871, + "time_to_request_ms": 419, + "first_content_frame_ms": 1871, "queued_turn_count": 0, "result_index": 0 }, + "budget": [ + 40, + 88 + ], "output_leak": null, - "over_budget": [], "outcome": "generated", - "output": "C:\\Workspace\\solid-ai-templates\\tests\\efficacy\\arms\\short\\CLAUDE.md", - "output_chars": 1896, - "output_lines": 39, - "output_width": 87 + "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\short\\CLAUDE.md", + "output_lines": 40, + "output_words": 352 } \ No newline at end of file diff --git a/tests/efficacy/generate_arm.py b/tests/efficacy/generate_arm.py index 673adef..2211958 100644 --- a/tests/efficacy/generate_arm.py +++ b/tests/efficacy/generate_arm.py @@ -6,11 +6,14 @@ - `reference` is fixed text naming each template of the chain - `inline` and `hybrid` are one non-interactive generation each, following `templates/core/agents.md` with no interview +- `short` is the same generation in the inline model, held to 40 lines of + 88 characters - `skills` is what `resolve_chain.py --emit` builds, the facts filled from the brief It writes `arms//CLAUDE.md` (and, for `skills`, the skills beside it), -and refuses to keep a result the specification leaked into. +and refuses to keep a result the specification leaked into, or one over its +arm's budget. Run it once per arm. Re-running it produces a different file and therefore a different arm, so it refuses to overwrite an existing one without @@ -44,14 +47,17 @@ # The arms this module makes, each with the directory under `arms/` its file # and record live in, and how it is made: fixed text, a model generation in -# one of `agents.md`'s models, or the emitter. Round 3's arms (`full`, -# `short`, `hand`) keep their committed files and records; they were made -# through an interview that no longer ships upstream. +# one of `agents.md`'s models, or the emitter, and a model arm's budget as +# (lines, width) where it has one. Round 3's `full` and `hand` keep their +# committed files and records; they were made through an interview that no +# longer ships upstream. GENERATED = { "reference": {"dir": "reference", "kind": "fixed"}, "inline": {"dir": "inline", "kind": "model", "model": "inline"}, "hybrid": {"dir": "hybrid", "kind": "model", "model": "hybrid"}, "skills": {"dir": "skills", "kind": "emit"}, + "short": {"dir": "short", "kind": "model", "model": "inline", + "budget": (40, 88)}, } @@ -195,9 +201,46 @@ def record_path(arm): SLOT = re.compile(r"\{\{[^}]+\}\}") +# The budget clause. The width keeps a line from carrying a paragraph. The +# closing check adds no content; it asks the model to hold a bound it is +# already given, since a file over it is refused whole. +BUDGET = """\ +The finished `CLAUDE.md` MUST be at most {lines} lines, blank lines counted, +and no line may be longer than {width} characters. Keep the rules that matter +most for this project and leave the rest out; a rule that does not fit is left +out, not squeezed onto another rule's line. + +Before you answer, measure every line against {width} characters and shorten +or split each one over it, then count the lines again. A file over either +bound is refused whole, never trimmed.""" + + def arm_clause(arm): - """The model paragraph for one model arm's instruction.""" - return "## The output model\n\n%s\n" % MODELS[GENERATED[arm]["model"]] + """The model and budget paragraphs for one model arm's instruction.""" + entry = GENERATED[arm] + lines = ["## The output model", "", MODELS[entry["model"]]] + if entry.get("budget"): + count, width = entry["budget"] + lines.extend(["", "## The budget", "", + BUDGET.format(lines=count, width=width)]) + return "\n".join(lines) + "\n" + + +def over_budget(document, budget): + """Every way a file exceeds its (lines, width) budget, as sentences; + empty where it fits or has no budget.""" + if not budget: + return [] + lines, width = budget + text = document.rstrip("\n").split("\n") + findings = [] + if len(text) > lines: + findings.append("%d lines, over the budget of %d" % (len(text), lines)) + widest = max((len(line) for line in text), default=0) + if widest > width: + findings.append("a line of %d characters, over the width of %d" + % (widest, width)) + return findings def read_brief(path=BRIEF): @@ -396,13 +439,15 @@ def parse_args(argv): def self_test(): - """A scan that cannot fail is not a control, and neither is a fill. + """A scan that cannot fail is not a control, and neither is a fill or a + budget. Plants a specification-only token and requires the scan to report it, and a clean text to scan clean. Requires the reference text to name every file under the vendored path and to be the same twice. Requires a fact slot the brief does not fill to be refused, and every known slot - filled. + filled. Requires a file one line over the budget, and one a character + too wide, refused, and a file at both bounds kept. """ clean = "A pricing and invoicing web application with discount rules." if scan(clean, "clean", PROMPT_TOKENS) is not None: @@ -436,6 +481,30 @@ def self_test(): except TrialError: pass print("every known fact slot is filled, and an unknown one is refused") + + budget = GENERATED["short"]["budget"] + lines, width = budget + at_bounds = "\n".join(["x" * width] * lines) + "\n" + if over_budget(at_bounds, budget): + print("FAIL: a file at both bounds was refused") + return 1 + long = "\n".join(["x"] * (lines + 1)) + "\n" + wide = "\n".join(["x" * (width + 1)] + ["x"] * (lines - 1)) + "\n" + if not over_budget(long, budget) or not over_budget(wide, budget): + print("FAIL: a file over the budget was kept") + return 1 + if over_budget(long, None): + print("FAIL: an arm with no budget refused a file") + return 1 + print("the budget keeps a file at %d lines of %d characters and refuses " + "one over either" % (lines, width)) + if "MUST be at most %d lines" % lines not in arm_clause("short") \ + or "measure every line against %d" % width \ + not in arm_clause("short") \ + or "budget" in arm_clause("inline").lower(): + print("FAIL: the budget clause is not in short's instruction alone") + return 1 + print("the budget is stated in short's instruction and no other") return 0 @@ -496,6 +565,17 @@ def main(argv): write_record(options.root, record, started_at) return 0 if record.get("outcome") == "dry-run" else 1 + # A file over its budget is refused whole rather than trimmed, since + # trimming would put a person's judgement into the arm. + record["budget"] = entry.get("budget") + over = over_budget(document, entry.get("budget")) + if over: + record["outcome"] = "refused: over budget" + record["over_budget"] = over + print("refused: the generated file is over its budget: %s" + % "; ".join(over)) + return write_record(options.root, record, started_at) or 1 + texts = [document] + list(skills.values()) leak = scan("\n".join(texts), "generated files", NON_INVENTABLE) record["output_leak"] = leak diff --git a/tests/efficacy/harness.py b/tests/efficacy/harness.py index 9d74489..af1a902 100644 --- a/tests/efficacy/harness.py +++ b/tests/efficacy/harness.py @@ -127,12 +127,13 @@ # `arms/`. Arm `none` carries no file: it is the bare agent. The two files # round 1 ran keep the directories its generation record names. `inline`, # `reference` and `skills` are round 5's; `hybrid` was regenerated for it, -# and an arm's vendored ref comes from its generation record. +# and an arm's vendored ref comes from its generation record. `short` was +# made again from round 5's chain, under round 3's budget. ARMS = { "none": {"label": "no context file", "context": None}, "full": {"label": "the templates' file, inline", "context": "full/CLAUDE.md"}, - "short": {"label": "the templates' file, 40 lines", + "short": {"label": "the templates' file, inline, 40 lines", "context": "short/CLAUDE.md"}, "hybrid": {"label": "the templates' file, hybrid", "context": "hybrid/CLAUDE.md", "vendor": VENDORED},