diff --git a/docs/coverage.md b/docs/coverage.md
index 1628ac1..ee3f09d 100644
--- a/docs/coverage.md
+++ b/docs/coverage.md
@@ -188,6 +188,7 @@ when:
| 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" |
+| FR-13-08 | Self-test | `generate_arm.py` "a generated file naming a tool is refused, and the prompt forbids one" |
## 14 One run at a time
diff --git a/docs/requirements.md b/docs/requirements.md
index ab4950e..a783487 100644
--- a/docs/requirements.md
+++ b/docs/requirements.md
@@ -196,6 +196,7 @@
| 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 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 |
+| FR-13-08 | The benchmark shall tell a model arm's generation to name no tool, and refuse a generated file that names one. | Arm generator |
### 14 One run at a time
diff --git a/tests/efficacy/arms/hybrid/CLAUDE.md b/tests/efficacy/arms/hybrid/CLAUDE.md
index 28c2a1a..602abc2 100644
--- a/tests/efficacy/arms/hybrid/CLAUDE.md
+++ b/tests/efficacy/arms/hybrid/CLAUDE.md
@@ -1,43 +1,27 @@
# tariff
-Imbra Ltd's pricing and invoicing application: a product catalog,
-discount rules of several kinds, tax jurisdictions, customers, and
-invoices assembled from them. Runs locally only; no deployment target,
-no live URL.
+A pricing and invoicing web application for Imbra Ltd — a product catalog, discount rules, tax jurisdictions, customers, and invoices assembled from them. Python 3.12, Flask 3, Jinja, HTMX, SQLite. Runs locally only; there is no deployment target.
-Quality conventions are defined in `docs/solid-ai-templates/templates/`
-(a vendored copy at a pinned revision, not a submodule). Key references:
+- Model: hybrid
+- Rule language: a plain imperative ("Use X", "Never Y") is MUST / MUST NOT. RFC 2119 keywords (MUST, MUST NOT, SHOULD, SHOULD NOT, MAY) are used where strength needs to be explicit.
+- Precedence where sources disagree: this file, then `AGENTS.md`, then the vendored templates below. A disagreement between this file and `AGENTS.md` is a bug in one of them — fix it before continuing, never act on either alone when the running system is defensible.
+
+Quality conventions are vendored, not submoduled, at `docs/solid-ai-templates/templates/` (a copy pinned at a fixed revision, not a git submodule — never instruct anyone to add it as one). This file inlines every rule the project has adopted from that copy and references the rest by path. Reading a newer version of a referenced template, or moving the vendored copy's pin, adopts nothing by itself (MUST); a rule joins this project only when this file is edited to state it. Exclude `docs/solid-ai-templates/` from any linter, formatter, secret scanner, or spell/link checker the project later adds (MUST), before its first commit.
-- `docs/solid-ai-templates/templates/core/agents.md` — governs this
- file's own structure
+Key references (read before touching the area they cover):
- `docs/solid-ai-templates/templates/core/quality.md`
- `docs/solid-ai-templates/templates/core/git.md`
- `docs/solid-ai-templates/templates/core/docs.md`
- `docs/solid-ai-templates/templates/core/testing.md`
- `docs/solid-ai-templates/templates/core/review.md`
- `docs/solid-ai-templates/templates/backend/http.md`
-- `docs/solid-ai-templates/templates/backend/database.md`
- `docs/solid-ai-templates/templates/security/security.md`
+- `docs/solid-ai-templates/templates/backend/database.md`
- `docs/solid-ai-templates/templates/frontend/ux.md`
- `docs/solid-ai-templates/templates/data/data-modeling.md`
- `docs/solid-ai-templates/templates/data/data-governance.md`
-Adoption boundary (MUST): the rules inlined or referenced below are the
-adopted set. They stay in force until this file is edited to change them.
-Reading a newer version of a referenced template, or moving the vendored
-pin, adopts nothing by itself — only an edit to this file changes what is
-adopted.
-
-Not adopted, and intentionally absent below: `backend/api.md` and
-`backend/auth.md`. The pricing engine is a library imported in-process by
-two callers (the web application and another program); it is never
-exposed as a network API, so REST/gRPC/GraphQL contract, versioning and
-token/RBAC rules do not apply. Do not add them without first recording
-why a network-facing contract has become necessary.
-
-Before the first commit that adds `docs/solid-ai-templates/`, exclude
-that directory from every tool that walks the tree: ruff, mypy, any
-secret scanner, and any spell or link checker (MUST).
+Declined candidates: `backend/api.md` — the project's only external interfaces are the pricing engine's library API and the invoice exports (per the brief); there is no published HTTP/REST/gRPC/GraphQL contract to version or paginate. `backend/auth.md` — there is one administrator and no second role, no service-to-service API, and no bearer-token or API-key surface; `security/security.md`'s authentication and session rules already cover the single sign-in.
## 1. Project
@@ -45,467 +29,193 @@ secret scanner, and any spell or link checker (MUST).
- Owner: Imbra Ltd
- Stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite
-- Tooling: uv, ruff, mypy (strict), pytest
-- Hosting: none — runs locally, single process, no deployment target
-- Actors: the administrator (one account, browser-based) and another
- program that imports the pricing engine directly, in-process, without
- the web application present
-- Model: hybrid
+- Hosting: none — the application runs on the administrator's own machine; it is never deployed, and nothing in it reaches the network (MUST stay true — see §9)
### 1.2 Project structure
-Keep the authoritative directory map in `README.md`. Do not duplicate it
-here. Placement rules for this project:
-
-- Keep the pricing engine (catalog, discount rules, tax jurisdictions,
- invoice assembly) in its own package, importable with the web
- application absent (MUST)
-- Keep Flask routes, Jinja templates and HTMX partials in a separate web
- package that imports the pricing engine; never the reverse (MUST)
-- Mirror the source layout in `tests/`
-- Keep SQLite migrations in one directory, applied in order, numbered
-- Keep `docs/solid-ai-templates/` untouched except for the revision pin
-
-### 1.3 Commands
-
-```bash
-uv sync
-uv run flask --app tariff run --debug
-uv run ruff check .
-uv run ruff format --check .
-uv run mypy --strict .
-uv run pytest
-```
-
-### 1.4 Governance
-
-- Who approves a change: open — not settled by the project yet
-- How work is tracked: open — not settled by the project yet
-- What is a release: open — not settled by the project yet; the
- application has no deployment target, so a release is at most a tagged
- commit, not a deployed artifact
-
-## 2. Code conventions
-
-### 2.1 Git
-
-- Commit under one full name and one consistent email; never change
- identity mid-project
-- Work on a branch; never commit directly to `main`
-- Never commit build output, dependency directories, secrets, or the
- SQLite database file
-- Keep a `.gitignore` covering dependencies, build output, secrets,
- editor state, OS files and coverage output (MUST)
-- Commit the `uv.lock` lockfile (MUST)
-- Inspect the working tree and index before starting a task; never
- discard, reset, stash or overwrite a change the task did not make
-- Stage only the changes the task made; read the staged diff before
- committing
-- Keep a pull request to one concern; test locally before committing
-- Review the diff against the base before merging, in order: security,
- correctness, clarity, conventions
-- Merge only after review passes and CI is green; never force-push,
- including `--force-with-lease`
-- Bring a branch up to date by merging the base into it, never by
- rebase-and-force-push
-- Read the CI run for the push before calling a change good; never merge
- while a check is failing, cancelled, or not yet registered
-
-**Off-limits paths** (MUST NOT change without explicit approval; propose
-first, with rollback and tests that would catch a regression):
-
-- Authentication and session code (administrator sign-in)
-- Customer data erasure and export code (GDPR compliance paths)
-- SQLite migrations
-- `.env*` and secret files
-- CI/CD workflow files
-
-Name any off-limits path touched at the top of the change's summary,
-whether proposed or already approved; a diff confined to prose in such a
-file is ordinary work.
-
-### 2.2 Python
-
-- Run under mypy strict mode; add no untyped `def`, no implicit `Any`,
- and no `# type: ignore` without the specific error code it silences
-- Run ruff as both linter and formatter; a generator-produced file must
- pass both without `--fix`
-- Encode every committed text file UTF-8 with LF line endings, and keep
- identifiers ASCII:
-
-```bash
-pre-commit run check-ascii-identifiers --all-files --verbose
-```
-
-Pass condition: inspected count above zero, `non-ASCII identifiers` zero.
-
-- Commit a `.gitattributes` with `* text=auto`, adding `eol=lf` where LF
- must be forced, and `-text` on any path that is genuinely binary or
- must keep CRLF
-
-## 3. Quality
-
-- Keep one authoritative representation of each piece of knowledge
- (e.g., a tax rule, a currency format); the third copy is a bug
-- Choose the simplest solution a stated requirement justifies; build only
- what the catalog, discount, tax, customer and invoice features need now
-- Record, beside every deferral, the concrete condition that reopens it
-- Delete a path once it has no caller or its input is retired
-
-**Naming**
-
-- Name a function with a verb, a class or module with a noun, a boolean
- with `is`/`has`/`can`
-- Use the same name for the same concept in every module (e.g., one name
- for "discount rule" throughout catalog, pricing and invoice code)
-- Name a public enum member or result discriminator for the capability it
- offers, never the library behind it
-
-**Complexity**
-
-- Keep cognitive complexity at or under 15 per function; nest at most
- three levels, with guard clauses and early returns
-- Replace a boolean flag that selects behaviour with an enum or two named
- functions
-- Name every magic number and magic string as a constant
-- Take a tax, currency or rounding limit from the applicable law or
- specification and name it; never derive it from an observed sample
-
-**Dependencies and module structure**
-
-- Keep the module graph acyclic: the pricing engine never imports the web
- package
-- Enforce that boundary mechanically once the import-ban check is wired
- into pre-commit, with the pricing-engine-to-web direction declared as a
- forbidden pair:
-
-```bash
-pre-commit run find-import-bans --all-files --verbose
-```
-
-- Keep the Flask web application a thin layer over the pricing engine
- library: decode request → call the library → render response; push
- catalog, discount, tax and invoice logic into the library, not into
- route handlers
-- Never write to standard output or standard error from the pricing
- engine library, and never configure logging beyond its own logger
- (MUST); make its logger injectable, falling back to its module logger
-- Keep constants beside the functions that use them
-
-**Errors**
-
-- Validate input at the boundary (HTTP handlers, the other program's call
- sites) and fail at once on invalid state
-- Never break a public catch contract: a raise callers catch by a
- built-in type keeps that type
-- Add an error type only where a caller could act differently
-- Never let a caller-side filter stand in for a precondition inside the
- pricing engine; assert the precondition there
-
-**Deprecation**
-
-- Deprecate a public symbol in the pricing engine's API, naming its
- replacement, before a later change removes it; the other program and
- the web application are both callers that can be broken by a silent
- removal
-
-**Comments and debug code**
-
-- Prefer code that needs no comment; never cite a ticket or PR number in
- a comment — state the substance instead
-- Commit no debug output (`print()`) and no commented-out code; gate
- debug tooling behind a flag, off by default
-- Delete a probe script before the commit that uses its findings; keep
- the findings in a comment, decision record or doc, never in the probe
-
-**Destructive operations** (governs GDPR erasure above all)
-
-- Delete, anonymize or overwrite only what the operation can prove it
- owns: match an erasure or export request by customer ID, never by a
- name or email string match
-- Validate the input as well: reject an empty or malformed customer
- identifier before acting
-- Find nothing, and change nothing, where the proof of ownership is
- unavailable: no guess, no partial match
-
-**Check trust**
-
-- Confirm a migration or data-fix script is correct, on a copy of real
- data, before running it against the live SQLite file
-- Cross-check an independent source before overwriting stored customer or
- pricing data with a source that looks wrong
-
-**Completion**
-
-- Finish a task when the requested behaviour works through the entry
- point its user or caller reaches (the browser UI, or the library call
- the other program makes), and the checks that prove it pass
-- Report a check that could not run as not run, never as a pass
-
-## 4. Security
-
-- Validate all external input (HTTP form/query data, and any input the
- other program passes into the pricing engine) at the boundary, with a
- schema validator; use an allowlist, never a blocklist
-- Encode dynamic data for its rendering context at the point of output in
- Jinja templates; never bypass auto-escaping with a raw-HTML path for
- customer- or admin-supplied text
-- Use parameterized queries for every SQLite access; never concatenate
- input into SQL
-- Hash the administrator's password with bcrypt, scrypt or Argon2; use
- constant-time comparison for any token; lock out or throttle after
- repeated failed sign-in attempts
-- Generate the session ID with a cryptographic random generator;
- regenerate it after login; set `HttpOnly`, `Secure`, `SameSite=Lax`
- cookie flags; expire idle sessions; invalidate on logout
-- Give every state-changing request (`POST`/`PUT`/`PATCH`/`DELETE`) a
- CSRF token, since the administrator's session is authenticated by an
- ambient cookie; use the framework's CSRF middleware (e.g. Flask-WTF),
- never a hand-rolled check
-- Include the CSRF token explicitly in every HTMX request that mutates
- state (`hx-headers` or a hidden field); HTMX does not add it on its own
-- Never change state on a `GET` request
-- Never hardcode secrets (session signing key, any admin credential) in
- source; keep them in a local secret file excluded from version control
-- Never expose a stack trace, internal path or SQLite error to the
- browser; return a generic error externally and log full detail
- server-side
-- Never log secrets, tokens, or personally identifiable information
- (customer name, email, postal address); log authentication and
- authorization failures with an opaque user ID and the client IP, kept
- only in a security log with its own retention
-- Pin dependency versions and verify them via `uv.lock`; never trust an
- unpinned upstream package
-- Set security headers on every response (`Content-Security-Policy`,
- `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY` or CSP
- `frame-ancestors`, `Referrer-Policy`, `Permissions-Policy`); do not
- expose `Server`/`X-Powered-By` version strings
-
-Not applicable, and do not add without a stated reason:
-
-- Transport security (HTTPS/HSTS/TLS) and CORS — the application serves
- only loopback HTTP to the administrator's local browser; it has no
- deployment target and no second origin to allow
-- SSRF defences — the application makes no outbound network requests;
- nothing it does reaches the network
-- File-upload rules — there is no file-upload feature
-
-## 5. Data modeling and GDPR compliance
-
-**Modeling** (products, discount rules, tax jurisdictions, customers,
-invoices)
-
-- Use one naming convention for every table and column (snake_case)
-- Give every table a primary key; store monetary values as integers in
- minor units, never floating point; store timestamps in UTC; document a
- maximum length for every text field
-- Enforce every reference (invoice → customer, invoice line → product,
- discount → product or category) with SQLite foreign key constraints
- (`PRAGMA foreign_keys = ON`); decide per reference whether deleting the
- target cascades, clears the reference, or is refused
-- Run every schema change through a versioned migration with both up and
- down steps; never hand-edit the schema
-
-**Classification**
-
-- Confidential: customer name, email, postal address; invoice records
- (they carry the same fields)
-- Restricted: the administrator's password hash and the session signing
- key
-- Internal: product catalog, discount rules, tax jurisdiction
- configuration
-
-**Personal data (customers)**
-
-- Encrypt PII at rest if the deployment environment changes from a single
- trusted local machine; document the decision either way
-- Minimize collection: store only name, email and postal address, no more
-- Provide an erasure mechanism: hard-delete or anonymize the customer
- record on request; never a soft delete of PII
-- Anonymize the customer's name, email and postal address on invoices
- that must be retained for tax or accounting records after an erasure
- request, rather than deleting the invoice itself; keep the invoice's
- financial figures intact
-- Provide a data-portability export: on request, produce the customer's
- own stored data (name, email, postal address, and the invoices billed
- to them) in a structured, machine-readable format
-- Never put a customer's name, email or address in an application log or
- error message; the audit trail below is a separate store, not a log
-
-**Retention**
-
-- Define, per data category, how long it is kept and when it is purged;
- the statutory retention period for invoices under the applicable tax
- law is open — settle it before relying on a default
-- Retain customer PII only until it is no longer needed for an open
- invoice relationship, or until an erasure request, whichever is sooner
-
-**Ownership and audit**
-
-- The administrator is the sole owner of every data domain (customers,
- products, discounts, tax jurisdictions, invoices) while the application
- has one operator
-- Log every change to a customer's PII and to the administrator's
- credentials in an append-only audit table, separate from application
- logs: who changed what, when, and that a value changed, never the old
- or new PII value itself
-- Erasing a customer's PII must still leave an audit trail entry that the
- erasure happened, without a copy of the erased value
-
-## 6. Database
-
-- Parameterize every SQLite query; never build one by string
- interpolation
-- Bound every list view (customers, invoices, products) with a limit or
- pagination; never load a full table for an interactive request
-- Fetch related rows (e.g., invoice lines for a set of invoices) in one
- query, never one query per row in a loop
-- Wrap a multi-table write (assembling an invoice from catalog, discount
- and tax data) in a transaction; commit only after every write succeeds
-- Keep transactions short; never call the pricing engine's heavier
- computations or any I/O inside an open transaction
-- Open one connection per request through Flask's application context,
- closed at teardown; do not size a connection pool for this — SQLite is
- an embedded local file, not a networked database server
-- Reset state between test runs by wrapping each test in a transaction
- rolled back after completion, or by using a fresh temporary SQLite file
- per test; never substitute an in-memory or different database engine in
- tests
-- Never run a migration against the real local SQLite file from a test
- suite
-
-## 7. Web interface and UX
-
-**HTTP**
-
-- Read the port from an environment variable such as `PORT`; use a
- well-known development default
-- Keep Flask handlers thin: decode request → call the pricing engine →
- render the Jinja template or HTMX fragment; validate all incoming
- request data before processing
-- Parse a typed query parameter explicitly, distinguishing absent,
- present-and-valid, and present-but-invalid (raise 400 on the last)
-- Never let a `GET` or `HEAD` request change state; make every `PUT` and
- `DELETE` idempotent
-- Format every date and time field as ISO 8601, every currency code as
- ISO 4217, and every country code as ISO 3166-1 alpha-2, in invoice
- exports and in any JSON the application emits
-- Serialise a computed float that is non-finite (`NaN`/`Infinity`) as
- `null` in any JSON export, never as a bare token
-- Use a consistent error response shape across all routes; 4xx for client
- errors, 5xx for server errors, never 200 for an error
-- Enforce authentication on every route except none are declared public;
- the application has a single administrator account and no self-service
- sign-up or recovery flow
-
-Not applicable: the process-lifecycle rules for graceful shutdown under
-an orchestrator (drain deadlines, `SIGTERM` handling across instances) —
-the application runs as a single local process with no deployment target
-and no second instance to drain into.
-
-**UX and accessibility**
-
-- Meet WCAG 2.1 AA: keep text contrast at 4.5:1 (3:1 for large text),
- keep every interactive element keyboard-reachable, use a native button
- or link rather than a click handler on a non-focusable element, style
- focus with `:focus-visible`, and never convey meaning by colour alone
-- Give an icon-only control a descriptive `aria-label`
-- Scan rendered pages with an automated accessibility checker; before
- shipping a new interactive component, tab through it without a mouse
- and verify with one screen reader
-- Keep visual values (colour, spacing, type) in one CSS source of truth;
- the project has no shared design system yet, so do not hardcode a
- visual value in more than one place
-- Support the last two versions of Chrome, Firefox, Safari and Edge
-
-## 8. Review process
-
-Review in this order, most critical first: security, correctness,
-clarity, conventions. `docs/solid-ai-templates/templates/core/quality.md`
-is the standard for items 2–4.
-
-**MUST checklist**
-
-- [ ] No credential, token or sensitive value appears in a committed file
-- [ ] Every failure path is handled; no silent catch, no swallowed
- exception
-- [ ] Every new dependency carries an acceptable licence
-- [ ] Existing documentation matches the code after the change
+- The structure lives in `README.md`'s project map; this file only adds placement rules on top of it. Never duplicate the directory tree here.
+- Keep the pricing engine (catalog, discount rules, tax jurisdictions, invoice assembly) in its own package, importable with no Flask, Jinja, HTMX, or SQLite-session code in its import path. Nothing under that package may import from the web layer.
+- Keep the Flask app, templates, and HTMX fragment views in a separate package that imports the pricing engine; never the reverse.
+- Keep this file, `AGENTS.md`, and `README.md` in the repository root; update all three in the same commit whenever a rule, the stack, or the structure changes, so none of them drifts from the others.
+
+### 1.3 Commands and checks
+
+No specific type checker, linter, formatter, test runner, or package manager is named by the project. Until one is chosen, every check below is a requirement on behavior, not on a tool:
+
+- A static type check over the whole Python codebase must run clean before a commit.
+- A linter and a formatter must both run clean before a commit; let the formatter run on save rather than hand-formatting.
+- The full test suite (pricing engine unit tests, Flask integration tests, and any end-to-end check of the invoice export) must run clean before a merge.
+- Report any of the above as "not run" when it could not run; never report it as passing.
+
+## 2. Architecture boundaries
+
+- There are exactly two actors: the administrator, who works through the browser, and another program, which imports the pricing engine directly, with no web application present. The web application is one caller of the library among possibly several; design and test the library so it never assumes the web app is running.
+- The pricing engine is a library: never let it write to standard output or standard error, and never let it configure logging beyond its own logger (MUST). Give it an injectable logger that falls back to its own module logger. Verify its silence in a fresh process — a test runner's own log handler hides the default.
+- The store is a local SQLite file; nothing in the system reaches the network. Treat any change that would open a socket, call an external HTTP service, or depend on a remote resource as outside this project's design until the brief says otherwise — raise it rather than add it.
+- Keep the Flask handlers thin: decode the request, call the pricing engine or a data-access function, render or encode the response. Never put discount, tax, or pricing logic in a handler or a template.
+
+## 3. Off-limits paths
+
+Change only with explicit approval, a stated rollback strategy, and the regression test that would catch a mistake, proposed before the change is made (MUST):
+
+- Sign-in and session code (there is exactly one administrator account; a bug here is a full compromise or a full lockout)
+- The pricing engine's discount, tax, and invoice-total calculation logic (an error here is a wrong invoice, not just a wrong screen)
+- Database migrations, once merged
+- `.env*` files and any other secret material
+- Any CI/CD workflow the project later adds
+
+Name any off-limits path touched by a change at the top of its summary, whether proposed or already approved (MUST). A diff confined to comments or prose inside these paths is ordinary work; anything executable — logic, flags, migration steps — is not.
+
+## 4. Git and change conventions
+
+- Work on a branch; never commit directly to `main`.
+- Commit under one consistent name and email.
+- Never commit build output, dependency directories, the SQLite database file, or any secret. Keep a `.gitignore` covering all of these plus editor and OS files.
+- Commit lockfiles once the project has one.
+- Inspect the working tree and the index before starting a task; never discard, reset, stash, or overwrite a change the task did not make.
+- Stage only the task's own changes — a whole file only if it held no prior change, otherwise only the task's hunks. Read the staged diff before committing.
+- Keep a pull request (or, for a solo change, a single commit) to one concern.
+- Never force-push. Bring a branch up to date by merging the base into it, never by rebasing and force-pushing.
+- Treat every repository as public: no secret or credential in source or history, ever, even though this project has no deployment target.
+
+## 5. Code quality and Python conventions
+
+- Keep one authoritative representation of each piece of pricing, discount, tax, or invoicing rule; a second copy is a bug waiting to diverge from the first.
+- Build only what the brief or an approved plan calls for; no speculative discount types, tax rules, or export formats ahead of a stated need.
+- Name a function with a verb, a class or module with a noun, a boolean with `is`/`has`/`can`. Name a discount kind, tax rule, or export format for the capability it offers (`DiscountKind.PERCENTAGE`), never for a library behind it.
+- Keep cognitive complexity at or under 15 per function; nest at most three levels; use guard clauses over nested conditionals.
+- Replace a boolean flag that selects behavior with an enum or two named functions.
+- Name every magic number and magic string (a tax rate, a rounding mode, a discount cap) as a constant.
+- Keep the module graph acyclic and coupling shallow: a change to one discount kind or tax rule must not force a change in an unrelated one.
+- Validate input at the Flask boundary and fail at once on invalid state; do not re-validate the same precondition in every inner function, but do assert it where a function depends on it.
+- Add an error type only where a caller (the web layer, or the other program) could act differently on it; never change what type a public function raises.
+- Prefer code that needs no comment; when a comment is needed, state the non-obvious why, never the what. Never cite an issue or PR number in a comment — state the substance instead.
+- Commit no debug `print()`/breakpoints and no commented-out code.
+- Annotate every public function's parameters and return type.
+- Encode every committed text file in UTF-8 with LF line endings; keep identifiers ASCII.
+- Wrap Markdown documentation conservatively (roughly 80-100 columns) until the project declares and enforces a specific width.
+- A task finishes when the requested behavior works through the entry point that reaches it (a route, the library's public function, or the export) and the tests that prove it pass — not when surrounding code has also been rewritten.
+
+## 6. Data modeling and database conventions
+
+- Use one naming convention across every SQLite table, column, key, and index.
+- Give every table a primary key; prefer a surrogate key internally.
+- Store each fact once; duplicate only with a documented reason.
+- Never pack several values into one text column (e.g., an address) — use separate columns or a related table.
+- Enforce every foreign key with SQLite's own constraint; decide and document, per relationship, whether deleting the target deletes the referencing rows, clears the reference, or is refused.
+- Store a discount's kind as a discriminator column plus the fields that kind needs; never overload one column to mean different things for different kinds.
+- Store monetary values (prices, discount amounts, tax amounts, invoice totals) as integers in minor units or as a fixed-precision decimal type — never as floating point.
+- Store every date and time in ISO 8601, in UTC where a time is involved; convert to local time only when displaying it.
+- Represent a tax jurisdiction's country as an ISO 3166-1 alpha-2 code and every currency as an ISO 4217 code.
+- Document a maximum length for every text field, including name, email, and postal-address fields.
+- Run every schema change through a migration committed to the repository, with both an `up` and a `down` step; never hand-edit the schema. Say so, and get approval, when a `down` step would lose data.
+- Parameterize every query that takes a value; never build SQL by string interpolation.
+- Bound every interactive query (an invoice list, a customer list) with a limit or pagination; never load an unbounded result into a page.
+- Fetch related rows for a set of records in one query, never one query per row in a loop.
+- Wrap each multi-step write (e.g., assembling an invoice from catalog, discount, and tax rows) in a transaction; keep transactions short and never call out to the pricing engine's I/O from inside one.
+- Use soft deletes only where audit history is required (see §7); otherwise delete the row.
+- In tests, use the real SQLite engine, not an in-memory substitute with different behavior, and reset state between tests rather than relying on run order.
+
+## 7. Privacy and data governance (GDPR)
+
+The business is in the EU; the GDPR applies to every customer's name, email, and postal address, and to any invoice that names them.
+
+- Classify customer name, email, and postal address, and any invoice line that carries them, as confidential data; scope database and export access to the single administrator account accordingly.
+- Encrypt the SQLite file at rest (e.g., full-disk or file-level encryption on the machine it runs on) given it holds confidential PII, and never transmit it anywhere — nothing in this project reaches the network.
+- Minimize collection: store only the name, email, and postal address the invoicing process needs; add no further personal field without a stated reason.
+- Never put a customer's name, email, or address in an application log, error message, or stack trace (MUST NOT). Identify a customer in a log by an opaque internal ID only.
+- Implement the customer's right of access (GDPR Art. 15) as a function that exports everything stored about one customer, keyed by that customer's ID, in a form the administrator can hand over.
+- Implement the customer's right to erasure (GDPR Art. 17) as a real delete or anonymization of the customer's personal fields — never a soft delete that leaves the name, email, or address readable.
+- Resolve the conflict between erasure and invoice retention explicitly: when a legal or tax obligation requires keeping a past invoice's financial record, anonymize that invoice's customer-identifying fields (name, email, address) in place rather than deleting the invoice row, and delete the live customer record itself. Document the retention period that obligation sets, and purge personal data automatically once it lapses rather than relying on a manual sweep.
+- Keep an audit trail, separate from the application log, of every access-and-erasure action taken (export produced, erasure applied) and every edit to a customer's PII: actor (the administrator), timestamp, action, and that a value changed — never the old or new value itself. Make this trail append-only.
+- Treat Imbra Ltd (via the administrator account) as the owner of every data domain — catalog, discount rules, tax jurisdictions, customers, invoices — there being no separate team to assign it to.
+
+## 8. Security
+
+- Validate all input arriving through a Flask route (form fields, query parameters, HTMX payloads) at that boundary, with an allowlist, before it reaches the pricing engine or the database.
+- Encode every value rendered into a Jinja template for its context; never bypass Jinja's autoescaping with a raw-HTML path for user-supplied or stored data (customer names and addresses included).
+- Parameterize every database query (see §6); never pass stored data to a shell or an `eval`-like construct.
+- Hash the administrator's password with bcrypt, scrypt, or Argon2 — never MD5, SHA-1, or plain SHA-256. Require a minimum length and reject known-breached passwords; impose no composition rules.
+- Lock the account or throttle sign-in after repeated failed attempts; compare secrets and tokens in constant time.
+- Generate the session ID cryptographically at random, regenerate it on successful sign-in, and invalidate it on logout rather than relying on cookie expiry alone.
+- Set the session cookie `HttpOnly`, `Secure`, and `SameSite=Strict` given the data behind it is financial and personal. Current browsers treat `http://localhost` as a secure context, so `Secure` does not block local-only operation.
+- Expire the session after 30 minutes of idleness, given the sensitivity of the data.
+- Give every state-changing HTMX request (`hx-post`, `hx-put`, `hx-delete`) CSRF protection bound to the session; validate the token on every such request and never on a `GET`. Never let a `GET`/`hx-get` request change state.
+- Never hardcode a secret, API key, or credential in source; keep any local secret file out of version control and out of logs.
+- Return generic error messages to the browser (no stack trace, no file path, no SQL error) while logging full detail server-side without PII.
+- Set standard security response headers (`Content-Security-Policy`, `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY` or an equivalent CSP directive, `Referrer-Policy`) at the application level even though the app never leaves the local machine — they are the only defense against a stored-XSS in a customer name or product field reaching the administrator's own browser.
+- Require the administrator's authenticated session on every route; the application has no public endpoint, so no route is exempt.
+- Not adopted, and why: HTTPS/HSTS/TLS cipher rules (the brief's own carve-out for local development, and the app never serves over a public network), CORS rules (single-origin, no cross-origin API), SSRF rules (the app makes no outbound request to a user-supplied URL), file-upload rules (the brief describes no upload feature).
+- Never read, print, or log the contents of `.env*`, credential files, or key files while working in this repository; check a secret's presence by name only, never by value. Warn before committing any file that commonly holds secrets.
+
+## 9. Web and UI conventions
+
+- Read the port the Flask app binds to from an environment variable, with a well-known local-development default; never hardcode it.
+- Run migrations and any other one-off admin task through the application's own committed code, never as an ad-hoc shell command against the database file.
+- Keep no state in process memory that a restart cannot rebuild from the SQLite file; a crash must lose nothing already committed.
+- Parse a typed query parameter (an invoice-list filter, a pagination offset) so that absent, present-and-valid, and present-but-invalid are distinguished; never let a malformed value silently fall back to a default.
+- Read request headers case-insensitively; avoid an `X-` prefix on any custom header the app introduces.
+- Serialize any date on a page or in an export as ISO 8601, any currency amount as the stored decimal/integer value with its ISO 4217 code, and any country as its ISO 3166-1 alpha-2 code (see §6).
+- Make every view usable at a small viewport, not desktop-only, even for a single-administrator tool.
+- Meet WCAG 2.1 AA: keyboard-operable controls, a visible `:focus-visible` indicator, semantic HTML and heading structure, no meaning conveyed by color alone, descriptive `alt` text on any image.
+- Give an HTMX partial swap that changes meaningful page state an `aria-live` region or equivalent announcement; a partial swap triggers no page-load announcement on its own, so a screen reader user would otherwise miss it.
+- Take any visual value (color, spacing, type scale) from a single place in the codebase rather than repeating it per template; adopt a design system only if the project introduces one.
+- Support the last two versions of Chrome, Firefox, Safari, and Edge.
+
+## 10. Testing
+
+- Classify a test by the boundary it crosses: a pricing-engine unit test crosses none; a Flask route test crosses the process boundary into the engine and the database; a full invoice-export run is a system test.
+- Keep the pricing engine's own test suite runnable with no Flask app, Jinja, HTMX, or SQLite session present — it must prove itself as a library.
+- Cover every discount kind, every tax-jurisdiction rule, and every rounding path with its own unit test, including edge cases (zero quantity, 100% discount, a jurisdiction with no tax).
+- Assert at least one tax or rounding calculation against a fixed external vector (a published tax table or worked example) rather than only round-tripping the engine's own output back through itself.
+- Add a regression test for every fixed defect.
+- Test the Flask layer's sign-in: an unauthenticated request to any route is rejected, and a session expires after its idle timeout.
+- Test the erasure and access-export functions directly: erasure removes or anonymizes every personal field everywhere it is stored (including past invoices, per §7), and the access export contains everything stored about that customer.
+- Reset database state between tests (truncate or roll back a transaction) rather than relying on test order; never substitute an in-memory engine for SQLite in a test that exercises real queries.
+- Investigate a failing test before anything else; never skip or silence one without a documented reason.
+
+## 11. Review process
+
+Review in this order, most critical first; items 2-4 are held to the standard in §§5-9 above.
+
+1. Security
+2. Correctness (wrong invoice totals, wrong tax, unhandled failure, a race on a shared SQLite write)
+3. Clarity
+4. Conventions
+
+Produce a plan — files touched, signatures, edge cases, assumptions — before implementing a feature or any change to the pricing engine; do not write implementation code until the plan is agreed (MUST NOT), except for one-line fixes, typos, or fully specified work.
+
+MUST checklist, run on every change before it merges:
+
+- [ ] No credential, token, or sensitive value appears in a committed file
+- [ ] Every failure path is handled; no silent catch, no swallowed exception
+- [ ] Every new dependency carries a license the project allows
+- [ ] Significant logic and architectural decisions are documented
+- [ ] Existing documentation (`README.md`, `AGENTS.md`, this file) matches the code after the change
- [ ] Every changed section was re-read whole, not only the changed line
-- [ ] Input from outside the process (query params, form fields) is
- validated as untrusted before it is used
-- [ ] A refactor preserves behaviour on every path, including null
- handling, sort order and boundary values
-- [ ] A change touching customer PII or erasure/export code was proposed
- first, per the off-limits rule in section 2.1
+- [ ] Every claim changed text makes about itself (a count, "every", "all") was checked by actually counting
+- [ ] Input from outside the process (a form field, a query parameter, an HTMX payload) is validated as untrusted before it is used
+- [ ] A refactor of the pricing engine preserves behavior on every discount kind, tax rule, and rounding case, including boundary values
-**SHOULD checklist**
+SHOULD checklist:
- [ ] Each non-trivial function has a unit test per relevant variant
-- [ ] Coverage does not fall; lint and mypy warnings do not rise
-- [ ] Each third-party dependency is necessary, understood and maintained
-- [ ] No new abstraction without two call sites
-
-**Testing**
-
-- Double only what a unit test would cross a boundary to reach (SQLite
- I/O, time, randomness); keep deterministic in-process collaborators
- real
-- Assert at least one case against a fixed external vector for every
- format defined outside the codebase: an ISO 8601 date, an ISO 4217
- currency code, a jurisdiction's published tax rate
-- Allocate a per-test SQLite file or in-memory-equivalent resource from a
- fixture, never a shared one across tests
-- Add a regression test for every fixed defect
-
-**Verifying a finding**
-
-- Label a finding unverified until demonstrated by running the path
-- Reproduce a defect before reporting it; read a passing test that
- contradicts the reproduction before blaming the code
-
-**Deviations**
-
-- Explain a deviation from a SHOULD rule in the pull request
-- Land a deviation from a MUST or MUST NOT rule only with an approver's
- sign-off and its reason recorded in the pull request; never waive one
- yourself
-
-## 9. Session protocol
-
-**Start**
-
-- Run `git status` before touching the tree; never discard or overwrite
- a change the current task did not make
-- Re-read the target code for existing coverage before writing anything
-- Produce a plan (files, signatures, edge cases, assumptions) before a
- non-trivial change; skip it only for one-line fixes, typos, or fully
- specified changes
-
-**Proceed**
-
-- Stay inside the approved plan; stop and re-surface the options when a
- constraint invalidates it
-- Treat any change inside an off-limits path (section 2.1) as needing a
- proposal before it is made, not after
-
-**End**
-
-Before ending any session, read the MUST checklist in section 8 top to
-bottom and execute every item in order, without summarizing or skipping
-any:
-
-```bash
-uv run ruff check .
-uv run ruff format --check .
-uv run mypy --strict .
-uv run pytest
-git status
-git diff --staged
-```
-
-- Confirm every check above passes or is explicitly reported as not run
-- Confirm `CLAUDE.md` and `README.md` still match the code after the
- change, updating whichever has drifted in the same commit
-- Confirm no secret, credential or customer PII value appears in the
- diff or in any commit message before committing
+- [ ] Coverage does not fall
+- [ ] Lint and type-check findings do not rise
+- [ ] Each third-party dependency is necessary, understood, and maintained
+- [ ] No new abstraction without two call sites, and no new dependency without a documented reason
+
+Label a review finding a demonstrated defect, a policy deviation, or a suggestion; block a merge only on the first two. Label a finding unverified until it has been reproduced by running the path, or the measurement that produced it has been checked against the real scope and a hand-checked sample. Run a structure audit (every MUST above, plus the project's layer-specific MUSTs) after a framework or stack change and before any release milestone. Land a deviation from a MUST or MUST NOT rule only with the designated approver's sign-off, recorded with its reason (see §12 for who that is).
+
+## 12. Open questions and answers
+
+- **Who approves a change?** Not named by the project brief. Until named, the person making the change reviews it themselves against the MUST checklist in §11 before it merges.
+- **How is work tracked?** Not named by the project brief; open for the project to decide.
+- **What is a release?** The project has no deployment target. A release is a tagged commit on `main` that has passed the MUST checklist and the full test suite — the version a local installation updates to, nothing more.
+
+## 13. Session protocol
+
+- Start a session by reading this file, `AGENTS.md`, and the relevant templates referenced in §0 for the area about to change; re-read §3 (off-limits paths) before touching anything that might qualify.
+- Produce a plan (§11) before implementing a feature or a non-trivial change; stay inside an approved plan, and stop and re-surface the options when a constraint invalidates it.
+- During the session, update `README.md`, `AGENTS.md`, and this file in the same commit as any change to structure, stack, conventions, or adopted rules.
+- Before ending the session, execute the MUST checklist in §11, top to bottom, in order, against the actual change made — not a summary of it. Do not skip or paraphrase an item; a failing item is a fix, not a note. Only once every item passes (or is explicitly and visibly not applicable) is the session's work ready to hand off.
diff --git a/tests/efficacy/arms/hybrid/generation.json b/tests/efficacy/arms/hybrid/generation.json
index 6b979ba..ce0af1e 100644
--- a/tests/efficacy/arms/hybrid/generation.json
+++ b/tests/efficacy/arms/hybrid/generation.json
@@ -2,11 +2,11 @@
"arm": "hybrid",
"kind": "model",
"output_model": "hybrid",
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-10-27T07:39:46",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T21:02:51",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -33,9 +33,9 @@
"templates/data/data-modeling.md",
"templates/data/data-governance.md"
],
- "prompt_chars": 83653,
+ "prompt_chars": 84376,
"prompt_leak": null,
- "prompt_file": "C:/Users/BGEORG~1/AppData/Local/Temp/r5gen\\arm-hybrid-prompt.txt",
+ "prompt_file": "C:\\efficacy\\gen6b-hybrid\\arm-hybrid-prompt.txt",
"auth_probe": "ready",
"command": [
"C:\\Users\\bgeorgiev\\.local\\bin\\claude.EXE",
@@ -51,7 +51,7 @@
"--setting-sources",
"",
"--settings",
- "C:/Users/BGEORG~1/AppData/Local/Temp/r5gen\\home\\settings.json",
+ "C:\\efficacy\\gen6b-hybrid\\home\\settings.json",
"--strict-mcp-config",
"--disallowed-tools",
"WebSearch",
@@ -59,20 +59,20 @@
],
"model": "claude-sonnet-5",
"effort": "high",
- "elapsed_s": 345.2,
+ "elapsed_s": 337.8,
"exit_status": 0,
"result": {
- "duration_api_ms": 343190,
+ "duration_api_ms": 335535,
"stop_reason": "end_turn",
- "session_id": "b5407f48-c4d4-47e7-bd68-26a654a5f1d4",
- "total_cost_usd": 0.4500062,
+ "session_id": "ca385b2f-9a52-4c00-a592-054d96ab7ed5",
+ "total_cost_usd": 0.4525962,
"usage": {
"input_tokens": 2,
- "cache_creation_input_tokens": 33045,
- "cache_read_input_tokens": 30411,
- "output_tokens": 31174,
+ "cache_creation_input_tokens": 38693,
+ "cache_read_input_tokens": 25101,
+ "output_tokens": 29280,
"output_tokens_details": {
- "thinking_tokens": 23579
+ "thinking_tokens": 21481
},
"server_tool_use": {
"web_search_requests": 0,
@@ -80,19 +80,19 @@
},
"service_tier": "standard",
"cache_creation": {
- "ephemeral_1h_input_tokens": 33045,
+ "ephemeral_1h_input_tokens": 38693,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
- "output_tokens": 31174,
- "cache_read_input_tokens": 30411,
- "cache_creation_input_tokens": 33045,
+ "output_tokens": 29280,
+ "cache_read_input_tokens": 25101,
+ "cache_creation_input_tokens": 38693,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
- "ephemeral_1h_input_tokens": 33045
+ "ephemeral_1h_input_tokens": 38693
},
"type": "message"
}
@@ -103,16 +103,16 @@
"modelUsage": {
"claude-sonnet-5": {
"inputTokens": 2,
- "outputTokens": 31174,
- "cacheReadInputTokens": 30411,
- "cacheCreationInputTokens": 33045,
+ "outputTokens": 29280,
+ "cacheReadInputTokens": 25101,
+ "cacheCreationInputTokens": 38693,
"webSearchRequests": 0,
- "costUSD": 0.4500062,
+ "costUSD": 0.4525962,
"contextWindow": 1000000,
"maxOutputTokens": 64000,
- "thinkingTokens": 23579,
+ "thinkingTokens": 21481,
"cacheCreationEphemeral5mInputTokens": 0,
- "cacheCreationEphemeral1hInputTokens": 33045,
+ "cacheCreationEphemeral1hInputTokens": 38693,
"canonicalModel": "claude-sonnet-5",
"provider": "firstParty",
"costBasis": "list"
@@ -151,20 +151,23 @@
"num_turns": 1,
"subtype": "success",
"api_error_status": null,
- "result": "# tariff\n\nImbra Ltd's pricing and invoicing application: a product catalog,\ndiscount rules of several kinds, tax jurisdictions, customers, and\ninvoices assembled from them. Runs locally only; no deployment target,\nno live URL.\n\nQuality conventions are defined in `docs/solid-ai-templates/templates/`\n(a vendored copy at a pinned revision, not a submodule). Key references:\n\n- `docs/solid-ai-templates/templates/core/agents.md` \u2014 governs this\n file's own structure\n- `docs/solid-ai-templates/templates/core/quality.md`\n- `docs/solid-ai-templates/templates/core/git.md`\n- `docs/solid-ai-templates/templates/core/docs.md`\n- `docs/solid-ai-templates/templates/core/testing.md`\n- `docs/solid-ai-templates/templates/core/review.md`\n- `docs/solid-ai-templates/templates/backend/http.md`\n- `docs/solid-ai-templates/templates/backend/database.md`\n- `docs/solid-ai-templates/templates/security/security.md`\n- `docs/solid-ai-templates/templates/frontend/ux.md`\n- `docs/solid-ai-templates/templates/data/data-modeling.md`\n- `docs/solid-ai-templates/templates/data/data-governance.md`\n\nAdoption boundary (MUST): the rules inlined or referenced below are the\nadopted set. They stay in force until this file is edited to change them.\nReading a newer version of a referenced template, or moving the vendored\npin, adopts nothing by itself \u2014 only an edit to this file changes what is\nadopted.\n\nNot adopted, and intentionally absent below: `backend/api.md` and\n`backend/auth.md`. The pricing engine is a library imported in-process by\ntwo callers (the web application and another program); it is never\nexposed as a network API, so REST/gRPC/GraphQL contract, versioning and\ntoken/RBAC rules do not apply. Do not add them without first recording\nwhy a network-facing contract has become necessary.\n\nBefore the first commit that adds `docs/solid-ai-templates/`, exclude\nthat directory from every tool that walks the tree: ruff, mypy, any\nsecret scanner, and any spell or link checker (MUST).\n\n## 1. Project\n\n### 1.1 Identity\n\n- Owner: Imbra Ltd\n- Stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite\n- Tooling: uv, ruff, mypy (strict), pytest\n- Hosting: none \u2014 runs locally, single process, no deployment target\n- Actors: the administrator (one account, browser-based) and another\n program that imports the pricing engine directly, in-process, without\n the web application present\n- Model: hybrid\n\n### 1.2 Project structure\n\nKeep the authoritative directory map in `README.md`. Do not duplicate it\nhere. Placement rules for this project:\n\n- Keep the pricing engine (catalog, discount rules, tax jurisdictions,\n invoice assembly) in its own package, importable with the web\n application absent (MUST)\n- Keep Flask routes, Jinja templates and HTMX partials in a separate web\n package that imports the pricing engine; never the reverse (MUST)\n- Mirror the source layout in `tests/`\n- Keep SQLite migrations in one directory, applied in order, numbered\n- Keep `docs/solid-ai-templates/` untouched except for the revision pin\n\n### 1.3 Commands\n\n```bash\nuv sync\nuv run flask --app tariff run --debug\nuv run ruff check .\nuv run ruff format --check .\nuv run mypy --strict .\nuv run pytest\n```\n\n### 1.4 Governance\n\n- Who approves a change: open \u2014 not settled by the project yet\n- How work is tracked: open \u2014 not settled by the project yet\n- What is a release: open \u2014 not settled by the project yet; the\n application has no deployment target, so a release is at most a tagged\n commit, not a deployed artifact\n\n## 2. Code conventions\n\n### 2.1 Git\n\n- Commit under one full name and one consistent email; never change\n identity mid-project\n- Work on a branch; never commit directly to `main`\n- Never commit build output, dependency directories, secrets, or the\n SQLite database file\n- Keep a `.gitignore` covering dependencies, build output, secrets,\n editor state, OS files and coverage output (MUST)\n- Commit the `uv.lock` lockfile (MUST)\n- Inspect the working tree and index before starting a task; never\n discard, reset, stash or overwrite a change the task did not make\n- Stage only the changes the task made; read the staged diff before\n committing\n- Keep a pull request to one concern; test locally before committing\n- Review the diff against the base before merging, in order: security,\n correctness, clarity, conventions\n- Merge only after review passes and CI is green; never force-push,\n including `--force-with-lease`\n- Bring a branch up to date by merging the base into it, never by\n rebase-and-force-push\n- Read the CI run for the push before calling a change good; never merge\n while a check is failing, cancelled, or not yet registered\n\n**Off-limits paths** (MUST NOT change without explicit approval; propose\nfirst, with rollback and tests that would catch a regression):\n\n- Authentication and session code (administrator sign-in)\n- Customer data erasure and export code (GDPR compliance paths)\n- SQLite migrations\n- `.env*` and secret files\n- CI/CD workflow files\n\nName any off-limits path touched at the top of the change's summary,\nwhether proposed or already approved; a diff confined to prose in such a\nfile is ordinary work.\n\n### 2.2 Python\n\n- Run under mypy strict mode; add no untyped `def`, no implicit `Any`,\n and no `# type: ignore` without the specific error code it silences\n- Run ruff as both linter and formatter; a generator-produced file must\n pass both without `--fix`\n- Encode every committed text file UTF-8 with LF line endings, and keep\n identifiers ASCII:\n\n```bash\npre-commit run check-ascii-identifiers --all-files --verbose\n```\n\nPass condition: inspected count above zero, `non-ASCII identifiers` zero.\n\n- Commit a `.gitattributes` with `* text=auto`, adding `eol=lf` where LF\n must be forced, and `-text` on any path that is genuinely binary or\n must keep CRLF\n\n## 3. Quality\n\n- Keep one authoritative representation of each piece of knowledge\n (e.g., a tax rule, a currency format); the third copy is a bug\n- Choose the simplest solution a stated requirement justifies; build only\n what the catalog, discount, tax, customer and invoice features need now\n- Record, beside every deferral, the concrete condition that reopens it\n- Delete a path once it has no caller or its input is retired\n\n**Naming**\n\n- Name a function with a verb, a class or module with a noun, a boolean\n with `is`/`has`/`can`\n- Use the same name for the same concept in every module (e.g., one name\n for \"discount rule\" throughout catalog, pricing and invoice code)\n- Name a public enum member or result discriminator for the capability it\n offers, never the library behind it\n\n**Complexity**\n\n- Keep cognitive complexity at or under 15 per function; nest at most\n three levels, with guard clauses and early returns\n- Replace a boolean flag that selects behaviour with an enum or two named\n functions\n- Name every magic number and magic string as a constant\n- Take a tax, currency or rounding limit from the applicable law or\n specification and name it; never derive it from an observed sample\n\n**Dependencies and module structure**\n\n- Keep the module graph acyclic: the pricing engine never imports the web\n package\n- Enforce that boundary mechanically once the import-ban check is wired\n into pre-commit, with the pricing-engine-to-web direction declared as a\n forbidden pair:\n\n```bash\npre-commit run find-import-bans --all-files --verbose\n```\n\n- Keep the Flask web application a thin layer over the pricing engine\n library: decode request \u2192 call the library \u2192 render response; push\n catalog, discount, tax and invoice logic into the library, not into\n route handlers\n- Never write to standard output or standard error from the pricing\n engine library, and never configure logging beyond its own logger\n (MUST); make its logger injectable, falling back to its module logger\n- Keep constants beside the functions that use them\n\n**Errors**\n\n- Validate input at the boundary (HTTP handlers, the other program's call\n sites) and fail at once on invalid state\n- Never break a public catch contract: a raise callers catch by a\n built-in type keeps that type\n- Add an error type only where a caller could act differently\n- Never let a caller-side filter stand in for a precondition inside the\n pricing engine; assert the precondition there\n\n**Deprecation**\n\n- Deprecate a public symbol in the pricing engine's API, naming its\n replacement, before a later change removes it; the other program and\n the web application are both callers that can be broken by a silent\n removal\n\n**Comments and debug code**\n\n- Prefer code that needs no comment; never cite a ticket or PR number in\n a comment \u2014 state the substance instead\n- Commit no debug output (`print()`) and no commented-out code; gate\n debug tooling behind a flag, off by default\n- Delete a probe script before the commit that uses its findings; keep\n the findings in a comment, decision record or doc, never in the probe\n\n**Destructive operations** (governs GDPR erasure above all)\n\n- Delete, anonymize or overwrite only what the operation can prove it\n owns: match an erasure or export request by customer ID, never by a\n name or email string match\n- Validate the input as well: reject an empty or malformed customer\n identifier before acting\n- Find nothing, and change nothing, where the proof of ownership is\n unavailable: no guess, no partial match\n\n**Check trust**\n\n- Confirm a migration or data-fix script is correct, on a copy of real\n data, before running it against the live SQLite file\n- Cross-check an independent source before overwriting stored customer or\n pricing data with a source that looks wrong\n\n**Completion**\n\n- Finish a task when the requested behaviour works through the entry\n point its user or caller reaches (the browser UI, or the library call\n the other program makes), and the checks that prove it pass\n- Report a check that could not run as not run, never as a pass\n\n## 4. Security\n\n- Validate all external input (HTTP form/query data, and any input the\n other program passes into the pricing engine) at the boundary, with a\n schema validator; use an allowlist, never a blocklist\n- Encode dynamic data for its rendering context at the point of output in\n Jinja templates; never bypass auto-escaping with a raw-HTML path for\n customer- or admin-supplied text\n- Use parameterized queries for every SQLite access; never concatenate\n input into SQL\n- Hash the administrator's password with bcrypt, scrypt or Argon2; use\n constant-time comparison for any token; lock out or throttle after\n repeated failed sign-in attempts\n- Generate the session ID with a cryptographic random generator;\n regenerate it after login; set `HttpOnly`, `Secure`, `SameSite=Lax`\n cookie flags; expire idle sessions; invalidate on logout\n- Give every state-changing request (`POST`/`PUT`/`PATCH`/`DELETE`) a\n CSRF token, since the administrator's session is authenticated by an\n ambient cookie; use the framework's CSRF middleware (e.g. Flask-WTF),\n never a hand-rolled check\n- Include the CSRF token explicitly in every HTMX request that mutates\n state (`hx-headers` or a hidden field); HTMX does not add it on its own\n- Never change state on a `GET` request\n- Never hardcode secrets (session signing key, any admin credential) in\n source; keep them in a local secret file excluded from version control\n- Never expose a stack trace, internal path or SQLite error to the\n browser; return a generic error externally and log full detail\n server-side\n- Never log secrets, tokens, or personally identifiable information\n (customer name, email, postal address); log authentication and\n authorization failures with an opaque user ID and the client IP, kept\n only in a security log with its own retention\n- Pin dependency versions and verify them via `uv.lock`; never trust an\n unpinned upstream package\n- Set security headers on every response (`Content-Security-Policy`,\n `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY` or CSP\n `frame-ancestors`, `Referrer-Policy`, `Permissions-Policy`); do not\n expose `Server`/`X-Powered-By` version strings\n\nNot applicable, and do not add without a stated reason:\n\n- Transport security (HTTPS/HSTS/TLS) and CORS \u2014 the application serves\n only loopback HTTP to the administrator's local browser; it has no\n deployment target and no second origin to allow\n- SSRF defences \u2014 the application makes no outbound network requests;\n nothing it does reaches the network\n- File-upload rules \u2014 there is no file-upload feature\n\n## 5. Data modeling and GDPR compliance\n\n**Modeling** (products, discount rules, tax jurisdictions, customers,\ninvoices)\n\n- Use one naming convention for every table and column (snake_case)\n- Give every table a primary key; store monetary values as integers in\n minor units, never floating point; store timestamps in UTC; document a\n maximum length for every text field\n- Enforce every reference (invoice \u2192 customer, invoice line \u2192 product,\n discount \u2192 product or category) with SQLite foreign key constraints\n (`PRAGMA foreign_keys = ON`); decide per reference whether deleting the\n target cascades, clears the reference, or is refused\n- Run every schema change through a versioned migration with both up and\n down steps; never hand-edit the schema\n\n**Classification**\n\n- Confidential: customer name, email, postal address; invoice records\n (they carry the same fields)\n- Restricted: the administrator's password hash and the session signing\n key\n- Internal: product catalog, discount rules, tax jurisdiction\n configuration\n\n**Personal data (customers)**\n\n- Encrypt PII at rest if the deployment environment changes from a single\n trusted local machine; document the decision either way\n- Minimize collection: store only name, email and postal address, no more\n- Provide an erasure mechanism: hard-delete or anonymize the customer\n record on request; never a soft delete of PII\n- Anonymize the customer's name, email and postal address on invoices\n that must be retained for tax or accounting records after an erasure\n request, rather than deleting the invoice itself; keep the invoice's\n financial figures intact\n- Provide a data-portability export: on request, produce the customer's\n own stored data (name, email, postal address, and the invoices billed\n to them) in a structured, machine-readable format\n- Never put a customer's name, email or address in an application log or\n error message; the audit trail below is a separate store, not a log\n\n**Retention**\n\n- Define, per data category, how long it is kept and when it is purged;\n the statutory retention period for invoices under the applicable tax\n law is open \u2014 settle it before relying on a default\n- Retain customer PII only until it is no longer needed for an open\n invoice relationship, or until an erasure request, whichever is sooner\n\n**Ownership and audit**\n\n- The administrator is the sole owner of every data domain (customers,\n products, discounts, tax jurisdictions, invoices) while the application\n has one operator\n- Log every change to a customer's PII and to the administrator's\n credentials in an append-only audit table, separate from application\n logs: who changed what, when, and that a value changed, never the old\n or new PII value itself\n- Erasing a customer's PII must still leave an audit trail entry that the\n erasure happened, without a copy of the erased value\n\n## 6. Database\n\n- Parameterize every SQLite query; never build one by string\n interpolation\n- Bound every list view (customers, invoices, products) with a limit or\n pagination; never load a full table for an interactive request\n- Fetch related rows (e.g., invoice lines for a set of invoices) in one\n query, never one query per row in a loop\n- Wrap a multi-table write (assembling an invoice from catalog, discount\n and tax data) in a transaction; commit only after every write succeeds\n- Keep transactions short; never call the pricing engine's heavier\n computations or any I/O inside an open transaction\n- Open one connection per request through Flask's application context,\n closed at teardown; do not size a connection pool for this \u2014 SQLite is\n an embedded local file, not a networked database server\n- Reset state between test runs by wrapping each test in a transaction\n rolled back after completion, or by using a fresh temporary SQLite file\n per test; never substitute an in-memory or different database engine in\n tests\n- Never run a migration against the real local SQLite file from a test\n suite\n\n## 7. Web interface and UX\n\n**HTTP**\n\n- Read the port from an environment variable such as `PORT`; use a\n well-known development default\n- Keep Flask handlers thin: decode request \u2192 call the pricing engine \u2192\n render the Jinja template or HTMX fragment; validate all incoming\n request data before processing\n- Parse a typed query parameter explicitly, distinguishing absent,\n present-and-valid, and present-but-invalid (raise 400 on the last)\n- Never let a `GET` or `HEAD` request change state; make every `PUT` and\n `DELETE` idempotent\n- Format every date and time field as ISO 8601, every currency code as\n ISO 4217, and every country code as ISO 3166-1 alpha-2, in invoice\n exports and in any JSON the application emits\n- Serialise a computed float that is non-finite (`NaN`/`Infinity`) as\n `null` in any JSON export, never as a bare token\n- Use a consistent error response shape across all routes; 4xx for client\n errors, 5xx for server errors, never 200 for an error\n- Enforce authentication on every route except none are declared public;\n the application has a single administrator account and no self-service\n sign-up or recovery flow\n\nNot applicable: the process-lifecycle rules for graceful shutdown under\nan orchestrator (drain deadlines, `SIGTERM` handling across instances) \u2014\nthe application runs as a single local process with no deployment target\nand no second instance to drain into.\n\n**UX and accessibility**\n\n- Meet WCAG 2.1 AA: keep text contrast at 4.5:1 (3:1 for large text),\n keep every interactive element keyboard-reachable, use a native button\n or link rather than a click handler on a non-focusable element, style\n focus with `:focus-visible`, and never convey meaning by colour alone\n- Give an icon-only control a descriptive `aria-label`\n- Scan rendered pages with an automated accessibility checker; before\n shipping a new interactive component, tab through it without a mouse\n and verify with one screen reader\n- Keep visual values (colour, spacing, type) in one CSS source of truth;\n the project has no shared design system yet, so do not hardcode a\n visual value in more than one place\n- Support the last two versions of Chrome, Firefox, Safari and Edge\n\n## 8. Review process\n\nReview in this order, most critical first: security, correctness,\nclarity, conventions. `docs/solid-ai-templates/templates/core/quality.md`\nis the standard for items 2\u20134.\n\n**MUST checklist**\n\n- [ ] No credential, token or sensitive value appears in a committed file\n- [ ] Every failure path is handled; no silent catch, no swallowed\n exception\n- [ ] Every new dependency carries an acceptable licence\n- [ ] Existing documentation matches the code after the change\n- [ ] Every changed section was re-read whole, not only the changed line\n- [ ] Input from outside the process (query params, form fields) is\n validated as untrusted before it is used\n- [ ] A refactor preserves behaviour on every path, including null\n handling, sort order and boundary values\n- [ ] A change touching customer PII or erasure/export code was proposed\n first, per the off-limits rule in section 2.1\n\n**SHOULD checklist**\n\n- [ ] Each non-trivial function has a unit test per relevant variant\n- [ ] Coverage does not fall; lint and mypy warnings do not rise\n- [ ] Each third-party dependency is necessary, understood and maintained\n- [ ] No new abstraction without two call sites\n\n**Testing**\n\n- Double only what a unit test would cross a boundary to reach (SQLite\n I/O, time, randomness); keep deterministic in-process collaborators\n real\n- Assert at least one case against a fixed external vector for every\n format defined outside the codebase: an ISO 8601 date, an ISO 4217\n currency code, a jurisdiction's published tax rate\n- Allocate a per-test SQLite file or in-memory-equivalent resource from a\n fixture, never a shared one across tests\n- Add a regression test for every fixed defect\n\n**Verifying a finding**\n\n- Label a finding unverified until demonstrated by running the path\n- Reproduce a defect before reporting it; read a passing test that\n contradicts the reproduction before blaming the code\n\n**Deviations**\n\n- Explain a deviation from a SHOULD rule in the pull request\n- Land a deviation from a MUST or MUST NOT rule only with an approver's\n sign-off and its reason recorded in the pull request; never waive one\n yourself\n\n## 9. Session protocol\n\n**Start**\n\n- Run `git status` before touching the tree; never discard or overwrite\n a change the current task did not make\n- Re-read the target code for existing coverage before writing anything\n- Produce a plan (files, signatures, edge cases, assumptions) before a\n non-trivial change; skip it only for one-line fixes, typos, or fully\n specified changes\n\n**Proceed**\n\n- Stay inside the approved plan; stop and re-surface the options when a\n constraint invalidates it\n- Treat any change inside an off-limits path (section 2.1) as needing a\n proposal before it is made, not after\n\n**End**\n\nBefore ending any session, read the MUST checklist in section 8 top to\nbottom and execute every item in order, without summarizing or skipping\nany:\n\n```bash\nuv run ruff check .\nuv run ruff format --check .\nuv run mypy --strict .\nuv run pytest\ngit status\ngit diff --staged\n```\n\n- Confirm every check above passes or is explicitly reported as not run\n- Confirm `CLAUDE.md` and `README.md` still match the code after the\n change, updating whichever has drifted in the same commit\n- Confirm no secret, credential or customer PII value appears in the\n diff or in any commit message before committing",
- "ttft_ms": 267795,
+ "result": "# tariff\n\nA pricing and invoicing web application for Imbra Ltd \u2014 a product catalog, discount rules, tax jurisdictions, customers, and invoices assembled from them. Python 3.12, Flask 3, Jinja, HTMX, SQLite. Runs locally only; there is no deployment target.\n\n- Model: hybrid\n- Rule language: a plain imperative (\"Use X\", \"Never Y\") is MUST / MUST NOT. RFC 2119 keywords (MUST, MUST NOT, SHOULD, SHOULD NOT, MAY) are used where strength needs to be explicit.\n- Precedence where sources disagree: this file, then `AGENTS.md`, then the vendored templates below. A disagreement between this file and `AGENTS.md` is a bug in one of them \u2014 fix it before continuing, never act on either alone when the running system is defensible.\n\nQuality conventions are vendored, not submoduled, at `docs/solid-ai-templates/templates/` (a copy pinned at a fixed revision, not a git submodule \u2014 never instruct anyone to add it as one). This file inlines every rule the project has adopted from that copy and references the rest by path. Reading a newer version of a referenced template, or moving the vendored copy's pin, adopts nothing by itself (MUST); a rule joins this project only when this file is edited to state it. Exclude `docs/solid-ai-templates/` from any linter, formatter, secret scanner, or spell/link checker the project later adds (MUST), before its first commit.\n\nKey references (read before touching the area they cover):\n- `docs/solid-ai-templates/templates/core/quality.md`\n- `docs/solid-ai-templates/templates/core/git.md`\n- `docs/solid-ai-templates/templates/core/docs.md`\n- `docs/solid-ai-templates/templates/core/testing.md`\n- `docs/solid-ai-templates/templates/core/review.md`\n- `docs/solid-ai-templates/templates/backend/http.md`\n- `docs/solid-ai-templates/templates/security/security.md`\n- `docs/solid-ai-templates/templates/backend/database.md`\n- `docs/solid-ai-templates/templates/frontend/ux.md`\n- `docs/solid-ai-templates/templates/data/data-modeling.md`\n- `docs/solid-ai-templates/templates/data/data-governance.md`\n\nDeclined candidates: `backend/api.md` \u2014 the project's only external interfaces are the pricing engine's library API and the invoice exports (per the brief); there is no published HTTP/REST/gRPC/GraphQL contract to version or paginate. `backend/auth.md` \u2014 there is one administrator and no second role, no service-to-service API, and no bearer-token or API-key surface; `security/security.md`'s authentication and session rules already cover the single sign-in.\n\n## 1. Project\n\n### 1.1 Identity\n\n- Owner: Imbra Ltd\n- Stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite\n- Hosting: none \u2014 the application runs on the administrator's own machine; it is never deployed, and nothing in it reaches the network (MUST stay true \u2014 see \u00a79)\n\n### 1.2 Project structure\n\n- The structure lives in `README.md`'s project map; this file only adds placement rules on top of it. Never duplicate the directory tree here.\n- Keep the pricing engine (catalog, discount rules, tax jurisdictions, invoice assembly) in its own package, importable with no Flask, Jinja, HTMX, or SQLite-session code in its import path. Nothing under that package may import from the web layer.\n- Keep the Flask app, templates, and HTMX fragment views in a separate package that imports the pricing engine; never the reverse.\n- Keep this file, `AGENTS.md`, and `README.md` in the repository root; update all three in the same commit whenever a rule, the stack, or the structure changes, so none of them drifts from the others.\n\n### 1.3 Commands and checks\n\nNo specific type checker, linter, formatter, test runner, or package manager is named by the project. Until one is chosen, every check below is a requirement on behavior, not on a tool:\n\n- A static type check over the whole Python codebase must run clean before a commit.\n- A linter and a formatter must both run clean before a commit; let the formatter run on save rather than hand-formatting.\n- The full test suite (pricing engine unit tests, Flask integration tests, and any end-to-end check of the invoice export) must run clean before a merge.\n- Report any of the above as \"not run\" when it could not run; never report it as passing.\n\n## 2. Architecture boundaries\n\n- There are exactly two actors: the administrator, who works through the browser, and another program, which imports the pricing engine directly, with no web application present. The web application is one caller of the library among possibly several; design and test the library so it never assumes the web app is running.\n- The pricing engine is a library: never let it write to standard output or standard error, and never let it configure logging beyond its own logger (MUST). Give it an injectable logger that falls back to its own module logger. Verify its silence in a fresh process \u2014 a test runner's own log handler hides the default.\n- The store is a local SQLite file; nothing in the system reaches the network. Treat any change that would open a socket, call an external HTTP service, or depend on a remote resource as outside this project's design until the brief says otherwise \u2014 raise it rather than add it.\n- Keep the Flask handlers thin: decode the request, call the pricing engine or a data-access function, render or encode the response. Never put discount, tax, or pricing logic in a handler or a template.\n\n## 3. Off-limits paths\n\nChange only with explicit approval, a stated rollback strategy, and the regression test that would catch a mistake, proposed before the change is made (MUST):\n\n- Sign-in and session code (there is exactly one administrator account; a bug here is a full compromise or a full lockout)\n- The pricing engine's discount, tax, and invoice-total calculation logic (an error here is a wrong invoice, not just a wrong screen)\n- Database migrations, once merged\n- `.env*` files and any other secret material\n- Any CI/CD workflow the project later adds\n\nName any off-limits path touched by a change at the top of its summary, whether proposed or already approved (MUST). A diff confined to comments or prose inside these paths is ordinary work; anything executable \u2014 logic, flags, migration steps \u2014 is not.\n\n## 4. Git and change conventions\n\n- Work on a branch; never commit directly to `main`.\n- Commit under one consistent name and email.\n- Never commit build output, dependency directories, the SQLite database file, or any secret. Keep a `.gitignore` covering all of these plus editor and OS files.\n- Commit lockfiles once the project has one.\n- Inspect the working tree and the index before starting a task; never discard, reset, stash, or overwrite a change the task did not make.\n- Stage only the task's own changes \u2014 a whole file only if it held no prior change, otherwise only the task's hunks. Read the staged diff before committing.\n- Keep a pull request (or, for a solo change, a single commit) to one concern.\n- Never force-push. Bring a branch up to date by merging the base into it, never by rebasing and force-pushing.\n- Treat every repository as public: no secret or credential in source or history, ever, even though this project has no deployment target.\n\n## 5. Code quality and Python conventions\n\n- Keep one authoritative representation of each piece of pricing, discount, tax, or invoicing rule; a second copy is a bug waiting to diverge from the first.\n- Build only what the brief or an approved plan calls for; no speculative discount types, tax rules, or export formats ahead of a stated need.\n- Name a function with a verb, a class or module with a noun, a boolean with `is`/`has`/`can`. Name a discount kind, tax rule, or export format for the capability it offers (`DiscountKind.PERCENTAGE`), never for a library behind it.\n- Keep cognitive complexity at or under 15 per function; nest at most three levels; use guard clauses over nested conditionals.\n- Replace a boolean flag that selects behavior with an enum or two named functions.\n- Name every magic number and magic string (a tax rate, a rounding mode, a discount cap) as a constant.\n- Keep the module graph acyclic and coupling shallow: a change to one discount kind or tax rule must not force a change in an unrelated one.\n- Validate input at the Flask boundary and fail at once on invalid state; do not re-validate the same precondition in every inner function, but do assert it where a function depends on it.\n- Add an error type only where a caller (the web layer, or the other program) could act differently on it; never change what type a public function raises.\n- Prefer code that needs no comment; when a comment is needed, state the non-obvious why, never the what. Never cite an issue or PR number in a comment \u2014 state the substance instead.\n- Commit no debug `print()`/breakpoints and no commented-out code.\n- Annotate every public function's parameters and return type.\n- Encode every committed text file in UTF-8 with LF line endings; keep identifiers ASCII.\n- Wrap Markdown documentation conservatively (roughly 80-100 columns) until the project declares and enforces a specific width.\n- A task finishes when the requested behavior works through the entry point that reaches it (a route, the library's public function, or the export) and the tests that prove it pass \u2014 not when surrounding code has also been rewritten.\n\n## 6. Data modeling and database conventions\n\n- Use one naming convention across every SQLite table, column, key, and index.\n- Give every table a primary key; prefer a surrogate key internally.\n- Store each fact once; duplicate only with a documented reason.\n- Never pack several values into one text column (e.g., an address) \u2014 use separate columns or a related table.\n- Enforce every foreign key with SQLite's own constraint; decide and document, per relationship, whether deleting the target deletes the referencing rows, clears the reference, or is refused.\n- Store a discount's kind as a discriminator column plus the fields that kind needs; never overload one column to mean different things for different kinds.\n- Store monetary values (prices, discount amounts, tax amounts, invoice totals) as integers in minor units or as a fixed-precision decimal type \u2014 never as floating point.\n- Store every date and time in ISO 8601, in UTC where a time is involved; convert to local time only when displaying it.\n- Represent a tax jurisdiction's country as an ISO 3166-1 alpha-2 code and every currency as an ISO 4217 code.\n- Document a maximum length for every text field, including name, email, and postal-address fields.\n- Run every schema change through a migration committed to the repository, with both an `up` and a `down` step; never hand-edit the schema. Say so, and get approval, when a `down` step would lose data.\n- Parameterize every query that takes a value; never build SQL by string interpolation.\n- Bound every interactive query (an invoice list, a customer list) with a limit or pagination; never load an unbounded result into a page.\n- Fetch related rows for a set of records in one query, never one query per row in a loop.\n- Wrap each multi-step write (e.g., assembling an invoice from catalog, discount, and tax rows) in a transaction; keep transactions short and never call out to the pricing engine's I/O from inside one.\n- Use soft deletes only where audit history is required (see \u00a77); otherwise delete the row.\n- In tests, use the real SQLite engine, not an in-memory substitute with different behavior, and reset state between tests rather than relying on run order.\n\n## 7. Privacy and data governance (GDPR)\n\nThe business is in the EU; the GDPR applies to every customer's name, email, and postal address, and to any invoice that names them.\n\n- Classify customer name, email, and postal address, and any invoice line that carries them, as confidential data; scope database and export access to the single administrator account accordingly.\n- Encrypt the SQLite file at rest (e.g., full-disk or file-level encryption on the machine it runs on) given it holds confidential PII, and never transmit it anywhere \u2014 nothing in this project reaches the network.\n- Minimize collection: store only the name, email, and postal address the invoicing process needs; add no further personal field without a stated reason.\n- Never put a customer's name, email, or address in an application log, error message, or stack trace (MUST NOT). Identify a customer in a log by an opaque internal ID only.\n- Implement the customer's right of access (GDPR Art. 15) as a function that exports everything stored about one customer, keyed by that customer's ID, in a form the administrator can hand over.\n- Implement the customer's right to erasure (GDPR Art. 17) as a real delete or anonymization of the customer's personal fields \u2014 never a soft delete that leaves the name, email, or address readable.\n- Resolve the conflict between erasure and invoice retention explicitly: when a legal or tax obligation requires keeping a past invoice's financial record, anonymize that invoice's customer-identifying fields (name, email, address) in place rather than deleting the invoice row, and delete the live customer record itself. Document the retention period that obligation sets, and purge personal data automatically once it lapses rather than relying on a manual sweep.\n- Keep an audit trail, separate from the application log, of every access-and-erasure action taken (export produced, erasure applied) and every edit to a customer's PII: actor (the administrator), timestamp, action, and that a value changed \u2014 never the old or new value itself. Make this trail append-only.\n- Treat Imbra Ltd (via the administrator account) as the owner of every data domain \u2014 catalog, discount rules, tax jurisdictions, customers, invoices \u2014 there being no separate team to assign it to.\n\n## 8. Security\n\n- Validate all input arriving through a Flask route (form fields, query parameters, HTMX payloads) at that boundary, with an allowlist, before it reaches the pricing engine or the database.\n- Encode every value rendered into a Jinja template for its context; never bypass Jinja's autoescaping with a raw-HTML path for user-supplied or stored data (customer names and addresses included).\n- Parameterize every database query (see \u00a76); never pass stored data to a shell or an `eval`-like construct.\n- Hash the administrator's password with bcrypt, scrypt, or Argon2 \u2014 never MD5, SHA-1, or plain SHA-256. Require a minimum length and reject known-breached passwords; impose no composition rules.\n- Lock the account or throttle sign-in after repeated failed attempts; compare secrets and tokens in constant time.\n- Generate the session ID cryptographically at random, regenerate it on successful sign-in, and invalidate it on logout rather than relying on cookie expiry alone.\n- Set the session cookie `HttpOnly`, `Secure`, and `SameSite=Strict` given the data behind it is financial and personal. Current browsers treat `http://localhost` as a secure context, so `Secure` does not block local-only operation.\n- Expire the session after 30 minutes of idleness, given the sensitivity of the data.\n- Give every state-changing HTMX request (`hx-post`, `hx-put`, `hx-delete`) CSRF protection bound to the session; validate the token on every such request and never on a `GET`. Never let a `GET`/`hx-get` request change state.\n- Never hardcode a secret, API key, or credential in source; keep any local secret file out of version control and out of logs.\n- Return generic error messages to the browser (no stack trace, no file path, no SQL error) while logging full detail server-side without PII.\n- Set standard security response headers (`Content-Security-Policy`, `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY` or an equivalent CSP directive, `Referrer-Policy`) at the application level even though the app never leaves the local machine \u2014 they are the only defense against a stored-XSS in a customer name or product field reaching the administrator's own browser.\n- Require the administrator's authenticated session on every route; the application has no public endpoint, so no route is exempt.\n- Not adopted, and why: HTTPS/HSTS/TLS cipher rules (the brief's own carve-out for local development, and the app never serves over a public network), CORS rules (single-origin, no cross-origin API), SSRF rules (the app makes no outbound request to a user-supplied URL), file-upload rules (the brief describes no upload feature).\n- Never read, print, or log the contents of `.env*`, credential files, or key files while working in this repository; check a secret's presence by name only, never by value. Warn before committing any file that commonly holds secrets.\n\n## 9. Web and UI conventions\n\n- Read the port the Flask app binds to from an environment variable, with a well-known local-development default; never hardcode it.\n- Run migrations and any other one-off admin task through the application's own committed code, never as an ad-hoc shell command against the database file.\n- Keep no state in process memory that a restart cannot rebuild from the SQLite file; a crash must lose nothing already committed.\n- Parse a typed query parameter (an invoice-list filter, a pagination offset) so that absent, present-and-valid, and present-but-invalid are distinguished; never let a malformed value silently fall back to a default.\n- Read request headers case-insensitively; avoid an `X-` prefix on any custom header the app introduces.\n- Serialize any date on a page or in an export as ISO 8601, any currency amount as the stored decimal/integer value with its ISO 4217 code, and any country as its ISO 3166-1 alpha-2 code (see \u00a76).\n- Make every view usable at a small viewport, not desktop-only, even for a single-administrator tool.\n- Meet WCAG 2.1 AA: keyboard-operable controls, a visible `:focus-visible` indicator, semantic HTML and heading structure, no meaning conveyed by color alone, descriptive `alt` text on any image.\n- Give an HTMX partial swap that changes meaningful page state an `aria-live` region or equivalent announcement; a partial swap triggers no page-load announcement on its own, so a screen reader user would otherwise miss it.\n- Take any visual value (color, spacing, type scale) from a single place in the codebase rather than repeating it per template; adopt a design system only if the project introduces one.\n- Support the last two versions of Chrome, Firefox, Safari, and Edge.\n\n## 10. Testing\n\n- Classify a test by the boundary it crosses: a pricing-engine unit test crosses none; a Flask route test crosses the process boundary into the engine and the database; a full invoice-export run is a system test.\n- Keep the pricing engine's own test suite runnable with no Flask app, Jinja, HTMX, or SQLite session present \u2014 it must prove itself as a library.\n- Cover every discount kind, every tax-jurisdiction rule, and every rounding path with its own unit test, including edge cases (zero quantity, 100% discount, a jurisdiction with no tax).\n- Assert at least one tax or rounding calculation against a fixed external vector (a published tax table or worked example) rather than only round-tripping the engine's own output back through itself.\n- Add a regression test for every fixed defect.\n- Test the Flask layer's sign-in: an unauthenticated request to any route is rejected, and a session expires after its idle timeout.\n- Test the erasure and access-export functions directly: erasure removes or anonymizes every personal field everywhere it is stored (including past invoices, per \u00a77), and the access export contains everything stored about that customer.\n- Reset database state between tests (truncate or roll back a transaction) rather than relying on test order; never substitute an in-memory engine for SQLite in a test that exercises real queries.\n- Investigate a failing test before anything else; never skip or silence one without a documented reason.\n\n## 11. Review process\n\nReview in this order, most critical first; items 2-4 are held to the standard in \u00a7\u00a75-9 above.\n\n1. Security\n2. Correctness (wrong invoice totals, wrong tax, unhandled failure, a race on a shared SQLite write)\n3. Clarity\n4. Conventions\n\nProduce a plan \u2014 files touched, signatures, edge cases, assumptions \u2014 before implementing a feature or any change to the pricing engine; do not write implementation code until the plan is agreed (MUST NOT), except for one-line fixes, typos, or fully specified work.\n\nMUST checklist, run on every change before it merges:\n\n- [ ] No credential, token, or sensitive value appears in a committed file\n- [ ] Every failure path is handled; no silent catch, no swallowed exception\n- [ ] Every new dependency carries a license the project allows\n- [ ] Significant logic and architectural decisions are documented\n- [ ] Existing documentation (`README.md`, `AGENTS.md`, this file) matches the code after the change\n- [ ] Every changed section was re-read whole, not only the changed line\n- [ ] Every claim changed text makes about itself (a count, \"every\", \"all\") was checked by actually counting\n- [ ] Input from outside the process (a form field, a query parameter, an HTMX payload) is validated as untrusted before it is used\n- [ ] A refactor of the pricing engine preserves behavior on every discount kind, tax rule, and rounding case, including boundary values\n\nSHOULD checklist:\n\n- [ ] Each non-trivial function has a unit test per relevant variant\n- [ ] Coverage does not fall\n- [ ] Lint and type-check findings do not rise\n- [ ] Each third-party dependency is necessary, understood, and maintained\n- [ ] No new abstraction without two call sites, and no new dependency without a documented reason\n\nLabel a review finding a demonstrated defect, a policy deviation, or a suggestion; block a merge only on the first two. Label a finding unverified until it has been reproduced by running the path, or the measurement that produced it has been checked against the real scope and a hand-checked sample. Run a structure audit (every MUST above, plus the project's layer-specific MUSTs) after a framework or stack change and before any release milestone. Land a deviation from a MUST or MUST NOT rule only with the designated approver's sign-off, recorded with its reason (see \u00a712 for who that is).\n\n## 12. Open questions and answers\n\n- **Who approves a change?** Not named by the project brief. Until named, the person making the change reviews it themselves against the MUST checklist in \u00a711 before it merges.\n- **How is work tracked?** Not named by the project brief; open for the project to decide.\n- **What is a release?** The project has no deployment target. A release is a tagged commit on `main` that has passed the MUST checklist and the full test suite \u2014 the version a local installation updates to, nothing more.\n\n## 13. Session protocol\n\n- Start a session by reading this file, `AGENTS.md`, and the relevant templates referenced in \u00a70 for the area about to change; re-read \u00a73 (off-limits paths) before touching anything that might qualify.\n- Produce a plan (\u00a711) before implementing a feature or a non-trivial change; stay inside an approved plan, and stop and re-surface the options when a constraint invalidates it.\n- During the session, update `README.md`, `AGENTS.md`, and this file in the same commit as any change to structure, stack, conventions, or adopted rules.\n- Before ending the session, execute the MUST checklist in \u00a711, top to bottom, in order, against the actual change made \u2014 not a summary of it. Do not skip or paraphrase an item; a failing item is a fix, not a note. Only once every item passes (or is explicitly and visibly not applicable) is the session's work ready to hand off.",
+ "ttft_ms": 250032,
"type": "result",
- "duration_ms": 343641,
- "uuid": "814f5110-405a-4595-8b1d-aa36b64fcb40",
- "ttft_stream_ms": 2243,
- "time_to_request_ms": 438,
- "first_content_frame_ms": 2243,
+ "duration_ms": 335954,
+ "uuid": "16e4d32b-2e1e-4378-ad1b-1a38675f67e2",
+ "ttft_stream_ms": 1852,
+ "time_to_request_ms": 431,
+ "first_content_frame_ms": 1852,
"queued_turn_count": 0,
- "result_index": 0
+ "result_index": 0,
+ "credential_expires_at": "2026-12-11T13:29:52.387Z"
},
+ "budget": null,
"output_leak": null,
+ "named_tooling": [],
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\hybrid\\CLAUDE.md",
- "output_lines": 511,
- "output_words": 3426
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\hybrid\\CLAUDE.md",
+ "output_lines": 221,
+ "output_words": 3838
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/inline/CLAUDE.md b/tests/efficacy/arms/inline/CLAUDE.md
index 12edeb6..d6c4cb8 100644
--- a/tests/efficacy/arms/inline/CLAUDE.md
+++ b/tests/efficacy/arms/inline/CLAUDE.md
@@ -1,435 +1,433 @@
# tariff
-A pricing and invoicing web application for Imbra Ltd: a product catalog,
-discount rules of several kinds, tax jurisdictions, customers, and invoices
-assembled from them.
-
-Imbra Ltd. Stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite. Tooling: uv,
-ruff, mypy (strict), pytest. Runs locally only; there is no deployment
-target and nothing in the system reaches the network.
-
+Pricing and invoicing web application — Imbra Ltd
+Owner: Imbra Ltd. Runs locally only; no repository URL, live URL or deployment target applies.
- Model: inline
-Precedence when rules conflict: GDPR obligations (section 3.10) override
-every other rule in this file; this file overrides personal preference;
-`README.md` is the single source of truth for project structure. This file
-carries every rule the project has adopted, inline — nothing here is a
-pointer to an external document.
-
-A sibling `AGENTS.md` carries the same rules for any non-Claude agent.
-Update `CLAUDE.md`, `AGENTS.md` and `README.md` together whenever a change
-touches architecture, stack, structure, setup, or the conventions below;
-never let `AGENTS.md` and `CLAUDE.md` disagree.
-
-## Rule language
-
-A plain imperative ("Use X", "Never Y") means MUST or MUST NOT. Where
-strength matters, the keyword is explicit:
-
-| Word | Meaning |
-| --- | --- |
-| MUST | Absolute requirement; a deviation needs an approver's sign-off |
-| MUST NOT | Absolute prohibition; a deviation needs an approver's sign-off |
-| SHOULD | Recommended; a deviation needs a justification |
-| SHOULD NOT | Not recommended; may be ignored with a justification |
-| MAY | Optional; the developer decides |
-
## 1. Project
### 1.1 Overview
-See the precedence and stack summary above. Two actors reach this system:
-the administrator, signed in through the browser, and a second program
-that imports the pricing engine directly as a Python library, with the web
-application absent. Customers are data subjects under the EU GDPR: their
-name, email and postal address are stored and printed on the invoices
-billed to them (see section 3.10).
+`tariff` assembles invoices from a product catalog, several kinds of discount
+rule, tax jurisdictions and customers. Stack: Python 3.12, Flask 3, Jinja,
+HTMX, SQLite. It runs locally, with no deployment target.
-### 1.2 Project structure
+Two actors use it: an administrator working in a browser, and a separate
+program that imports the pricing engine directly as a library, without the
+web application present. The store is a local SQLite file. Nothing in this
+application reaches the network: no outbound HTTP call, no inbound API
+beyond the local web UI, no CORS surface, no SSRF surface. Do not add one
+without revisiting this file.
-See `README.md` for the full directory layout; this file does not
-duplicate it.
+One administrator signs in to use the web application; nobody else has an
+account. Customers are people: the system stores each one's name, email and
+postal address, and names them on the invoices billed to them. Imbra Ltd is
+in the EU, so GDPR applies — see section 6.
-- Keep the pricing engine (catalog, discount rules, tax jurisdictions,
- invoice assembly, invoice export) as a standalone Python package that
- imports nothing from Flask, Jinja, HTMX or any HTTP/web-framework code
- (MUST); another program must be able to import it with the web
- application absent.
-- Keep the Flask web app a thin caller of that library: a route decodes a
- request, calls the library, renders a template; never duplicate pricing,
- discount, tax or invoice-assembly logic in the web layer (MUST).
-- Keep invoice export logic (PDF/CSV/etc.) inside the library beside the
- invoice-assembly code it serializes, not in the Flask layer.
+### 1.2 Project structure
-### 1.3 Commands
+See `README.md` for the directory map; do not duplicate it here.
-```bash
-uv sync # install dependencies
-uv run flask run # run the app locally
-uv run ruff check . # lint
-uv run ruff format . # format
-uv run mypy --strict . # type-check
-uv run pytest # run tests
-uv run pytest --cov # run tests with coverage
-```
+Placement rule: keep the pricing engine in its own package, with no import
+of Flask, Jinja, HTMX or any other web-layer module. It must import and run
+correctly with the web application absent. The web application package may
+import the pricing engine; the reverse must never happen.
-## 2. Code conventions
+### 1.3 Commands
-### 2.1 Git
+The project has not yet chosen a package manager, test runner, type
+checker, linter or formatter. Until it does, each command below names what
+it must do, not how:
+
+- **Install**: resolve and install the project's pinned dependencies from
+ its lockfile.
+- **Migrate**: apply pending SQLite schema migrations through a committed
+ script before the application starts.
+- **Run**: start the Flask application locally, reading the port from an
+ environment variable, with a sensible default for local development.
+- **Test**: run the automated test suite (unit and integration) covering
+ both the pricing engine library and the web application.
+- **Type-check / Lint / Format**: run the project's static type checker,
+ linter and formatter, each in its strict and quiet mode, reporting zero
+ issues.
+
+## 2. Architecture boundaries
+
+- Keep the pricing engine a standalone Python library with no dependency on
+ Flask, Jinja, HTMX or any web-layer code (MUST); it must import and run
+ with the web application absent.
+- Treat the web application as one caller of the pricing engine, never a
+ second place that computes a price, discount or tax figure — call the
+ library; never re-implement its logic in a route handler or a template.
+- Keep the module graph acyclic: the web application depends on the
+ pricing engine; the pricing engine never imports the web application
+ (MUST).
+ **Check**: no module under the pricing-engine package imports anything
+ from the web-application package; the check must report zero violations.
+- Treat the pricing engine's public functions and classes as the contract
+ the other program — its second caller — depends on. Apply the
+ deprecation rule (section 3.2) before changing or removing any of them.
+- Give the pricing engine package its own version, independent of the web
+ application's; bump it deliberately, following semantic versioning,
+ whenever its public API changes.
+- Never let the pricing engine write to standard output or standard error,
+ and never let it configure logging beyond its own logger (MUST). Make
+ its logger injectable, falling back to its own module logger, so each
+ caller captures its output on its own terms.
+ **Check**: run the library alone in a fresh process and confirm it emits
+ nothing on stdout or stderr; a test runner's own log handler can hide a
+ default that would otherwise leak into both callers.
+
+## 3. Code conventions
+
+### 3.1 Git
- Commit under one full name and one consistent email; never change
identity mid-project.
- Work on a branch; never commit directly to `main`.
-- Never commit build output, the virtual environment, `__pycache__`, or
- secrets.
-- Keep a `.gitignore` covering `.venv`, `__pycache__`, build output,
- `.env*`, editor state, OS files and coverage output (MUST).
-- Commit `uv.lock` (MUST).
-- Treat the repository as public: no secret, credential or sensitive value
- in source or history.
-- Inspect the working tree and the index before starting a task.
-- Never discard, reset, stash or overwrite a change the task did not make
- (MUST NOT); never clear the tree for a clean test baseline without
- asking.
-- Stage only the changes the task made; read the staged diff before
- committing.
-- Stop and ask when a task change and a prior change share a hunk; report
- a pre-existing change that blocks the task rather than removing it.
-- Keep a pull request to one concern (SHOULD); test locally before
- committing.
-- Review every diff against the base before merging, in order: security,
- correctness, clarity, conventions. Merge only once review passes and CI
- is green.
-- Read the CI run for the push before calling a change good; never merge
- while a check is failing, cancelled, or not yet registered.
-- Never force-push, including `--force-with-lease` (MUST NOT); update a
- branch by merging the base into it.
-
-#### Off-limits paths
-
-These MUST NOT change without explicit approval. Propose a change inside
-one of them with a rollback strategy and the tests that would catch a
-regression, before making it:
-
-- Authentication and session code (sign-in, password hashing, session
- cookie configuration)
-- Database migrations
-- `.env*` and any secrets file
-- CI/CD workflow files
-
-Name any off-limits path touched at the top of the change's summary,
-whether proposed or already approved.
-
-### 2.2 Python
-
+- Never commit build output, dependency directories or secrets. Commit a
+ generated file only when the project tracks it on purpose.
+- Keep a `.gitignore` (MUST) covering dependencies, build output, secrets,
+ editor state, OS files and coverage output.
+- Commit lockfiles (MUST).
+- Inspect the working tree and the index before starting a task. Never
+ discard, reset, stash or overwrite a change the task did not make.
+ Stage only the changes the task made — a whole file only when it held
+ no prior change, otherwise only the task's hunks. Read the staged diff
+ before committing. Stop and ask when a task change and a prior change
+ share a hunk. Report a pre-existing change that blocks the task rather
+ than removing it.
+- Keep a pull request to one concern (SHOULD). Test locally before
+ committing. Review the diff against the base before merging, in the
+ order security, correctness, clarity, conventions. Merge only after the
+ review passes and CI is green.
+- Read the CI run for the push before describing a change as good. Treat
+ a pull request with no registered check as not passed. Never merge
+ while a check is failing, cancelled or not yet registered. Re-run a
+ verification a pull request claims once the base has moved since it was
+ written. Read a new or changed workflow's first run in its real
+ environment before trusting it.
+- Never force-push, including with `--force-with-lease` (MUST NOT). Bring
+ a branch up to date by merging the base into it, never by rebasing and
+ force-pushing.
+
+**Off-limits paths** (MUST NOT change without explicit approval; propose
+first, with a rollback strategy and the tests that would catch a
+regression):
+
+- Authentication and session code (the administrator's sign-in).
+- SQLite migrations.
+- `.env*` and secrets.
+- CI/CD workflow files, if and when the project adds any.
+- Payment code: not applicable — this application does not process
+ payments.
+
+A diff confined to prose is ordinary work; a comment a tool reads (a
+linter disable, a coverage pragma) counts as executable content and is
+off-limits the same as a command or a permission. Name an off-limits path
+at the top of a change's summary whenever the diff touches one, proposal
+or not.
+**Check**: the change summary names every off-limits path the diff
+touches; the check must report zero undeclared touches.
+
+### 3.2 Python
+
+- Keep one authoritative representation of each piece of pricing, discount
+ or tax knowledge (DRY). Build only what a stated requirement justifies
+ (YAGNI); record beside every deferral the concrete condition that
+ reopens it. Delete a path once evidence shows it unreachable.
+- Compute derived counts and statistics from the data; never hardcode
+ them. Remove unused modules, assets and data files promptly.
- Name a function with a verb, a class or module with a noun, a boolean
- with `is`, `has` or `can`.
-- Rename a name that needs a comment to explain it; use the same name for
- the same concept in every module (e.g. always `tax_jurisdiction`, never
- mixed with `tax_zone`).
-- Name a public enum member or result discriminator for the capability it
- offers, never the library behind it.
-- Keep cognitive complexity at or under 15 per function; enforce it with
- `ruff`'s `C90` rules and `max-complexity = 15` in `pyproject.toml`.
-- Nest at most three levels; use guard clauses and early returns.
-- Replace a boolean flag parameter that selects behaviour with an enum or
- two named functions.
-- Name every magic number and magic string as a constant; keep a constant
- beside the function that uses it.
-- Encode every committed text file in UTF-8 with LF line endings; keep
- identifiers ASCII.
-- Prefer code that needs no comment; comment only non-obvious intent;
- never cite a ticket or PR number in a comment or docstring.
-- Commit no debug output (`print()`), no commented-out code, and no
- hardcoded breakpoint; gate any debug tooling behind an environment
- variable, off by default.
-- Delete a probe script before the commit that uses its findings; keep the
- findings in a comment, decision record or doc, never in the probe.
-- Type-annotate every function signature; keep `mypy --strict .` and
- `ruff check .` clean as a merge gate (MUST).
-
-## 3. Quality
-
-### 3.1 Architecture and dependencies
-
-- Keep one authoritative representation of each piece of knowledge (DRY);
- extract shared logic only where substantial logic repeats.
-- Choose the simplest solution a stated requirement justifies (KISS);
- build only what is needed now (YAGNI).
-- Compute every derived count, total, tax amount or discount from the
- data; never hardcode one.
-- Remove unused modules, assets and data files promptly.
-- Snapshot pricing, discount and tax data onto an invoice at creation time;
- never recompute a historical invoice from current catalog, discount or
- tax-jurisdiction state (a later price or rate change must never alter an
- already-issued invoice).
-- Keep the module graph acyclic; break a cycle with a third module, never
- a divergent local copy.
+ with `is`, `has` or `can`. Rename a name that needs a comment to explain
+ it. Use the same name for the same concept in every module.
+- Keep cognitive complexity at or under 15 per function; nest at most
+ three levels; use guard clauses and early returns. Replace a boolean
+ flag that selects behaviour with an enum or two named functions.
+- Name every magic number and string as a constant — a discount
+ percentage, a tax rate, a threshold. Size a tuned threshold from its
+ measured distribution, naming the data source beside the constant;
+ take a limit a specification fixes (e.g. a tax jurisdiction's own
+ rounding rule) from that specification instead.
- Keep coupling shallow: a change inside one module must not require
- changes in unrelated modules.
-- Never let the pricing-engine library write to standard output or error,
- or configure logging beyond its own logger (MUST); make its logger
- injectable, falling back to its module logger, and verify the silence in
- a fresh process.
-- Enforce the library/web-app import boundary with a test
- (e.g. `test_library_has_no_web_imports`) asserting that no module under
- the pricing-engine package imports `flask`, `jinja2`, or anything from
- the web layer.
-
-### 3.2 Errors
-
-- Validate input at boundaries (the HTTP layer, the library's public
- functions) and fail at once on invalid state.
-- Read a value from its source-of-truth field and raise when it is
- missing; never fall back to a value derived from a slug, name or hash.
-- Never break a public catch contract: a raise callers catch by a built-in
- type keeps that type.
-- Add an error type only where a caller could act differently.
-
-### 3.3 Deprecation
-
-- Deprecate a public symbol in the pricing-engine library, naming its
- replacement, before a later change removes it; the second program
- consumes this library's API directly and has no version negotiation to
- fall back on.
-- Deprecate every part of one call site together; never alias the outer
- name alone while silently changing its keyword arguments.
-
-### 3.4 Destructive operations
-
-- Delete, truncate or overwrite only what the operation can prove it
- should affect: a specific customer ID matched exactly, never a loose
- filter.
-- Validate the input before any destructive operation: reject an empty or
- malformed ID.
-- Apply this with particular care to GDPR erasure (section 3.10): verify
- the customer record matched is the one requested before deleting or
- anonymizing it.
-
-### 3.5 Completion
-
-- Finish a task when the requested behaviour works through the entry point
- its user or caller reaches (the browser UI or the library's public API),
- and the checks that prove it pass.
-- Report a check that could not run as not run, never as a pass.
-- Add an abstraction or process step only when a stated requirement, a
- demonstrated defect, or a material risk justifies it.
-- Report a problem found outside the task's scope rather than fixing it in
- the same change (SHOULD).
-
-### 3.6 Testing
-
-- Classify a test by the boundary it crosses: unit (none), integration
- (the SQLite database), system (the whole app against its requirements),
- regression (reusing existing tests), exploratory (unscripted).
-- Double only what crosses a boundary: the database, time, randomness;
- keep deterministic in-process collaborators real.
-- Add a regression test for every fixed defect (SHOULD).
-- Cover every happy path the pricing, discount, tax and invoicing rules
- define, plus negative inputs and edge cases (SHOULD).
-- Keep pricing, discount and tax logic in pure functions; push the SQLite
- access to thin adapters at the edges; inject the database session rather
- than construct it inside the code under test.
-- Set or clear every environment variable a test depends on inside that
- test; never rely on ambient process state.
-- Treat a test that passes or fails by run order as an isolation bug;
- investigate a failing test before skipping or suppressing it.
-- Reset database state between test runs (a transaction rolled back per
- test, or a fresh SQLite file); never substitute a different database
- engine in tests.
-- Assert at least one case against a fixed vector from the ISO 4217 minor-
- unit table for currency rounding; never take a round trip through your
- own rounding code as proof it is correct.
-- Give every fact stored in two places (a documented field's maximum
- length and the constant enforcing it, for instance) a test that fails
- when the two diverge.
-- Verify a change to rendered HTML or an HTMX fragment against the
- rendered output, not the template source.
-- Never let coverage regress between commits; run every test from CI with
- no human step.
-
-### 3.7 HTTP and web conventions
-
-- Keep Flask route handlers thin: decode the request, call the pricing
- library or a service function, render the response; never put pricing,
- discount, tax or invoice logic in a handler.
-- Parse a typed query parameter explicitly so absent (use the default),
- present-and-valid (use it), and present-but-invalid (raise 400) are
- distinct; never let a parsing helper silently turn an invalid value into
- a default.
-- Never let a `GET` or `HEAD` request change state; make every HTMX
- `PUT`/`DELETE`-driven action idempotent.
-- Represent every date and time as ISO 8601 and every currency amount with
- its ISO 4217 code; store and compute money as an integer in minor units
- or as a decimal type, never as a float.
-- Use a consistent error response shape across the app; never return a
- stack trace, an internal path, or a raw database error to the browser;
- log the full detail server-side and show the administrator a generic
- message.
-- Enforce authentication on every route (MUST); this application declares
- no public endpoint. Apply authentication before any business logic
- runs.
-- Run a one-off task (a migration, a data fix, a REPL session) as a script
- committed to the repository, using the application's own code and
- config, never as an ad-hoc shell command.
-
-### 3.8 Database conventions
-
-- Make every schema change through a migration committed to source control
- (MUST); never edit the SQLite file by hand. One migration per logical
- change, with both an `up` and a `down` step; say in the migration and
- get approval when the `down` step would lose data.
-- Never modify a migration that is already merged.
-- Parameterize every query that takes a value; never build a query by
- string interpolation (see also section 3.9).
-- Bound every query an interactive request runs with a limit or
- pagination; select only the columns the code uses; fetch an invoice's
- related line items in one query, never one query per row.
-- Index every foreign key column (`customer_id` on invoices, `product_id`
- on line items, and similarly for discount and tax-jurisdiction
- references); drop an index once it is unused.
-- Wrap a multi-step write (assembling an invoice across its tables) in a
- transaction; keep transactions short; never call out to another process
- inside one.
-- Inject the database session as a dependency; no global database handle.
-- Use hard delete or anonymization for a GDPR erasure request, never a
- soft-delete flag alone (see section 3.10); where a soft delete is used
- elsewhere for audit history, filter deleted rows out of every query by
+ changes in unrelated modules. Talk only to direct dependencies. Reach a
+ heavy or platform-limited dependency through one module that owns its
+ import.
+- Validate input at boundaries and fail at once on invalid state. Read a
+ value from its source-of-truth field, and raise when it is missing;
+ never fall back to a value derived from a slug, name or hash. Add an
+ error type only where a caller could act differently. Never let a
+ caller-side filter stand in for a precondition.
+- Deprecate a public symbol, naming its replacement, before a later change
+ removes it. Deprecate every part of one call site together; never alias
+ the outer name alone.
+- Keep constants beside the functions that use them.
+- Encode every committed text file in UTF-8 with LF line endings (MUST);
+ keep identifiers ASCII (MUST). Set a program's output encoding
+ explicitly wherever another program reads its output — in particular,
+ the invoice export path. Commit a `.gitattributes` with `* text=auto`,
+ adding `eol=lf` for hard LF.
+ **Check**: every tracked text file is UTF-8 with LF endings and ASCII
+ identifiers; the check must report zero exceptions.
+- Prefer code that needs no comment. Never cite a ticket, PR or ADR number
+ in a comment or docstring — state the substance. Name a source (author,
+ year, method) where a tax or discount rule's logic is non-obvious.
+- Commit no debug output (`print()`) and no hardcoded breakpoint. Delete
+ commented-out code. Gate debug tooling behind a flag, off by default.
+- Write a probe script to measure data or behaviour rather than guess;
+ delete it before the commit that uses its findings; keep the findings
+ themselves in durable comments or decision records.
+- Grep for a construct a comment records as not working before reusing
+ it; read every hit as a suspected instance of the same defect.
+- Run a new constraint — a tightened bound, a narrowed exemption — against
+ the existing corpus before it merges.
+- When deleting, truncating or purging data (notably a GDPR erasure, see
+ section 6), act only on what the operation can prove is its target: an
+ exact customer ID, not a name match or a path guess. Find nothing, and
+ raise, where that proof is unavailable.
+- Confirm a migration, import or bulk-edit script is correct before
+ acting on its output in bulk; cross-check an independent source before
+ overwriting stored data that looks wrong.
+- Adopt the project's static type checker at its strictest setting and
+ keep it clean (MUST); annotate every public function's parameters and
+ return type (MUST). Adopt a linter and a formatter and keep both clean
+ (MUST). Run all three before every commit and in CI; each must print
+ nothing.
+- Finish a task when the requested behaviour works through the entry
+ point its caller reaches, and the checks that prove it pass. Report a
+ check that could not run as not run, never as a pass. Report a problem
+ found outside the task as its own task rather than folding it in.
+
+### 3.3 Web layer (Flask / Jinja / HTMX)
+
+- Read the port from an environment variable; never hardcode it. Keep
+ initialisation short.
+- Run one-off tasks (migrations, data fixes) with the application's own
+ code, config and dependencies; commit admin scripts to the repository
+ rather than running ad-hoc shell commands; prefer idempotent scripts;
+ never run one against the live database without a tested rollback plan.
+- Keep handlers thin: decode the request, call the pricing engine or a
+ service function, render the response. Never put business logic in a
+ handler. Validate all incoming request data before processing it.
+- Parse a typed query parameter explicitly, distinguishing absent
+ (default), present-and-valid (use it) and present-but-invalid (raise a
+ 400) — never let a parsing helper silently turn a bad value into the
default.
-- Never run a schema migration against production data inside a test
- suite.
-
-### 3.9 Security
-
-- Validate all external input (every form field, query parameter and HTMX
- payload) at the boundary with a schema-validation library; use an
- allowlist, not a blocklist; reject invalid input with a clear error
- rather than silently coercing it.
-- Never bypass Jinja's autoescaping with a raw-HTML path for user-supplied
- data (product names, customer names and addresses, discount codes
- included).
-- Use parameterized queries for all database access; never concatenate
- user input into SQL.
-- Hash the administrator's password with bcrypt, scrypt or Argon2; never
- MD5, SHA-1 or plain SHA-256. Require a minimum password length and
- reject known-breached passwords; impose no composition rules.
-- Use constant-time comparison for secrets and tokens; lock the account or
+- Read header names case-insensitively. Avoid the `X-` prefix on a custom
+ header; use an application-specific prefix instead.
+- Never let a GET or HTMX `hx-get` request change state. Make every PUT
+ and DELETE (including an `hx-delete`) idempotent.
+- Represent dates and times as ISO 8601, currency codes as ISO 4217, and
+ country or tax-jurisdiction codes as ISO 3166-1 alpha-2, wherever the
+ application stores, computes or displays them.
+- Use a consistent error shape across every route and HTMX fragment. Never
+ expose a stack trace or an internal path to the browser; return a
+ generic message and log the detail server-side. Use proper 4xx/5xx
+ status codes, never 200, for an error. Set an explicit `Content-Type`
+ on every response.
+- Enforce authentication on every route (MUST); this application declares
+ no public endpoint. Apply the auth check before any business logic
+ runs. Never expose a write path without the authenticated
+ administrator's session.
+- Not applicable, since nothing here reaches the network: HTTPS/TLS
+ enforcement, HSTS and other reverse-proxy security headers, CORS,
+ multi-instance process lifecycle (graceful shutdown, SIGKILL recovery).
+
+### 3.4 Data model (SQLite)
+
+- Pick one naming convention for tables, columns, keys and indexes, and
+ record it here once chosen — open for the project to decide.
+- Give every table a primary key; prefer a surrogate key. Store each fact
+ in one place; duplicate only when measured read performance requires
+ it, with the rationale documented. Never pack several values into one
+ field (e.g. a composite discount-rule string) — use a related record.
+- Enforce every reference (customer → invoice, invoice → product, invoice
+ → tax jurisdiction) with SQLite's own foreign-key constraint, or an
+ explicit check that every reference resolves. Decide what deleting the
+ target of each reference does — see section 6 for the customer case.
+ Document the maximum depth and cycle-prevention strategy for any
+ self-referencing relationship, such as a stacked or nested discount
+ rule, if one exists.
+- Make every schema change through a versioned migration (MUST); never
+ edit the schema by hand. Prefer additive changes, compatible with old
+ writers. Give a destructive change (drop or rename a column) a plan:
+ add the new column, migrate the data, drop the old one, with both up
+ and down steps (MUST). Say so, and get approval, where a down step
+ cannot restore the data. Test a migration against realistic data before
+ applying it.
+- Use the most specific SQLite type for each field: a date/time type, not
+ a string, for dates. Store timestamps in UTC; convert to local time only
+ at the presentation layer. Store every monetary value — a price, a
+ discount, a tax amount, an invoice total — as an integer in minor units
+ or an exact decimal type; never as a float (MUST). Document a maximum
+ length for every text field: customer name, email, postal address,
+ product description.
+- Open one connection per request or worker thread; never a long-lived
+ global handle. Wrap a multi-step write (e.g. assembling an invoice from
+ its line items) in a transaction; commit only once every write
+ succeeds; keep the transaction short.
+- Bound every interactive query with a limit or pagination (e.g. a
+ customer or invoice listing); a filter alone is not a bound. Select only
+ the columns a code path uses. Fetch related rows for a set in one query
+ or batch, never one query per row in a loop.
+- Use a hard delete or an anonymizing update for a customer erasure (see
+ section 6), never a soft delete that still returns the row to ordinary
+ queries. Keep an append-only audit log table instead of a soft-delete
+ flag.
+- Reset state between test runs — truncate tables or roll back a
+ transaction wrapping each test. Never substitute a different database
+ engine in tests; SQLite's own behaviour is part of what is tested.
+ Never run a schema migration against a production database inside a
+ test suite.
+
+## 4. Quality — testing
+
+Classify a test by the boundary it crosses: unit (none), integration
+(process/component — e.g. a real temporary SQLite file), system (the
+whole application against its requirements), regression (reusing
+existing tests against a fixed defect), exploratory (unscripted).
+
+- Double only what a unit test would cross a boundary to reach: file I/O,
+ the system clock (discount and tax-jurisdiction rules can be
+ date-effective), randomness. Keep deterministic in-process
+ collaborators real.
+- Add a regression test for every fixed defect.
+- Cover every happy path the pricing, discount, tax and invoicing rules
+ define, plus negative inputs and edge cases (SHOULD), plus each
+ dependency's faults (an unavailable database file, a malformed row).
+- Meet the project's coverage threshold for new code before merging;
+ never let coverage regress between releases. Run every unit test from
+ CI with no human step. Name a test so its name alone states the unit,
+ the input and the expected outcome (SHOULD).
+- Keep pricing, discount and tax logic in pure functions; push SQLite
+ access to thin adapters at the edges (SHOULD). Inject dependencies
+ rather than construct them in the code under test. Split a function
+ that needs more than two mocks to test.
+- Test behaviour, not implementation details. Set or clear every
+ environment variable a test depends on, in that test. Treat a test that
+ passes or fails by run order as an isolation bug. Wait on a condition
+ with a deadline, never a fixed sleep. Never enumerate, signal or
+ terminate a process the test did not start. Never mutate host state
+ outside the working directory. Investigate a failing test's own logic
+ before skipping or suppressing it.
+- Allocate a per-test temporary database file or path from a fixture or a
+ module-level counter, never from state a test class inherits.
+- Assert after every test that no thread, subprocess or server the suite
+ started survives it; join with a timeout, never a sleep.
+- Exercise every call site of a changed shared pricing, discount or tax
+ path, not only the reported case; keep the list of consumers beside the
+ shared path.
+
+## 5. Security
+
+- Validate all external input (invoice, customer and discount-rule forms)
+ at the boundary, with a schema validator, using an allowlist. Reject
+ invalid input with a clear error; never silently coerce or strip
+ fields.
+- Encode dynamic data for its rendering context at the point of output.
+ Rely on Jinja's auto-escaping; never insert user-supplied data through
+ a raw-HTML path (`|safe`, `Markup`) that bypasses it.
+- Use parameterized SQLite queries for all database access; never
+ concatenate user input into a query string.
+- Hash the administrator's password with bcrypt, scrypt or Argon2 — never
+ MD5, SHA-1 or plain SHA-256. Require a minimum length and reject
+ known-breached passwords; impose no composition rules. Use
+ constant-time comparison for secrets and tokens. Lock the account or
throttle after repeated failed sign-in attempts.
-- Generate the session ID with a cryptographic random generator and
- regenerate it after login (session fixation).
-- Set `HttpOnly`, `Secure` and `SameSite=Strict` on the session cookie;
- expire the session after 30 minutes idle; invalidate it on logout.
-- Give every state-changing request (every `POST`, `PUT`, `PATCH`,
- `DELETE` the admin UI issues, HTMX included) a CSRF defence, since the
- session is carried by an ambient cookie; use Flask's own CSRF protection
- rather than hand-rolled tokens; never change state on a `GET`.
-- Never hardcode a secret, API key or credential in source; keep `.env`
- out of version control; rotate a secret immediately if it is
- accidentally committed, and warn the user before committing a file that
- commonly holds one.
-- Set `X-Content-Type-Options: nosniff` and `X-Frame-Options: DENY` (or an
- equivalent CSP `frame-ancestors`) on every response.
-- Never expose a stack trace, internal path or database error to the
- administrator's browser; return a generic message and log the detail
- server-side.
-- Never log a secret, token, password, or PII (name, email, address); log
- authentication failures and access denials at WARN with an opaque user
- ID, never a submitted username.
-- As the coding agent: never read, print or `cat` a file that may hold a
- secret (`.env`, `*.pem`, `*.key`, `credentials.json`); never echo or log
- an environment variable's value; verify a secret's presence by an
- existence check, never by printing it.
-
-### 3.10 Data modeling and GDPR
-
-- Use one naming convention for every table, field, key and index
- (`snake_case`); give every table a primary key, surrogate for internal
- use.
-- Store each fact once; document the rationale for any intentional
- denormalization.
-- Never pack several values into one field (a comma-joined list of line
- items, for instance); use a related record instead.
-- Enforce every reference (customer, product, discount rule, tax
- jurisdiction) with a foreign-key constraint; decide and document what
- happens on delete for each: clear the reference, refuse the delete, or
- (for an invoice, which must keep its billed values regardless of later
- catalog changes) rely on the snapshot in section 3.1 rather than a live
- reference.
-- Run every schema change through a versioned migration; keep an additive
- change compatible with old data (a new field optional or defaulted);
- give a destructive change an add-migrate-drop plan.
-- Store timestamps in UTC; store monetary values as an integer in minor
- units or a decimal type, never a float; document a maximum length for
- every text field (customer name, email, postal address, product name,
- discount code).
-- Classify every field: customer name, email and postal address are
- Confidential (PII); invoice amounts and line items are Confidential;
- product catalog, discount rules and tax-jurisdiction data are Internal.
- Document this in the schema or a data dictionary, and restrict access to
- the Confidential tier to the signed-in administrator.
-- Minimize PII collection: store only what invoicing needs (name, email,
- postal address); never put PII in an application log, error message or
- stack trace.
-- Mask or use synthetic data for PII in any non-production environment
- (development fixtures, test data).
-- Provide a mechanism to erase a customer's PII on request (GDPR Art. 17):
- hard-delete or anonymize it, never a soft-delete flag alone. Where a
- statutory retention duty (e.g. tax-record retention) requires keeping
- the invoice itself, anonymize the customer's name, email and address on
- the retained invoice rather than deleting the invoice, and document the
- retention period relied on.
-- Provide a mechanism to export a copy of everything held about a customer
- on request (GDPR Art. 15/20), in a structured, commonly used format.
-- Define and document a retention period for each data category
- (customers, invoices, backups); implement automated purging rather than
- a manual process; apply the same retention to backups, and never retain
- a backup indefinitely.
-- Log every change to Confidential data: who (the administrator's opaque
- ID), when, what changed, and the previous value — except a credential's
- or a PII field's own value, which the audit entry must record as
- "changed" without storing either value, so an erasure leaves no copy in
- the append-only trail.
-- Data ownership (who owns the customers, invoices and catalog domains) is
- not settled by the project; assign one before this matters operationally.
-
-### 3.11 Accessibility and UX
-
-- Make every interactive element reachable and operable by keyboard; never
- put a click handler on a non-focusable element — use a native button or
- link instead.
-- Style focus with `:focus-visible` and keep a visible focus indicator on
- every focusable element, including links.
-- Never convey meaning by colour alone; keep text contrast at 4.5:1 (3:1
- for large text); give every image descriptive `alt` text (`alt=""` when
- decorative).
-- Use semantic HTML with a correct heading hierarchy.
-- Scan rendered pages with an automated accessibility checker in CI, and
- merge only on zero violations.
-- Before shipping a new interactive component: tab through it without a
- mouse, walk it with one screen reader, and zoom to 200% to check nothing
- clips or scrolls horizontally.
-- Support the last two versions of Chrome, Firefox, Safari and Edge.
-
-## 4. Review process
-
-Review in this order, most critical first:
-
-1. **Security**: anything exploitable, any credential or licence problem
-2. **Correctness**: wrong results, unhandled failures, race conditions
-3. **Clarity**: obscure names, deep nesting, high cognitive complexity,
- boolean flag parameters
-4. **Conventions**: deviations from the rules in section 2 and 3
-
+- Generate the session ID with a cryptographic random generator;
+ regenerate it after login. Set `HttpOnly`, `Secure` and
+ `SameSite=Strict` on the session cookie. Expire the session after an
+ idle period. Invalidate it on logout; do not rely on cookie expiry
+ alone.
+- Give every state-changing request (every HTMX `POST`/`PUT`/`PATCH`/
+ `DELETE`) a CSRF defence (MUST), since the administrator's session is
+ authenticated by an ambient cookie. Use the framework's built-in CSRF
+ middleware; prefer the synchroniser token pattern. Validate the token
+ on every state-changing request, never on GET. Never change state on a
+ GET request.
+- Never hardcode a secret, API key or credential in source. Keep local
+ secret files out of version control. Rotate a secret immediately if it
+ is ever committed.
+- Never expose a stack trace, an internal path or a database error to the
+ administrator's browser; log the full detail server-side. Answer a
+ failed sign-in the same way regardless of whether the account exists:
+ "invalid credentials", never "user not found".
+- Never log a secret, token or password, and never log a customer's name,
+ email or postal address (see section 6) — log an opaque ID instead.
+ Sanitize any user-supplied data that reaches a log. Log authentication
+ and authorization failures at WARN, with an opaque user ID, never a
+ submitted username. Keep the client IP only in an access-restricted
+ security log, purged at the end of its retention period.
+- Never deserialize untrusted data with a format that can instantiate
+ arbitrary types; use a data-only format (JSON) for any HTMX partial
+ that carries structured data. Pin dependency versions and verify
+ lockfile checksums; never trust an upstream registry blindly.
+- Never read, print or `cat` a file that may hold secrets (`.env`,
+ `credentials.json`, `*.pem`, `*.key`). Never echo or log an environment
+ variable's value; check its presence by name only. Warn before
+ committing a file that commonly holds secrets. Flag any secret exposed
+ in a session immediately, name it, and recommend rotation.
+- Not applicable, since nothing here reaches the network: HTTPS/HSTS/TLS
+ enforcement, reverse-proxy security headers, CORS, SSRF defences. Not
+ applicable, since the application has no upload feature: file-upload
+ validation.
+
+## 6. Privacy and data governance (GDPR)
+
+- Classify a customer's name, email and postal address as Confidential
+ personal data. Classify an invoice (which carries that PII alongside
+ pricing and tax figures) as Confidential. Classify the product catalog,
+ discount rules and tax-jurisdiction tables as Internal.
+- Match access to classification: only the signed-in administrator may
+ read or write Confidential data; there is no lower-privileged role to
+ restrict it from.
+- Encrypt PII at rest (MUST). There is no network transit to secure here.
+- Minimize PII collection: store only the name, email and postal address
+ the invoicing relationship needs.
+- Never put a customer's name, email or postal address in an application
+ log, error message or stack trace (MUST NOT); use an opaque customer ID
+ there instead.
+- Provide an erasure path (GDPR Art. 17) that anonymizes or removes a
+ customer's name, email and postal address from the live customer record
+ on request.
+- Preserve the name and address already billed on a previously issued
+ invoice exactly as issued (GDPR Art. 17(3)(b) permits retaining what a
+ legal — here, tax and bookkeeping — obligation requires): erase or
+ anonymize the customer record, never retroactively edit an issued
+ invoice's billing details. Never delete an issued invoice as a side
+ effect of an erasure request; clear or anonymize the customer reference
+ on it instead of deleting the row.
+- Provide an access/export path (GDPR Art. 15) that produces a complete,
+ human-readable copy of a customer's stored personal data and the
+ invoices billed to them, on request.
+- Record every erasure and export request in an append-only audit trail:
+ who requested it, when, and what action was taken — never the PII
+ values themselves, so that erasing the PII leaves no copy in the trail.
+ Log every other change to Confidential data (a customer record, an
+ invoice, a price-setting discount rule) the same way: who changed what,
+ when, and the previous value, with PII excluded. Keep this trail in its
+ own store, separate from application logs, access-restricted to the
+ administrator.
+- Define a retention period for customer and invoice data that satisfies
+ the bookkeeping and tax-retention law of the applicable EU member
+ state, and purge data automatically once it lapses; the exact period is
+ open for the project to decide, pending confirmation of the applicable
+ jurisdiction. Apply the same retention and purge discipline to the
+ audit trail.
+- Use synthetic customer data in tests and local development fixtures;
+ never real customer PII.
+- Designate the administrator as the owner of every data domain
+ (customers, invoices, products, discount rules, tax jurisdictions)
+ until the project names otherwise.
+
+## 7. Review process
+
+Review in this order, most critical first, weighing each finding
+separately: **security**, **correctness**, **clarity**, **conventions**.
Label each finding a demonstrated defect, a policy deviation, or a
-suggestion. Block a merge only on a defect or a policy deviation; leave a
-suggestion to the author.
-
-### End-of-session checklist
+suggestion; block a merge only on the first two.
-Read every item below and execute it in sequence before ending a session;
-never summarize or skip one.
-
-**MUST**
+**MUST checklist**
- [ ] No credential, token or sensitive value appears in a committed file
- [ ] Every failure path is handled; no silent catch, no swallowed
@@ -438,15 +436,14 @@ never summarize or skip one.
- [ ] Significant logic and architectural decisions are documented
- [ ] Existing documentation matches the code after the change
- [ ] Every changed section was re-read whole, not only the changed line
-- [ ] Every claim changed text makes about itself, such as a count or
- "all", was checked by counting with a tool
-- [ ] Input from outside the process (a form field, a query parameter) is
- validated as untrusted before it is destructured, indexed, or used
- as a key
-- [ ] A refactor preserves behaviour on every path: each case, direction
+- [ ] Every claim changed text makes about itself (a count, "all") was
+ checked by counting with a tool
+- [ ] Input from outside the process is validated as untrusted before it
+ is destructured, indexed or used as a key
+- [ ] A refactor preserves behaviour on every path — each case, direction
and mode, including null handling, sort order and boundary values
-**SHOULD**
+**SHOULD checklist**
- [ ] Each non-trivial function has a unit test per relevant variant
- [ ] Coverage does not fall
@@ -455,98 +452,30 @@ never summarize or skip one.
- [ ] No new abstraction without two call sites, and no new dependency
without a documented reason
-### CI signals
-
-- Read the log of a red check before calling the pull request green or
- red.
-- Separate an infrastructure failure (the check could not run) from a diff
- failure (it ran and found something), and say which in the merge
- decision.
-- Never retry until green without saying so; never bypass a failing check
- by skipping hooks or an admin merge without the approver's explicit
- acceptance of the risk.
-
-### Picking up an issue
-
-- Re-read the target for existing coverage before writing anything; verify
- everything the issue cites as existing against the current tree.
-- Check open pull requests and accepted decisions since the issue's filing
- date for work that already closes or moves it.
-- Resolve a cited version or classification against its actual source
- rather than trusting the issue's description of it.
-
-### Planning
-
- Produce a plan before implementing a feature or a non-trivial change:
- the files, the signatures or outline, the edge cases, the assumptions.
-- Never write implementation code until the plan is approved (MUST NOT);
- skip the plan only for one-line fixes, typos, and changes the requester
- has specified in full.
-- Stay inside the approved plan; when a constraint invalidates it, stop
- and re-surface the options.
-
-### Verifying a finding
-
-Label a finding unverified until it is demonstrated.
-
-- From reading: reproduce the defect by running the path; read a passing
- test that contradicts the reproduction before blaming the code.
-- From a measurement: confirm the tool measured the rule's actual unit and
- the claimed scope (not a diff or a sample); check one flagged item and
- one zero result by hand.
-- From an extraction: check an element reported absent against the raw
- artifact; scope the claim to what was inspected ("not verifiable from
- the extract", never "missing").
-- From a probe: confirm it ran under the conditions the finding is about
- (user, credential, environment); scope the claim to what it actually
- tested.
-- From an agent: check its finding against the file, commit or document
- that settles it before acting on it or repeating it; count a finding
- several agents agree on as one finding.
-
-### Deviations
-
-- Explain a deviation from a SHOULD rule in the pull request.
-- Land a deviation from a MUST or MUST NOT rule only with a designated
- approver's sign-off and its reason recorded in the pull request; never
- waive one yourself.
-
-### Cold-reader writing
-
-Apply this to every ticket, pull request and defect record, since the
-record outlives the session:
-
-- State the symptom before the mechanism; expand a term taken from the
- code at its first use, or avoid it.
-- Show a real example rather than describe one; keep to one idea per
- sentence.
-
-### Governance questions
-
-- **Who approves a change?** Not stated by the project; open for the
- project to decide. Until an approver is named, treat every MUST/MUST NOT
- deviation above as blocked.
-- **How is work tracked?** Not stated; open for the project to decide.
-- **What is a release?** Not applicable in the usual sense: the project
- runs locally with no deployment target. "Shipping" a change means
- merging it to `main` with a green CI run; there is no deployment step.
-
-## 5. Session protocol
-
-- **Start**: read this file and `README.md`; run `git status` and inspect
- the working tree and index before making any change; never discard or
- overwrite a change the task did not make.
-- **Proceed**: follow the planning rule in section 4 for anything beyond a
- one-line fix; stay inside the approved plan; propose any off-limits-path
- change (section 2.1) before making it.
-- **Disagreement between a document and the system**: never act on the
- document alone when the observed system state is defensible; find the
- rule that governs both (this file, or GDPR for section 3.10) and fix
- whichever one that rule does not support.
-- **End**: read the end-of-session checklist in section 4 and execute each
- item in sequence, without summarizing or skipping any; run
- `uv run ruff check .`, `uv run mypy --strict .` and `uv run pytest`;
- confirm no off-limits path changed without recorded approval; update
- `README.md`, `AGENTS.md` and this file together if the change touched
- structure, stack, or any convention above; commit only the task's
- changes, following section 2.1.
+ the files touched, the signatures or outline, the edge cases, the
+ assumptions. Never write implementation code before the plan is
+ approved. Skip the plan for one-line fixes, typos and fully-specified
+ requests.
+- Label a finding unverified until it is demonstrated. Reproduce a defect
+ by running the path before reporting it; read a passing test that
+ contradicts the reproduction before blaming the code.
+- Explain a deviation from a SHOULD rule in the pull request. Land a
+ deviation from a MUST or MUST NOT rule only with a designated
+ approver's sign-off and its reason recorded in the pull request. Never
+ waive a MUST rule without that sign-off.
+
+## 8. Session protocol
+
+- At the start of a session, inspect the working tree and index, and read
+ this file before making any change.
+- While working, follow sections 2 through 7 for every change.
+- Before ending a session, read the MUST and SHOULD checklists in section
+ 7 and execute each item in sequence, in full — do not summarize or skip
+ any of them.
+
+## 9. Governance
+
+- **Who approves a change?** Open for the project to decide.
+- **How is work tracked?** Open for the project to decide.
+- **What is a release?** Open for the project to decide.
diff --git a/tests/efficacy/arms/inline/generation.json b/tests/efficacy/arms/inline/generation.json
index b3d2955..4c36073 100644
--- a/tests/efficacy/arms/inline/generation.json
+++ b/tests/efficacy/arms/inline/generation.json
@@ -2,11 +2,11 @@
"arm": "inline",
"kind": "model",
"output_model": "inline",
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-10-27T07:33:38",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T20:55:33",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -33,9 +33,9 @@
"templates/data/data-modeling.md",
"templates/data/data-governance.md"
],
- "prompt_chars": 83333,
+ "prompt_chars": 84056,
"prompt_leak": null,
- "prompt_file": "C:/Users/BGEORG~1/AppData/Local/Temp/r5gen\\arm-inline-prompt.txt",
+ "prompt_file": "C:\\efficacy\\gen6b-inline\\arm-inline-prompt.txt",
"auth_probe": "ready",
"command": [
"C:\\Users\\bgeorgiev\\.local\\bin\\claude.EXE",
@@ -51,7 +51,7 @@
"--setting-sources",
"",
"--settings",
- "C:/Users/BGEORG~1/AppData/Local/Temp/r5gen\\home\\settings.json",
+ "C:\\efficacy\\gen6b-inline\\home\\settings.json",
"--strict-mcp-config",
"--disallowed-tools",
"WebSearch",
@@ -59,20 +59,20 @@
],
"model": "claude-sonnet-5",
"effort": "high",
- "elapsed_s": 358.7,
+ "elapsed_s": 430.0,
"exit_status": 0,
"result": {
- "duration_api_ms": 355213,
+ "duration_api_ms": 427908,
"stop_reason": "end_turn",
- "session_id": "0b18b764-6454-4a3d-b857-b2b08f8dfb10",
- "total_cost_usd": 0.57898,
+ "session_id": "4b6adbf2-f3cc-4144-8121-990b729f4e89",
+ "total_cost_usd": 0.5432242,
"usage": {
"input_tokens": 2,
- "cache_creation_input_tokens": 63359,
- "cache_read_input_tokens": 0,
- "output_tokens": 32554,
+ "cache_creation_input_tokens": 38590,
+ "cache_read_input_tokens": 25101,
+ "output_tokens": 38384,
"output_tokens_details": {
- "thinking_tokens": 23577
+ "thinking_tokens": 29500
},
"server_tool_use": {
"web_search_requests": 0,
@@ -80,19 +80,19 @@
},
"service_tier": "standard",
"cache_creation": {
- "ephemeral_1h_input_tokens": 63359,
+ "ephemeral_1h_input_tokens": 38590,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
- "output_tokens": 32554,
- "cache_read_input_tokens": 0,
- "cache_creation_input_tokens": 63359,
+ "output_tokens": 38384,
+ "cache_read_input_tokens": 25101,
+ "cache_creation_input_tokens": 38590,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
- "ephemeral_1h_input_tokens": 63359
+ "ephemeral_1h_input_tokens": 38590
},
"type": "message"
}
@@ -103,16 +103,16 @@
"modelUsage": {
"claude-sonnet-5": {
"inputTokens": 2,
- "outputTokens": 32554,
- "cacheReadInputTokens": 0,
- "cacheCreationInputTokens": 63359,
+ "outputTokens": 38384,
+ "cacheReadInputTokens": 25101,
+ "cacheCreationInputTokens": 38590,
"webSearchRequests": 0,
- "costUSD": 0.57898,
+ "costUSD": 0.5432242,
"contextWindow": 1000000,
"maxOutputTokens": 64000,
- "thinkingTokens": 23577,
+ "thinkingTokens": 29500,
"cacheCreationEphemeral5mInputTokens": 0,
- "cacheCreationEphemeral1hInputTokens": 63359,
+ "cacheCreationEphemeral1hInputTokens": 38590,
"canonicalModel": "claude-sonnet-5",
"provider": "firstParty",
"costBasis": "list"
@@ -151,20 +151,23 @@
"num_turns": 1,
"subtype": "success",
"api_error_status": null,
- "result": "# tariff\n\nA pricing and invoicing web application for Imbra Ltd: a product catalog,\ndiscount rules of several kinds, tax jurisdictions, customers, and invoices\nassembled from them.\n\nImbra Ltd. Stack: Python 3.12, Flask 3, Jinja, HTMX, SQLite. Tooling: uv,\nruff, mypy (strict), pytest. Runs locally only; there is no deployment\ntarget and nothing in the system reaches the network.\n\n- Model: inline\n\nPrecedence when rules conflict: GDPR obligations (section 3.10) override\nevery other rule in this file; this file overrides personal preference;\n`README.md` is the single source of truth for project structure. This file\ncarries every rule the project has adopted, inline \u2014 nothing here is a\npointer to an external document.\n\nA sibling `AGENTS.md` carries the same rules for any non-Claude agent.\nUpdate `CLAUDE.md`, `AGENTS.md` and `README.md` together whenever a change\ntouches architecture, stack, structure, setup, or the conventions below;\nnever let `AGENTS.md` and `CLAUDE.md` disagree.\n\n## Rule language\n\nA plain imperative (\"Use X\", \"Never Y\") means MUST or MUST NOT. Where\nstrength matters, the keyword is explicit:\n\n| Word | Meaning |\n| --- | --- |\n| MUST | Absolute requirement; a deviation needs an approver's sign-off |\n| MUST NOT | Absolute prohibition; a deviation needs an approver's sign-off |\n| SHOULD | Recommended; a deviation needs a justification |\n| SHOULD NOT | Not recommended; may be ignored with a justification |\n| MAY | Optional; the developer decides |\n\n## 1. Project\n\n### 1.1 Overview\n\nSee the precedence and stack summary above. Two actors reach this system:\nthe administrator, signed in through the browser, and a second program\nthat imports the pricing engine directly as a Python library, with the web\napplication absent. Customers are data subjects under the EU GDPR: their\nname, email and postal address are stored and printed on the invoices\nbilled to them (see section 3.10).\n\n### 1.2 Project structure\n\nSee `README.md` for the full directory layout; this file does not\nduplicate it.\n\n- Keep the pricing engine (catalog, discount rules, tax jurisdictions,\n invoice assembly, invoice export) as a standalone Python package that\n imports nothing from Flask, Jinja, HTMX or any HTTP/web-framework code\n (MUST); another program must be able to import it with the web\n application absent.\n- Keep the Flask web app a thin caller of that library: a route decodes a\n request, calls the library, renders a template; never duplicate pricing,\n discount, tax or invoice-assembly logic in the web layer (MUST).\n- Keep invoice export logic (PDF/CSV/etc.) inside the library beside the\n invoice-assembly code it serializes, not in the Flask layer.\n\n### 1.3 Commands\n\n```bash\nuv sync # install dependencies\nuv run flask run # run the app locally\nuv run ruff check . # lint\nuv run ruff format . # format\nuv run mypy --strict . # type-check\nuv run pytest # run tests\nuv run pytest --cov # run tests with coverage\n```\n\n## 2. Code conventions\n\n### 2.1 Git\n\n- Commit under one full name and one consistent email; never change\n identity mid-project.\n- Work on a branch; never commit directly to `main`.\n- Never commit build output, the virtual environment, `__pycache__`, or\n secrets.\n- Keep a `.gitignore` covering `.venv`, `__pycache__`, build output,\n `.env*`, editor state, OS files and coverage output (MUST).\n- Commit `uv.lock` (MUST).\n- Treat the repository as public: no secret, credential or sensitive value\n in source or history.\n- Inspect the working tree and the index before starting a task.\n- Never discard, reset, stash or overwrite a change the task did not make\n (MUST NOT); never clear the tree for a clean test baseline without\n asking.\n- Stage only the changes the task made; read the staged diff before\n committing.\n- Stop and ask when a task change and a prior change share a hunk; report\n a pre-existing change that blocks the task rather than removing it.\n- Keep a pull request to one concern (SHOULD); test locally before\n committing.\n- Review every diff against the base before merging, in order: security,\n correctness, clarity, conventions. Merge only once review passes and CI\n is green.\n- Read the CI run for the push before calling a change good; never merge\n while a check is failing, cancelled, or not yet registered.\n- Never force-push, including `--force-with-lease` (MUST NOT); update a\n branch by merging the base into it.\n\n#### Off-limits paths\n\nThese MUST NOT change without explicit approval. Propose a change inside\none of them with a rollback strategy and the tests that would catch a\nregression, before making it:\n\n- Authentication and session code (sign-in, password hashing, session\n cookie configuration)\n- Database migrations\n- `.env*` and any secrets file\n- CI/CD workflow files\n\nName any off-limits path touched at the top of the change's summary,\nwhether proposed or already approved.\n\n### 2.2 Python\n\n- Name a function with a verb, a class or module with a noun, a boolean\n with `is`, `has` or `can`.\n- Rename a name that needs a comment to explain it; use the same name for\n the same concept in every module (e.g. always `tax_jurisdiction`, never\n mixed with `tax_zone`).\n- Name a public enum member or result discriminator for the capability it\n offers, never the library behind it.\n- Keep cognitive complexity at or under 15 per function; enforce it with\n `ruff`'s `C90` rules and `max-complexity = 15` in `pyproject.toml`.\n- Nest at most three levels; use guard clauses and early returns.\n- Replace a boolean flag parameter that selects behaviour with an enum or\n two named functions.\n- Name every magic number and magic string as a constant; keep a constant\n beside the function that uses it.\n- Encode every committed text file in UTF-8 with LF line endings; keep\n identifiers ASCII.\n- Prefer code that needs no comment; comment only non-obvious intent;\n never cite a ticket or PR number in a comment or docstring.\n- Commit no debug output (`print()`), no commented-out code, and no\n hardcoded breakpoint; gate any debug tooling behind an environment\n variable, off by default.\n- Delete a probe script before the commit that uses its findings; keep the\n findings in a comment, decision record or doc, never in the probe.\n- Type-annotate every function signature; keep `mypy --strict .` and\n `ruff check .` clean as a merge gate (MUST).\n\n## 3. Quality\n\n### 3.1 Architecture and dependencies\n\n- Keep one authoritative representation of each piece of knowledge (DRY);\n extract shared logic only where substantial logic repeats.\n- Choose the simplest solution a stated requirement justifies (KISS);\n build only what is needed now (YAGNI).\n- Compute every derived count, total, tax amount or discount from the\n data; never hardcode one.\n- Remove unused modules, assets and data files promptly.\n- Snapshot pricing, discount and tax data onto an invoice at creation time;\n never recompute a historical invoice from current catalog, discount or\n tax-jurisdiction state (a later price or rate change must never alter an\n already-issued invoice).\n- Keep the module graph acyclic; break a cycle with a third module, never\n a divergent local copy.\n- Keep coupling shallow: a change inside one module must not require\n changes in unrelated modules.\n- Never let the pricing-engine library write to standard output or error,\n or configure logging beyond its own logger (MUST); make its logger\n injectable, falling back to its module logger, and verify the silence in\n a fresh process.\n- Enforce the library/web-app import boundary with a test\n (e.g. `test_library_has_no_web_imports`) asserting that no module under\n the pricing-engine package imports `flask`, `jinja2`, or anything from\n the web layer.\n\n### 3.2 Errors\n\n- Validate input at boundaries (the HTTP layer, the library's public\n functions) and fail at once on invalid state.\n- Read a value from its source-of-truth field and raise when it is\n missing; never fall back to a value derived from a slug, name or hash.\n- Never break a public catch contract: a raise callers catch by a built-in\n type keeps that type.\n- Add an error type only where a caller could act differently.\n\n### 3.3 Deprecation\n\n- Deprecate a public symbol in the pricing-engine library, naming its\n replacement, before a later change removes it; the second program\n consumes this library's API directly and has no version negotiation to\n fall back on.\n- Deprecate every part of one call site together; never alias the outer\n name alone while silently changing its keyword arguments.\n\n### 3.4 Destructive operations\n\n- Delete, truncate or overwrite only what the operation can prove it\n should affect: a specific customer ID matched exactly, never a loose\n filter.\n- Validate the input before any destructive operation: reject an empty or\n malformed ID.\n- Apply this with particular care to GDPR erasure (section 3.10): verify\n the customer record matched is the one requested before deleting or\n anonymizing it.\n\n### 3.5 Completion\n\n- Finish a task when the requested behaviour works through the entry point\n its user or caller reaches (the browser UI or the library's public API),\n and the checks that prove it pass.\n- Report a check that could not run as not run, never as a pass.\n- Add an abstraction or process step only when a stated requirement, a\n demonstrated defect, or a material risk justifies it.\n- Report a problem found outside the task's scope rather than fixing it in\n the same change (SHOULD).\n\n### 3.6 Testing\n\n- Classify a test by the boundary it crosses: unit (none), integration\n (the SQLite database), system (the whole app against its requirements),\n regression (reusing existing tests), exploratory (unscripted).\n- Double only what crosses a boundary: the database, time, randomness;\n keep deterministic in-process collaborators real.\n- Add a regression test for every fixed defect (SHOULD).\n- Cover every happy path the pricing, discount, tax and invoicing rules\n define, plus negative inputs and edge cases (SHOULD).\n- Keep pricing, discount and tax logic in pure functions; push the SQLite\n access to thin adapters at the edges; inject the database session rather\n than construct it inside the code under test.\n- Set or clear every environment variable a test depends on inside that\n test; never rely on ambient process state.\n- Treat a test that passes or fails by run order as an isolation bug;\n investigate a failing test before skipping or suppressing it.\n- Reset database state between test runs (a transaction rolled back per\n test, or a fresh SQLite file); never substitute a different database\n engine in tests.\n- Assert at least one case against a fixed vector from the ISO 4217 minor-\n unit table for currency rounding; never take a round trip through your\n own rounding code as proof it is correct.\n- Give every fact stored in two places (a documented field's maximum\n length and the constant enforcing it, for instance) a test that fails\n when the two diverge.\n- Verify a change to rendered HTML or an HTMX fragment against the\n rendered output, not the template source.\n- Never let coverage regress between commits; run every test from CI with\n no human step.\n\n### 3.7 HTTP and web conventions\n\n- Keep Flask route handlers thin: decode the request, call the pricing\n library or a service function, render the response; never put pricing,\n discount, tax or invoice logic in a handler.\n- Parse a typed query parameter explicitly so absent (use the default),\n present-and-valid (use it), and present-but-invalid (raise 400) are\n distinct; never let a parsing helper silently turn an invalid value into\n a default.\n- Never let a `GET` or `HEAD` request change state; make every HTMX\n `PUT`/`DELETE`-driven action idempotent.\n- Represent every date and time as ISO 8601 and every currency amount with\n its ISO 4217 code; store and compute money as an integer in minor units\n or as a decimal type, never as a float.\n- Use a consistent error response shape across the app; never return a\n stack trace, an internal path, or a raw database error to the browser;\n log the full detail server-side and show the administrator a generic\n message.\n- Enforce authentication on every route (MUST); this application declares\n no public endpoint. Apply authentication before any business logic\n runs.\n- Run a one-off task (a migration, a data fix, a REPL session) as a script\n committed to the repository, using the application's own code and\n config, never as an ad-hoc shell command.\n\n### 3.8 Database conventions\n\n- Make every schema change through a migration committed to source control\n (MUST); never edit the SQLite file by hand. One migration per logical\n change, with both an `up` and a `down` step; say in the migration and\n get approval when the `down` step would lose data.\n- Never modify a migration that is already merged.\n- Parameterize every query that takes a value; never build a query by\n string interpolation (see also section 3.9).\n- Bound every query an interactive request runs with a limit or\n pagination; select only the columns the code uses; fetch an invoice's\n related line items in one query, never one query per row.\n- Index every foreign key column (`customer_id` on invoices, `product_id`\n on line items, and similarly for discount and tax-jurisdiction\n references); drop an index once it is unused.\n- Wrap a multi-step write (assembling an invoice across its tables) in a\n transaction; keep transactions short; never call out to another process\n inside one.\n- Inject the database session as a dependency; no global database handle.\n- Use hard delete or anonymization for a GDPR erasure request, never a\n soft-delete flag alone (see section 3.10); where a soft delete is used\n elsewhere for audit history, filter deleted rows out of every query by\n default.\n- Never run a schema migration against production data inside a test\n suite.\n\n### 3.9 Security\n\n- Validate all external input (every form field, query parameter and HTMX\n payload) at the boundary with a schema-validation library; use an\n allowlist, not a blocklist; reject invalid input with a clear error\n rather than silently coercing it.\n- Never bypass Jinja's autoescaping with a raw-HTML path for user-supplied\n data (product names, customer names and addresses, discount codes\n included).\n- Use parameterized queries for all database access; never concatenate\n user input into SQL.\n- Hash the administrator's password with bcrypt, scrypt or Argon2; never\n MD5, SHA-1 or plain SHA-256. Require a minimum password length and\n reject known-breached passwords; impose no composition rules.\n- Use constant-time comparison for secrets and tokens; lock the account or\n throttle after repeated failed sign-in attempts.\n- Generate the session ID with a cryptographic random generator and\n regenerate it after login (session fixation).\n- Set `HttpOnly`, `Secure` and `SameSite=Strict` on the session cookie;\n expire the session after 30 minutes idle; invalidate it on logout.\n- Give every state-changing request (every `POST`, `PUT`, `PATCH`,\n `DELETE` the admin UI issues, HTMX included) a CSRF defence, since the\n session is carried by an ambient cookie; use Flask's own CSRF protection\n rather than hand-rolled tokens; never change state on a `GET`.\n- Never hardcode a secret, API key or credential in source; keep `.env`\n out of version control; rotate a secret immediately if it is\n accidentally committed, and warn the user before committing a file that\n commonly holds one.\n- Set `X-Content-Type-Options: nosniff` and `X-Frame-Options: DENY` (or an\n equivalent CSP `frame-ancestors`) on every response.\n- Never expose a stack trace, internal path or database error to the\n administrator's browser; return a generic message and log the detail\n server-side.\n- Never log a secret, token, password, or PII (name, email, address); log\n authentication failures and access denials at WARN with an opaque user\n ID, never a submitted username.\n- As the coding agent: never read, print or `cat` a file that may hold a\n secret (`.env`, `*.pem`, `*.key`, `credentials.json`); never echo or log\n an environment variable's value; verify a secret's presence by an\n existence check, never by printing it.\n\n### 3.10 Data modeling and GDPR\n\n- Use one naming convention for every table, field, key and index\n (`snake_case`); give every table a primary key, surrogate for internal\n use.\n- Store each fact once; document the rationale for any intentional\n denormalization.\n- Never pack several values into one field (a comma-joined list of line\n items, for instance); use a related record instead.\n- Enforce every reference (customer, product, discount rule, tax\n jurisdiction) with a foreign-key constraint; decide and document what\n happens on delete for each: clear the reference, refuse the delete, or\n (for an invoice, which must keep its billed values regardless of later\n catalog changes) rely on the snapshot in section 3.1 rather than a live\n reference.\n- Run every schema change through a versioned migration; keep an additive\n change compatible with old data (a new field optional or defaulted);\n give a destructive change an add-migrate-drop plan.\n- Store timestamps in UTC; store monetary values as an integer in minor\n units or a decimal type, never a float; document a maximum length for\n every text field (customer name, email, postal address, product name,\n discount code).\n- Classify every field: customer name, email and postal address are\n Confidential (PII); invoice amounts and line items are Confidential;\n product catalog, discount rules and tax-jurisdiction data are Internal.\n Document this in the schema or a data dictionary, and restrict access to\n the Confidential tier to the signed-in administrator.\n- Minimize PII collection: store only what invoicing needs (name, email,\n postal address); never put PII in an application log, error message or\n stack trace.\n- Mask or use synthetic data for PII in any non-production environment\n (development fixtures, test data).\n- Provide a mechanism to erase a customer's PII on request (GDPR Art. 17):\n hard-delete or anonymize it, never a soft-delete flag alone. Where a\n statutory retention duty (e.g. tax-record retention) requires keeping\n the invoice itself, anonymize the customer's name, email and address on\n the retained invoice rather than deleting the invoice, and document the\n retention period relied on.\n- Provide a mechanism to export a copy of everything held about a customer\n on request (GDPR Art. 15/20), in a structured, commonly used format.\n- Define and document a retention period for each data category\n (customers, invoices, backups); implement automated purging rather than\n a manual process; apply the same retention to backups, and never retain\n a backup indefinitely.\n- Log every change to Confidential data: who (the administrator's opaque\n ID), when, what changed, and the previous value \u2014 except a credential's\n or a PII field's own value, which the audit entry must record as\n \"changed\" without storing either value, so an erasure leaves no copy in\n the append-only trail.\n- Data ownership (who owns the customers, invoices and catalog domains) is\n not settled by the project; assign one before this matters operationally.\n\n### 3.11 Accessibility and UX\n\n- Make every interactive element reachable and operable by keyboard; never\n put a click handler on a non-focusable element \u2014 use a native button or\n link instead.\n- Style focus with `:focus-visible` and keep a visible focus indicator on\n every focusable element, including links.\n- Never convey meaning by colour alone; keep text contrast at 4.5:1 (3:1\n for large text); give every image descriptive `alt` text (`alt=\"\"` when\n decorative).\n- Use semantic HTML with a correct heading hierarchy.\n- Scan rendered pages with an automated accessibility checker in CI, and\n merge only on zero violations.\n- Before shipping a new interactive component: tab through it without a\n mouse, walk it with one screen reader, and zoom to 200% to check nothing\n clips or scrolls horizontally.\n- Support the last two versions of Chrome, Firefox, Safari and Edge.\n\n## 4. Review process\n\nReview in this order, most critical first:\n\n1. **Security**: anything exploitable, any credential or licence problem\n2. **Correctness**: wrong results, unhandled failures, race conditions\n3. **Clarity**: obscure names, deep nesting, high cognitive complexity,\n boolean flag parameters\n4. **Conventions**: deviations from the rules in section 2 and 3\n\nLabel each finding a demonstrated defect, a policy deviation, or a\nsuggestion. Block a merge only on a defect or a policy deviation; leave a\nsuggestion to the author.\n\n### End-of-session checklist\n\nRead every item below and execute it in sequence before ending a session;\nnever summarize or skip one.\n\n**MUST**\n\n- [ ] No credential, token or sensitive value appears in a committed file\n- [ ] Every failure path is handled; no silent catch, no swallowed\n exception\n- [ ] Every new dependency carries a licence the project's policy allows\n- [ ] Significant logic and architectural decisions are documented\n- [ ] Existing documentation matches the code after the change\n- [ ] Every changed section was re-read whole, not only the changed line\n- [ ] Every claim changed text makes about itself, such as a count or\n \"all\", was checked by counting with a tool\n- [ ] Input from outside the process (a form field, a query parameter) is\n validated as untrusted before it is destructured, indexed, or used\n as a key\n- [ ] A refactor preserves behaviour on every path: each case, direction\n and mode, including null handling, sort order and boundary values\n\n**SHOULD**\n\n- [ ] Each non-trivial function has a unit test per relevant variant\n- [ ] Coverage does not fall\n- [ ] Lint errors and warnings do not rise\n- [ ] Each third-party dependency is necessary, understood and maintained\n- [ ] No new abstraction without two call sites, and no new dependency\n without a documented reason\n\n### CI signals\n\n- Read the log of a red check before calling the pull request green or\n red.\n- Separate an infrastructure failure (the check could not run) from a diff\n failure (it ran and found something), and say which in the merge\n decision.\n- Never retry until green without saying so; never bypass a failing check\n by skipping hooks or an admin merge without the approver's explicit\n acceptance of the risk.\n\n### Picking up an issue\n\n- Re-read the target for existing coverage before writing anything; verify\n everything the issue cites as existing against the current tree.\n- Check open pull requests and accepted decisions since the issue's filing\n date for work that already closes or moves it.\n- Resolve a cited version or classification against its actual source\n rather than trusting the issue's description of it.\n\n### Planning\n\n- Produce a plan before implementing a feature or a non-trivial change:\n the files, the signatures or outline, the edge cases, the assumptions.\n- Never write implementation code until the plan is approved (MUST NOT);\n skip the plan only for one-line fixes, typos, and changes the requester\n has specified in full.\n- Stay inside the approved plan; when a constraint invalidates it, stop\n and re-surface the options.\n\n### Verifying a finding\n\nLabel a finding unverified until it is demonstrated.\n\n- From reading: reproduce the defect by running the path; read a passing\n test that contradicts the reproduction before blaming the code.\n- From a measurement: confirm the tool measured the rule's actual unit and\n the claimed scope (not a diff or a sample); check one flagged item and\n one zero result by hand.\n- From an extraction: check an element reported absent against the raw\n artifact; scope the claim to what was inspected (\"not verifiable from\n the extract\", never \"missing\").\n- From a probe: confirm it ran under the conditions the finding is about\n (user, credential, environment); scope the claim to what it actually\n tested.\n- From an agent: check its finding against the file, commit or document\n that settles it before acting on it or repeating it; count a finding\n several agents agree on as one finding.\n\n### Deviations\n\n- Explain a deviation from a SHOULD rule in the pull request.\n- Land a deviation from a MUST or MUST NOT rule only with a designated\n approver's sign-off and its reason recorded in the pull request; never\n waive one yourself.\n\n### Cold-reader writing\n\nApply this to every ticket, pull request and defect record, since the\nrecord outlives the session:\n\n- State the symptom before the mechanism; expand a term taken from the\n code at its first use, or avoid it.\n- Show a real example rather than describe one; keep to one idea per\n sentence.\n\n### Governance questions\n\n- **Who approves a change?** Not stated by the project; open for the\n project to decide. Until an approver is named, treat every MUST/MUST NOT\n deviation above as blocked.\n- **How is work tracked?** Not stated; open for the project to decide.\n- **What is a release?** Not applicable in the usual sense: the project\n runs locally with no deployment target. \"Shipping\" a change means\n merging it to `main` with a green CI run; there is no deployment step.\n\n## 5. Session protocol\n\n- **Start**: read this file and `README.md`; run `git status` and inspect\n the working tree and index before making any change; never discard or\n overwrite a change the task did not make.\n- **Proceed**: follow the planning rule in section 4 for anything beyond a\n one-line fix; stay inside the approved plan; propose any off-limits-path\n change (section 2.1) before making it.\n- **Disagreement between a document and the system**: never act on the\n document alone when the observed system state is defensible; find the\n rule that governs both (this file, or GDPR for section 3.10) and fix\n whichever one that rule does not support.\n- **End**: read the end-of-session checklist in section 4 and execute each\n item in sequence, without summarizing or skipping any; run\n `uv run ruff check .`, `uv run mypy --strict .` and `uv run pytest`;\n confirm no off-limits path changed without recorded approval; update\n `README.md`, `AGENTS.md` and this file together if the change touched\n structure, stack, or any convention above; commit only the task's\n changes, following section 2.1.",
- "ttft_ms": 270171,
+ "result": "# tariff\n\nPricing and invoicing web application \u2014 Imbra Ltd\nOwner: Imbra Ltd. Runs locally only; no repository URL, live URL or deployment target applies.\n- Model: inline\n\n## 1. Project\n\n### 1.1 Overview\n\n`tariff` assembles invoices from a product catalog, several kinds of discount\nrule, tax jurisdictions and customers. Stack: Python 3.12, Flask 3, Jinja,\nHTMX, SQLite. It runs locally, with no deployment target.\n\nTwo actors use it: an administrator working in a browser, and a separate\nprogram that imports the pricing engine directly as a library, without the\nweb application present. The store is a local SQLite file. Nothing in this\napplication reaches the network: no outbound HTTP call, no inbound API\nbeyond the local web UI, no CORS surface, no SSRF surface. Do not add one\nwithout revisiting this file.\n\nOne administrator signs in to use the web application; nobody else has an\naccount. Customers are people: the system stores each one's name, email and\npostal address, and names them on the invoices billed to them. Imbra Ltd is\nin the EU, so GDPR applies \u2014 see section 6.\n\n### 1.2 Project structure\n\nSee `README.md` for the directory map; do not duplicate it here.\n\nPlacement rule: keep the pricing engine in its own package, with no import\nof Flask, Jinja, HTMX or any other web-layer module. It must import and run\ncorrectly with the web application absent. The web application package may\nimport the pricing engine; the reverse must never happen.\n\n### 1.3 Commands\n\nThe project has not yet chosen a package manager, test runner, type\nchecker, linter or formatter. Until it does, each command below names what\nit must do, not how:\n\n- **Install**: resolve and install the project's pinned dependencies from\n its lockfile.\n- **Migrate**: apply pending SQLite schema migrations through a committed\n script before the application starts.\n- **Run**: start the Flask application locally, reading the port from an\n environment variable, with a sensible default for local development.\n- **Test**: run the automated test suite (unit and integration) covering\n both the pricing engine library and the web application.\n- **Type-check / Lint / Format**: run the project's static type checker,\n linter and formatter, each in its strict and quiet mode, reporting zero\n issues.\n\n## 2. Architecture boundaries\n\n- Keep the pricing engine a standalone Python library with no dependency on\n Flask, Jinja, HTMX or any web-layer code (MUST); it must import and run\n with the web application absent.\n- Treat the web application as one caller of the pricing engine, never a\n second place that computes a price, discount or tax figure \u2014 call the\n library; never re-implement its logic in a route handler or a template.\n- Keep the module graph acyclic: the web application depends on the\n pricing engine; the pricing engine never imports the web application\n (MUST).\n **Check**: no module under the pricing-engine package imports anything\n from the web-application package; the check must report zero violations.\n- Treat the pricing engine's public functions and classes as the contract\n the other program \u2014 its second caller \u2014 depends on. Apply the\n deprecation rule (section 3.2) before changing or removing any of them.\n- Give the pricing engine package its own version, independent of the web\n application's; bump it deliberately, following semantic versioning,\n whenever its public API changes.\n- Never let the pricing engine write to standard output or standard error,\n and never let it configure logging beyond its own logger (MUST). Make\n its logger injectable, falling back to its own module logger, so each\n caller captures its output on its own terms.\n **Check**: run the library alone in a fresh process and confirm it emits\n nothing on stdout or stderr; a test runner's own log handler can hide a\n default that would otherwise leak into both callers.\n\n## 3. Code conventions\n\n### 3.1 Git\n\n- Commit under one full name and one consistent email; never change\n identity mid-project.\n- Work on a branch; never commit directly to `main`.\n- Never commit build output, dependency directories or secrets. Commit a\n generated file only when the project tracks it on purpose.\n- Keep a `.gitignore` (MUST) covering dependencies, build output, secrets,\n editor state, OS files and coverage output.\n- Commit lockfiles (MUST).\n- Inspect the working tree and the index before starting a task. Never\n discard, reset, stash or overwrite a change the task did not make.\n Stage only the changes the task made \u2014 a whole file only when it held\n no prior change, otherwise only the task's hunks. Read the staged diff\n before committing. Stop and ask when a task change and a prior change\n share a hunk. Report a pre-existing change that blocks the task rather\n than removing it.\n- Keep a pull request to one concern (SHOULD). Test locally before\n committing. Review the diff against the base before merging, in the\n order security, correctness, clarity, conventions. Merge only after the\n review passes and CI is green.\n- Read the CI run for the push before describing a change as good. Treat\n a pull request with no registered check as not passed. Never merge\n while a check is failing, cancelled or not yet registered. Re-run a\n verification a pull request claims once the base has moved since it was\n written. Read a new or changed workflow's first run in its real\n environment before trusting it.\n- Never force-push, including with `--force-with-lease` (MUST NOT). Bring\n a branch up to date by merging the base into it, never by rebasing and\n force-pushing.\n\n**Off-limits paths** (MUST NOT change without explicit approval; propose\nfirst, with a rollback strategy and the tests that would catch a\nregression):\n\n- Authentication and session code (the administrator's sign-in).\n- SQLite migrations.\n- `.env*` and secrets.\n- CI/CD workflow files, if and when the project adds any.\n- Payment code: not applicable \u2014 this application does not process\n payments.\n\nA diff confined to prose is ordinary work; a comment a tool reads (a\nlinter disable, a coverage pragma) counts as executable content and is\noff-limits the same as a command or a permission. Name an off-limits path\nat the top of a change's summary whenever the diff touches one, proposal\nor not.\n**Check**: the change summary names every off-limits path the diff\ntouches; the check must report zero undeclared touches.\n\n### 3.2 Python\n\n- Keep one authoritative representation of each piece of pricing, discount\n or tax knowledge (DRY). Build only what a stated requirement justifies\n (YAGNI); record beside every deferral the concrete condition that\n reopens it. Delete a path once evidence shows it unreachable.\n- Compute derived counts and statistics from the data; never hardcode\n them. Remove unused modules, assets and data files promptly.\n- Name a function with a verb, a class or module with a noun, a boolean\n with `is`, `has` or `can`. Rename a name that needs a comment to explain\n it. Use the same name for the same concept in every module.\n- Keep cognitive complexity at or under 15 per function; nest at most\n three levels; use guard clauses and early returns. Replace a boolean\n flag that selects behaviour with an enum or two named functions.\n- Name every magic number and string as a constant \u2014 a discount\n percentage, a tax rate, a threshold. Size a tuned threshold from its\n measured distribution, naming the data source beside the constant;\n take a limit a specification fixes (e.g. a tax jurisdiction's own\n rounding rule) from that specification instead.\n- Keep coupling shallow: a change inside one module must not require\n changes in unrelated modules. Talk only to direct dependencies. Reach a\n heavy or platform-limited dependency through one module that owns its\n import.\n- Validate input at boundaries and fail at once on invalid state. Read a\n value from its source-of-truth field, and raise when it is missing;\n never fall back to a value derived from a slug, name or hash. Add an\n error type only where a caller could act differently. Never let a\n caller-side filter stand in for a precondition.\n- Deprecate a public symbol, naming its replacement, before a later change\n removes it. Deprecate every part of one call site together; never alias\n the outer name alone.\n- Keep constants beside the functions that use them.\n- Encode every committed text file in UTF-8 with LF line endings (MUST);\n keep identifiers ASCII (MUST). Set a program's output encoding\n explicitly wherever another program reads its output \u2014 in particular,\n the invoice export path. Commit a `.gitattributes` with `* text=auto`,\n adding `eol=lf` for hard LF.\n **Check**: every tracked text file is UTF-8 with LF endings and ASCII\n identifiers; the check must report zero exceptions.\n- Prefer code that needs no comment. Never cite a ticket, PR or ADR number\n in a comment or docstring \u2014 state the substance. Name a source (author,\n year, method) where a tax or discount rule's logic is non-obvious.\n- Commit no debug output (`print()`) and no hardcoded breakpoint. Delete\n commented-out code. Gate debug tooling behind a flag, off by default.\n- Write a probe script to measure data or behaviour rather than guess;\n delete it before the commit that uses its findings; keep the findings\n themselves in durable comments or decision records.\n- Grep for a construct a comment records as not working before reusing\n it; read every hit as a suspected instance of the same defect.\n- Run a new constraint \u2014 a tightened bound, a narrowed exemption \u2014 against\n the existing corpus before it merges.\n- When deleting, truncating or purging data (notably a GDPR erasure, see\n section 6), act only on what the operation can prove is its target: an\n exact customer ID, not a name match or a path guess. Find nothing, and\n raise, where that proof is unavailable.\n- Confirm a migration, import or bulk-edit script is correct before\n acting on its output in bulk; cross-check an independent source before\n overwriting stored data that looks wrong.\n- Adopt the project's static type checker at its strictest setting and\n keep it clean (MUST); annotate every public function's parameters and\n return type (MUST). Adopt a linter and a formatter and keep both clean\n (MUST). Run all three before every commit and in CI; each must print\n nothing.\n- Finish a task when the requested behaviour works through the entry\n point its caller reaches, and the checks that prove it pass. Report a\n check that could not run as not run, never as a pass. Report a problem\n found outside the task as its own task rather than folding it in.\n\n### 3.3 Web layer (Flask / Jinja / HTMX)\n\n- Read the port from an environment variable; never hardcode it. Keep\n initialisation short.\n- Run one-off tasks (migrations, data fixes) with the application's own\n code, config and dependencies; commit admin scripts to the repository\n rather than running ad-hoc shell commands; prefer idempotent scripts;\n never run one against the live database without a tested rollback plan.\n- Keep handlers thin: decode the request, call the pricing engine or a\n service function, render the response. Never put business logic in a\n handler. Validate all incoming request data before processing it.\n- Parse a typed query parameter explicitly, distinguishing absent\n (default), present-and-valid (use it) and present-but-invalid (raise a\n 400) \u2014 never let a parsing helper silently turn a bad value into the\n default.\n- Read header names case-insensitively. Avoid the `X-` prefix on a custom\n header; use an application-specific prefix instead.\n- Never let a GET or HTMX `hx-get` request change state. Make every PUT\n and DELETE (including an `hx-delete`) idempotent.\n- Represent dates and times as ISO 8601, currency codes as ISO 4217, and\n country or tax-jurisdiction codes as ISO 3166-1 alpha-2, wherever the\n application stores, computes or displays them.\n- Use a consistent error shape across every route and HTMX fragment. Never\n expose a stack trace or an internal path to the browser; return a\n generic message and log the detail server-side. Use proper 4xx/5xx\n status codes, never 200, for an error. Set an explicit `Content-Type`\n on every response.\n- Enforce authentication on every route (MUST); this application declares\n no public endpoint. Apply the auth check before any business logic\n runs. Never expose a write path without the authenticated\n administrator's session.\n- Not applicable, since nothing here reaches the network: HTTPS/TLS\n enforcement, HSTS and other reverse-proxy security headers, CORS,\n multi-instance process lifecycle (graceful shutdown, SIGKILL recovery).\n\n### 3.4 Data model (SQLite)\n\n- Pick one naming convention for tables, columns, keys and indexes, and\n record it here once chosen \u2014 open for the project to decide.\n- Give every table a primary key; prefer a surrogate key. Store each fact\n in one place; duplicate only when measured read performance requires\n it, with the rationale documented. Never pack several values into one\n field (e.g. a composite discount-rule string) \u2014 use a related record.\n- Enforce every reference (customer \u2192 invoice, invoice \u2192 product, invoice\n \u2192 tax jurisdiction) with SQLite's own foreign-key constraint, or an\n explicit check that every reference resolves. Decide what deleting the\n target of each reference does \u2014 see section 6 for the customer case.\n Document the maximum depth and cycle-prevention strategy for any\n self-referencing relationship, such as a stacked or nested discount\n rule, if one exists.\n- Make every schema change through a versioned migration (MUST); never\n edit the schema by hand. Prefer additive changes, compatible with old\n writers. Give a destructive change (drop or rename a column) a plan:\n add the new column, migrate the data, drop the old one, with both up\n and down steps (MUST). Say so, and get approval, where a down step\n cannot restore the data. Test a migration against realistic data before\n applying it.\n- Use the most specific SQLite type for each field: a date/time type, not\n a string, for dates. Store timestamps in UTC; convert to local time only\n at the presentation layer. Store every monetary value \u2014 a price, a\n discount, a tax amount, an invoice total \u2014 as an integer in minor units\n or an exact decimal type; never as a float (MUST). Document a maximum\n length for every text field: customer name, email, postal address,\n product description.\n- Open one connection per request or worker thread; never a long-lived\n global handle. Wrap a multi-step write (e.g. assembling an invoice from\n its line items) in a transaction; commit only once every write\n succeeds; keep the transaction short.\n- Bound every interactive query with a limit or pagination (e.g. a\n customer or invoice listing); a filter alone is not a bound. Select only\n the columns a code path uses. Fetch related rows for a set in one query\n or batch, never one query per row in a loop.\n- Use a hard delete or an anonymizing update for a customer erasure (see\n section 6), never a soft delete that still returns the row to ordinary\n queries. Keep an append-only audit log table instead of a soft-delete\n flag.\n- Reset state between test runs \u2014 truncate tables or roll back a\n transaction wrapping each test. Never substitute a different database\n engine in tests; SQLite's own behaviour is part of what is tested.\n Never run a schema migration against a production database inside a\n test suite.\n\n## 4. Quality \u2014 testing\n\nClassify a test by the boundary it crosses: unit (none), integration\n(process/component \u2014 e.g. a real temporary SQLite file), system (the\nwhole application against its requirements), regression (reusing\nexisting tests against a fixed defect), exploratory (unscripted).\n\n- Double only what a unit test would cross a boundary to reach: file I/O,\n the system clock (discount and tax-jurisdiction rules can be\n date-effective), randomness. Keep deterministic in-process\n collaborators real.\n- Add a regression test for every fixed defect.\n- Cover every happy path the pricing, discount, tax and invoicing rules\n define, plus negative inputs and edge cases (SHOULD), plus each\n dependency's faults (an unavailable database file, a malformed row).\n- Meet the project's coverage threshold for new code before merging;\n never let coverage regress between releases. Run every unit test from\n CI with no human step. Name a test so its name alone states the unit,\n the input and the expected outcome (SHOULD).\n- Keep pricing, discount and tax logic in pure functions; push SQLite\n access to thin adapters at the edges (SHOULD). Inject dependencies\n rather than construct them in the code under test. Split a function\n that needs more than two mocks to test.\n- Test behaviour, not implementation details. Set or clear every\n environment variable a test depends on, in that test. Treat a test that\n passes or fails by run order as an isolation bug. Wait on a condition\n with a deadline, never a fixed sleep. Never enumerate, signal or\n terminate a process the test did not start. Never mutate host state\n outside the working directory. Investigate a failing test's own logic\n before skipping or suppressing it.\n- Allocate a per-test temporary database file or path from a fixture or a\n module-level counter, never from state a test class inherits.\n- Assert after every test that no thread, subprocess or server the suite\n started survives it; join with a timeout, never a sleep.\n- Exercise every call site of a changed shared pricing, discount or tax\n path, not only the reported case; keep the list of consumers beside the\n shared path.\n\n## 5. Security\n\n- Validate all external input (invoice, customer and discount-rule forms)\n at the boundary, with a schema validator, using an allowlist. Reject\n invalid input with a clear error; never silently coerce or strip\n fields.\n- Encode dynamic data for its rendering context at the point of output.\n Rely on Jinja's auto-escaping; never insert user-supplied data through\n a raw-HTML path (`|safe`, `Markup`) that bypasses it.\n- Use parameterized SQLite queries for all database access; never\n concatenate user input into a query string.\n- Hash the administrator's password with bcrypt, scrypt or Argon2 \u2014 never\n MD5, SHA-1 or plain SHA-256. Require a minimum length and reject\n known-breached passwords; impose no composition rules. Use\n constant-time comparison for secrets and tokens. Lock the account or\n throttle after repeated failed sign-in attempts.\n- Generate the session ID with a cryptographic random generator;\n regenerate it after login. Set `HttpOnly`, `Secure` and\n `SameSite=Strict` on the session cookie. Expire the session after an\n idle period. Invalidate it on logout; do not rely on cookie expiry\n alone.\n- Give every state-changing request (every HTMX `POST`/`PUT`/`PATCH`/\n `DELETE`) a CSRF defence (MUST), since the administrator's session is\n authenticated by an ambient cookie. Use the framework's built-in CSRF\n middleware; prefer the synchroniser token pattern. Validate the token\n on every state-changing request, never on GET. Never change state on a\n GET request.\n- Never hardcode a secret, API key or credential in source. Keep local\n secret files out of version control. Rotate a secret immediately if it\n is ever committed.\n- Never expose a stack trace, an internal path or a database error to the\n administrator's browser; log the full detail server-side. Answer a\n failed sign-in the same way regardless of whether the account exists:\n \"invalid credentials\", never \"user not found\".\n- Never log a secret, token or password, and never log a customer's name,\n email or postal address (see section 6) \u2014 log an opaque ID instead.\n Sanitize any user-supplied data that reaches a log. Log authentication\n and authorization failures at WARN, with an opaque user ID, never a\n submitted username. Keep the client IP only in an access-restricted\n security log, purged at the end of its retention period.\n- Never deserialize untrusted data with a format that can instantiate\n arbitrary types; use a data-only format (JSON) for any HTMX partial\n that carries structured data. Pin dependency versions and verify\n lockfile checksums; never trust an upstream registry blindly.\n- Never read, print or `cat` a file that may hold secrets (`.env`,\n `credentials.json`, `*.pem`, `*.key`). Never echo or log an environment\n variable's value; check its presence by name only. Warn before\n committing a file that commonly holds secrets. Flag any secret exposed\n in a session immediately, name it, and recommend rotation.\n- Not applicable, since nothing here reaches the network: HTTPS/HSTS/TLS\n enforcement, reverse-proxy security headers, CORS, SSRF defences. Not\n applicable, since the application has no upload feature: file-upload\n validation.\n\n## 6. Privacy and data governance (GDPR)\n\n- Classify a customer's name, email and postal address as Confidential\n personal data. Classify an invoice (which carries that PII alongside\n pricing and tax figures) as Confidential. Classify the product catalog,\n discount rules and tax-jurisdiction tables as Internal.\n- Match access to classification: only the signed-in administrator may\n read or write Confidential data; there is no lower-privileged role to\n restrict it from.\n- Encrypt PII at rest (MUST). There is no network transit to secure here.\n- Minimize PII collection: store only the name, email and postal address\n the invoicing relationship needs.\n- Never put a customer's name, email or postal address in an application\n log, error message or stack trace (MUST NOT); use an opaque customer ID\n there instead.\n- Provide an erasure path (GDPR Art. 17) that anonymizes or removes a\n customer's name, email and postal address from the live customer record\n on request.\n- Preserve the name and address already billed on a previously issued\n invoice exactly as issued (GDPR Art. 17(3)(b) permits retaining what a\n legal \u2014 here, tax and bookkeeping \u2014 obligation requires): erase or\n anonymize the customer record, never retroactively edit an issued\n invoice's billing details. Never delete an issued invoice as a side\n effect of an erasure request; clear or anonymize the customer reference\n on it instead of deleting the row.\n- Provide an access/export path (GDPR Art. 15) that produces a complete,\n human-readable copy of a customer's stored personal data and the\n invoices billed to them, on request.\n- Record every erasure and export request in an append-only audit trail:\n who requested it, when, and what action was taken \u2014 never the PII\n values themselves, so that erasing the PII leaves no copy in the trail.\n Log every other change to Confidential data (a customer record, an\n invoice, a price-setting discount rule) the same way: who changed what,\n when, and the previous value, with PII excluded. Keep this trail in its\n own store, separate from application logs, access-restricted to the\n administrator.\n- Define a retention period for customer and invoice data that satisfies\n the bookkeeping and tax-retention law of the applicable EU member\n state, and purge data automatically once it lapses; the exact period is\n open for the project to decide, pending confirmation of the applicable\n jurisdiction. Apply the same retention and purge discipline to the\n audit trail.\n- Use synthetic customer data in tests and local development fixtures;\n never real customer PII.\n- Designate the administrator as the owner of every data domain\n (customers, invoices, products, discount rules, tax jurisdictions)\n until the project names otherwise.\n\n## 7. Review process\n\nReview in this order, most critical first, weighing each finding\nseparately: **security**, **correctness**, **clarity**, **conventions**.\nLabel each finding a demonstrated defect, a policy deviation, or a\nsuggestion; block a merge only on the first two.\n\n**MUST checklist**\n\n- [ ] No credential, token or sensitive value appears in a committed file\n- [ ] Every failure path is handled; no silent catch, no swallowed\n exception\n- [ ] Every new dependency carries a licence the project's policy allows\n- [ ] Significant logic and architectural decisions are documented\n- [ ] Existing documentation matches the code after the change\n- [ ] Every changed section was re-read whole, not only the changed line\n- [ ] Every claim changed text makes about itself (a count, \"all\") was\n checked by counting with a tool\n- [ ] Input from outside the process is validated as untrusted before it\n is destructured, indexed or used as a key\n- [ ] A refactor preserves behaviour on every path \u2014 each case, direction\n and mode, including null handling, sort order and boundary values\n\n**SHOULD checklist**\n\n- [ ] Each non-trivial function has a unit test per relevant variant\n- [ ] Coverage does not fall\n- [ ] Lint errors and warnings do not rise\n- [ ] Each third-party dependency is necessary, understood and maintained\n- [ ] No new abstraction without two call sites, and no new dependency\n without a documented reason\n\n- Produce a plan before implementing a feature or a non-trivial change:\n the files touched, the signatures or outline, the edge cases, the\n assumptions. Never write implementation code before the plan is\n approved. Skip the plan for one-line fixes, typos and fully-specified\n requests.\n- Label a finding unverified until it is demonstrated. Reproduce a defect\n by running the path before reporting it; read a passing test that\n contradicts the reproduction before blaming the code.\n- Explain a deviation from a SHOULD rule in the pull request. Land a\n deviation from a MUST or MUST NOT rule only with a designated\n approver's sign-off and its reason recorded in the pull request. Never\n waive a MUST rule without that sign-off.\n\n## 8. Session protocol\n\n- At the start of a session, inspect the working tree and index, and read\n this file before making any change.\n- While working, follow sections 2 through 7 for every change.\n- Before ending a session, read the MUST and SHOULD checklists in section\n 7 and execute each item in sequence, in full \u2014 do not summarize or skip\n any of them.\n\n## 9. Governance\n\n- **Who approves a change?** Open for the project to decide.\n- **How is work tracked?** Open for the project to decide.\n- **What is a release?** Open for the project to decide.",
+ "ttft_ms": 345832,
"type": "result",
- "duration_ms": 355592,
- "uuid": "12abf35d-ade1-4e69-b903-4eff581fe48b",
- "ttft_stream_ms": 1976,
- "time_to_request_ms": 384,
- "first_content_frame_ms": 1976,
+ "duration_ms": 428384,
+ "uuid": "6cbb0a75-a65c-4632-b129-7400d9ad854c",
+ "ttft_stream_ms": 2771,
+ "time_to_request_ms": 482,
+ "first_content_frame_ms": 2772,
"queued_turn_count": 0,
- "result_index": 0
+ "result_index": 0,
+ "credential_expires_at": "2026-12-11T13:29:52.387Z"
},
+ "budget": null,
"output_leak": null,
+ "named_tooling": [],
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\inline\\CLAUDE.md",
- "output_lines": 552,
- "output_words": 4248
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\inline\\CLAUDE.md",
+ "output_lines": 481,
+ "output_words": 4236
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/lazyref/CLAUDE.md b/tests/efficacy/arms/lazyref/CLAUDE.md
index 8aa9a64..fa8c46d 100644
--- a/tests/efficacy/arms/lazyref/CLAUDE.md
+++ b/tests/efficacy/arms/lazyref/CLAUDE.md
@@ -1,5 +1,23 @@
# tariff
+`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 — 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
+in the EU, so the GDPR applies: a customer may ask for their data to be
+erased or for a copy of it. One administrator signs in to use the
+application; nobody else has an account.
+
+Boundaries and actors: two actors, the administrator working in a browser
+and another program; the pricing engine is a library the program imports
+without the web application present, and the web application is one
+caller of it. The store is a local file. Nothing reaches the network.
+The program's interfaces are the library's own API and the invoice
+exports.
+
The project's rules are the templates below, one per topic. Do not read them
before the work starts. The first time the work touches a template's topics,
read that template, vendored at `docs/solid-ai-templates/` at the revision the
diff --git a/tests/efficacy/arms/lazyref/generation.json b/tests/efficacy/arms/lazyref/generation.json
index ad0b00c..44c5b73 100644
--- a/tests/efficacy/arms/lazyref/generation.json
+++ b/tests/efficacy/arms/lazyref/generation.json
@@ -2,11 +2,11 @@
"arm": "lazyref",
"kind": "map",
"output_model": null,
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-11-05T09:51:58",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T14:45:13",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -104,7 +104,7 @@
"budget": null,
"output_leak": null,
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\lazyref\\CLAUDE.md",
- "output_lines": 22,
- "output_words": 229
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\lazyref\\CLAUDE.md",
+ "output_lines": 40,
+ "output_words": 393
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/lazyskills/CLAUDE.md b/tests/efficacy/arms/lazyskills/CLAUDE.md
index e49453f..a34f630 100644
--- a/tests/efficacy/arms/lazyskills/CLAUDE.md
+++ b/tests/efficacy/arms/lazyskills/CLAUDE.md
@@ -1,5 +1,23 @@
# tariff
+`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 — 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
+in the EU, so the GDPR applies: a customer may ask for their data to be
+erased or for a copy of it. One administrator signs in to use the
+application; nobody else has an account.
+
+Boundaries and actors: two actors, the administrator working in a browser
+and another program; the pricing engine is a library the program imports
+without the web application present, and the web application is one
+caller of it. The store is a local file. Nothing reaches the network.
+The program's interfaces are the library's own API and the invoice
+exports.
+
The project's rules are the templates below, one per topic. Do not read them
before the work starts. The first time the work touches a template's topics,
load that template's skill; then apply every rule it holds that fits this
diff --git a/tests/efficacy/arms/lazyskills/generation.json b/tests/efficacy/arms/lazyskills/generation.json
index dfc41dc..f5ca357 100644
--- a/tests/efficacy/arms/lazyskills/generation.json
+++ b/tests/efficacy/arms/lazyskills/generation.json
@@ -2,11 +2,11 @@
"arm": "lazyskills",
"kind": "map",
"output_model": null,
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-11-05T09:52:07",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T14:45:24",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -104,22 +104,22 @@
"budget": null,
"output_leak": null,
"skills": {
- "base-quality": 1629,
+ "base-quality": 1717,
"base-git": 999,
- "base-docs": 1175,
+ "base-docs": 1166,
"base-testing": 1439,
- "base-review": 1257,
+ "base-review": 1259,
"backend-http": 899,
"backend-api": 668,
"base-security": 1581,
- "backend-auth": 609,
+ "backend-auth": 611,
"backend-database": 465,
"frontend-ux": 525,
"base-data-modeling": 449,
"base-data-governance": 515
},
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\lazyskills\\CLAUDE.md",
- "output_lines": 22,
- "output_words": 221
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\lazyskills\\CLAUDE.md",
+ "output_lines": 40,
+ "output_words": 385
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/lazyskills/skills/backend-auth/SKILL.md b/tests/efficacy/arms/lazyskills/skills/backend-auth/SKILL.md
index 26b8632..98fc706 100644
--- a/tests/efficacy/arms/lazyskills/skills/backend-auth/SKILL.md
+++ b/tests/efficacy/arms/lazyskills/skills/backend-auth/SKILL.md
@@ -9,7 +9,7 @@ description: Authn/authz, JWT, RBAC, sessions, API keys
Rules for identity verification (authn) and access control (authz).
Applies to any backend service that has protected resources.
-Extends `security/security.md`, "Authentication" (`security-authn`) and
+Extends the security rules "Authentication" (`security-authn`) and
"Session management" (`security-sessions`), with backend-specific depth.
## General principles
diff --git a/tests/efficacy/arms/lazyskills/skills/base-docs/SKILL.md b/tests/efficacy/arms/lazyskills/skills/base-docs/SKILL.md
index 853b194..d7ededa 100644
--- a/tests/efficacy/arms/lazyskills/skills/base-docs/SKILL.md
+++ b/tests/efficacy/arms/lazyskills/skills/base-docs/SKILL.md
@@ -27,8 +27,7 @@ Which documents a project keeps, and how they stay true.
[LOAD: write-docs]
-- Carry these three in every project (MUST); their layout is the project's
- own, and `templates/core/agents.md` offers a default for the agent files
+- Carry these three in every project (MUST); their layout is the project's own
| File | Purpose |
| --- | --- |
diff --git a/tests/efficacy/arms/lazyskills/skills/base-quality/SKILL.md b/tests/efficacy/arms/lazyskills/skills/base-quality/SKILL.md
index eeb0bf2..475ca4f 100644
--- a/tests/efficacy/arms/lazyskills/skills/base-quality/SKILL.md
+++ b/tests/efficacy/arms/lazyskills/skills/base-quality/SKILL.md
@@ -247,6 +247,25 @@ match on "[0-9a-f]{16}.html" wrong directory -> nothing matched
source that looks wrong
- Never weaken the rule behind a check to make it green or quiet
+## Static checks
+
+- Adopt the language's static type checker at its strictest setting where
+ the language has one, and keep it clean (MUST)
+- Annotate every public function's parameters and return type where the
+ language allows it (MUST)
+- Adopt a linter and a formatter, and keep both clean (MUST)
+- Run the type checker, the linter and the formatter before every commit
+ and in CI
+
+```bash
+
+
+
+```
+
+Pass condition: all three print nothing. Each command is the project's own,
+in its quiet mode.
+
## Enforcement
- Enforce these conventions through the gates: editor, pre-commit, CI
diff --git a/tests/efficacy/arms/lazyskills/skills/base-review/SKILL.md b/tests/efficacy/arms/lazyskills/skills/base-review/SKILL.md
index 98fa7a1..a4316ba 100644
--- a/tests/efficacy/arms/lazyskills/skills/base-review/SKILL.md
+++ b/tests/efficacy/arms/lazyskills/skills/base-review/SKILL.md
@@ -21,9 +21,9 @@ How a change is reviewed, and how a finding is proven before it is reported.
[LOAD: review]
-Review in this order, most critical first. `templates/core/quality.md`, and
-any language quality template the project carries, is the standard for
-items 2 to 4.
+Review in this order, most critical first. The quality rules, and any
+language quality rules the project carries, are the standard for items 2
+to 4.
1. **Security**: anything exploitable, any credential or licence problem
2. **Correctness**: wrong results, unhandled failures, race conditions
diff --git a/tests/efficacy/arms/reference/CLAUDE.md b/tests/efficacy/arms/reference/CLAUDE.md
index f676e41..195f84d 100644
--- a/tests/efficacy/arms/reference/CLAUDE.md
+++ b/tests/efficacy/arms/reference/CLAUDE.md
@@ -1,5 +1,23 @@
# tariff
+`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 — 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
+in the EU, so the GDPR applies: a customer may ask for their data to be
+erased or for a copy of it. One administrator signs in to use the
+application; nobody else has an account.
+
+Boundaries and actors: two actors, the administrator working in a browser
+and another program; the pricing engine is a library the program imports
+without the web application present, and the web application is one
+caller of it. The store is a local file. Nothing reaches the network.
+The program's interfaces are the library's own API and the invoice
+exports.
+
Before starting work, read each template below and apply every rule it
holds that fits this project. They are vendored at `docs/solid-ai-templates/`,
at the revision the project adopted.
diff --git a/tests/efficacy/arms/reference/generation.json b/tests/efficacy/arms/reference/generation.json
index e68878d..ad557bb 100644
--- a/tests/efficacy/arms/reference/generation.json
+++ b/tests/efficacy/arms/reference/generation.json
@@ -2,11 +2,11 @@
"arm": "reference",
"kind": "fixed",
"output_model": null,
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-10-27T07:33:03",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T14:45:02",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -33,9 +33,10 @@
"templates/data/data-modeling.md",
"templates/data/data-governance.md"
],
+ "budget": null,
"output_leak": null,
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\reference\\CLAUDE.md",
- "output_lines": 19,
- "output_words": 56
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\reference\\CLAUDE.md",
+ "output_lines": 37,
+ "output_words": 220
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/short/CLAUDE.md b/tests/efficacy/arms/short/CLAUDE.md
index b17acb2..b0ffec9 100644
--- a/tests/efficacy/arms/short/CLAUDE.md
+++ b/tests/efficacy/arms/short/CLAUDE.md
@@ -1,40 +1,40 @@
# 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.
+
+Pricing/invoicing web app for Imbra Ltd, local only.
- 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
-```
+### 1.1 Overview
+Catalog, discounts, tax rules, customers, invoices. Python 3.12, Flask 3,
+Jinja, HTMX, SQLite; local only, no network egress. One admin signs in via
+browser; another program also imports the pricing engine as a library.
+### 1.2 Project structure
+See the structure map in `README.md`; the pricing-engine library stays
+free of Flask/Jinja/HTTP imports.
+### 1.3 Commands
+Before every commit, run a strict type check, a linter, a formatter
+check and the test suite; each must report a clean pass.
+
## 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.
+### 2.1 Git
+- Work on a branch; never commit to `main` directly.
+- Off-limits, propose with a rollback plan first: login/session code,
+ GDPR erasure/export code, DB migrations, `.env*` and secrets.
+### 2.2 Security and data
+- Parameterize every SQLite query; never interpolate input into SQL.
+- Hash the admin password (bcrypt/scrypt/Argon2); lock out repeated failures.
+- CSRF-protect every state-changing request; cookies: HttpOnly, Secure, SameSite=Lax.
+- Rely on Jinja's autoescaping; never bypass it with raw user data.
+- Never log a customer's name, email or address; use an opaque ID.
+- Erase/anonymize and export a customer's data on request, machine-readable.
+- Store money as integer minor units or Decimal; migrate schema with up/down steps.
+
## 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`.
+Review order: security, correctness, clarity, conventions; block only on
+a demonstrated defect or policy deviation.
+- Approver and work tracker: open, not yet named by the project.
+- Release: a tagged commit of `main`; there is no deployment step.
+
## 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.
+Read the diff before changing anything. At session end, read and
+execute, in order, the review rules' MUST and SHOULD checklists.
diff --git a/tests/efficacy/arms/short/generation.json b/tests/efficacy/arms/short/generation.json
index 7862623..8597f6c 100644
--- a/tests/efficacy/arms/short/generation.json
+++ b/tests/efficacy/arms/short/generation.json
@@ -2,11 +2,11 @@
"arm": "short",
"kind": "model",
"output_model": "inline",
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-10-31T13:22:29",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T22:48:14",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -33,9 +33,9 @@
"templates/data/data-modeling.md",
"templates/data/data-governance.md"
],
- "prompt_chars": 83803,
+ "prompt_chars": 84526,
"prompt_leak": null,
- "prompt_file": "C:/efficacy/gen-short\\arm-short-prompt.txt",
+ "prompt_file": "C:\\efficacy\\gen6c-short\\arm-short-prompt.txt",
"auth_probe": "ready",
"command": [
"C:\\Users\\bgeorgiev\\.local\\bin\\claude.EXE",
@@ -51,7 +51,7 @@
"--setting-sources",
"",
"--settings",
- "C:/efficacy/gen-short\\home\\settings.json",
+ "C:\\efficacy\\gen6c-short\\home\\settings.json",
"--strict-mcp-config",
"--disallowed-tools",
"WebSearch",
@@ -59,20 +59,20 @@
],
"model": "claude-sonnet-5",
"effort": "high",
- "elapsed_s": 200.3,
+ "elapsed_s": 363.9,
"exit_status": 0,
"result": {
- "duration_api_ms": 193738,
+ "duration_api_ms": 359431,
"stop_reason": "end_turn",
- "session_id": "d648277b-ed48-47a3-8e32-165e689f9c29",
- "total_cost_usd": 0.5512856,
+ "session_id": "520b02a2-8a41-4d23-ae76-f47f6efeb14b",
+ "total_cost_usd": 0.5654821999999999,
"usage": {
- "input_tokens": 14,
- "cache_creation_input_tokens": 60568,
- "cache_read_input_tokens": 495278,
- "output_tokens": 20993,
+ "input_tokens": 2,
+ "cache_creation_input_tokens": 38747,
+ "cache_read_input_tokens": 25101,
+ "output_tokens": 40547,
"output_tokens_details": {
- "thinking_tokens": 17757
+ "thinking_tokens": 39853
},
"server_tool_use": {
"web_search_requests": 0,
@@ -80,19 +80,19 @@
},
"service_tier": "standard",
"cache_creation": {
- "ephemeral_1h_input_tokens": 60568,
+ "ephemeral_1h_input_tokens": 38747,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
- "output_tokens": 1058,
- "cache_read_input_tokens": 84624,
- "cache_creation_input_tokens": 1044,
+ "output_tokens": 40547,
+ "cache_read_input_tokens": 25101,
+ "cache_creation_input_tokens": 38747,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
- "ephemeral_1h_input_tokens": 1044
+ "ephemeral_1h_input_tokens": 38747
},
"type": "message"
}
@@ -102,17 +102,17 @@
},
"modelUsage": {
"claude-sonnet-5": {
- "inputTokens": 14,
- "outputTokens": 20993,
- "cacheReadInputTokens": 495278,
- "cacheCreationInputTokens": 60568,
+ "inputTokens": 2,
+ "outputTokens": 40547,
+ "cacheReadInputTokens": 25101,
+ "cacheCreationInputTokens": 38747,
"webSearchRequests": 0,
- "costUSD": 0.5512856,
+ "costUSD": 0.5654821999999999,
"contextWindow": 1000000,
"maxOutputTokens": 64000,
- "thinkingTokens": 17757,
+ "thinkingTokens": 39853,
"cacheCreationEphemeral5mInputTokens": 0,
- "cacheCreationEphemeral1hInputTokens": 60568,
+ "cacheCreationEphemeral1hInputTokens": 38747,
"canonicalModel": "claude-sonnet-5",
"provider": "firstParty",
"costBasis": "list"
@@ -148,27 +148,29 @@
},
"safety_stops": 0,
"is_error": false,
- "num_turns": 7,
+ "num_turns": 1,
"subtype": "success",
"api_error_status": null,
- "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,
+ "result": "# tariff\n\nPricing/invoicing web app for Imbra Ltd, local only.\n- Model: inline\n\n## 1. Project\n### 1.1 Overview\nCatalog, discounts, tax rules, customers, invoices. Python 3.12, Flask 3,\nJinja, HTMX, SQLite; local only, no network egress. One admin signs in via\nbrowser; another program also imports the pricing engine as a library.\n### 1.2 Project structure\nSee the structure map in `README.md`; the pricing-engine library stays\nfree of Flask/Jinja/HTTP imports.\n### 1.3 Commands\nBefore every commit, run a strict type check, a linter, a formatter\ncheck and the test suite; each must report a clean pass.\n\n## 2. Code conventions\n### 2.1 Git\n- Work on a branch; never commit to `main` directly.\n- Off-limits, propose with a rollback plan first: login/session code,\n GDPR erasure/export code, DB migrations, `.env*` and secrets.\n### 2.2 Security and data\n- Parameterize every SQLite query; never interpolate input into SQL.\n- Hash the admin password (bcrypt/scrypt/Argon2); lock out repeated failures.\n- CSRF-protect every state-changing request; cookies: HttpOnly, Secure, SameSite=Lax.\n- Rely on Jinja's autoescaping; never bypass it with raw user data.\n- Never log a customer's name, email or address; use an opaque ID.\n- Erase/anonymize and export a customer's data on request, machine-readable.\n- Store money as integer minor units or Decimal; migrate schema with up/down steps.\n\n## 3. Review process\nReview order: security, correctness, clarity, conventions; block only on\na demonstrated defect or policy deviation.\n- Approver and work tracker: open, not yet named by the project.\n- Release: a tagged commit of `main`; there is no deployment step.\n\n## 4. Session protocol\nRead the diff before changing anything. At session end, read and\nexecute, in order, the review rules' MUST and SHOULD checklists.",
+ "ttft_ms": 356457,
"type": "result",
- "duration_ms": 197972,
- "uuid": "b711c13a-688b-4a75-a566-6125baae94ef",
- "ttft_stream_ms": 1871,
- "time_to_request_ms": 419,
- "first_content_frame_ms": 1871,
+ "duration_ms": 360065,
+ "uuid": "37a9ed76-45d9-43a6-bb2e-d81ccd4ff0a8",
+ "ttft_stream_ms": 2012,
+ "time_to_request_ms": 633,
+ "first_content_frame_ms": 2012,
"queued_turn_count": 0,
- "result_index": 0
+ "result_index": 0,
+ "credential_expires_at": "2026-12-11T13:29:52.387Z"
},
"budget": [
40,
88
],
"output_leak": null,
+ "named_tooling": [],
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\short\\CLAUDE.md",
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\short\\CLAUDE.md",
"output_lines": 40,
- "output_words": 352
+ "output_words": 283
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/skills/CLAUDE.md b/tests/efficacy/arms/skills/CLAUDE.md
index 70f5b2c..a1fc42c 100644
--- a/tests/efficacy/arms/skills/CLAUDE.md
+++ b/tests/efficacy/arms/skills/CLAUDE.md
@@ -8,7 +8,7 @@ A pricing and invoicing web application: a product catalog, discount rules, tax
## Commands
-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.
## Answers
@@ -212,6 +212,25 @@ match on "[0-9a-f]{16}.html" wrong directory -> nothing matched
source that looks wrong
- Never weaken the rule behind a check to make it green or quiet
+#### Static checks
+
+- Adopt the language's static type checker at its strictest setting where
+ the language has one, and keep it clean (MUST)
+- Annotate every public function's parameters and return type where the
+ language allows it (MUST)
+- Adopt a linter and a formatter, and keep both clean (MUST)
+- Run the type checker, the linter and the formatter before every commit
+ and in CI
+
+```bash
+
+
+
+```
+
+Pass condition: all three print nothing. Each command is the project's own,
+in its quiet mode.
+
#### Enforcement
- Enforce these conventions through the gates: editor, pre-commit, CI
@@ -990,7 +1009,7 @@ failures, and server-side request forgery.
Rules for identity verification (authn) and access control (authz).
Applies to any backend service that has protected resources.
-Extends `security/security.md`, "Authentication" (`security-authn`) and
+Extends the security rules "Authentication" (`security-authn`) and
"Session management" (`security-sessions`), with backend-specific depth.
#### General principles
diff --git a/tests/efficacy/arms/skills/generation.json b/tests/efficacy/arms/skills/generation.json
index 4e070d4..43c653f 100644
--- a/tests/efficacy/arms/skills/generation.json
+++ b/tests/efficacy/arms/skills/generation.json
@@ -2,11 +2,11 @@
"arm": "skills",
"kind": "emit",
"output_model": null,
- "ref": "9086e0ff",
+ "ref": "9abed019",
"source": {
"remote": "https://github.com/solid-ai-dev/solid-ai-templates.git",
- "ref": "9086e0ff",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004"
+ "ref": "9abed019",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd"
},
"roots": [
"backend-api",
@@ -16,8 +16,8 @@
"base-security",
"base-data-governance"
],
- "started_at": "2026-10-27T08:11:09",
- "commit": "9086e0ffc454fbff1d234601822257ce5e40a004",
+ "started_at": "2026-11-13T14:45:06",
+ "commit": "9abed01916b941d9ed2f8daa8ff8c3b28f0718fd",
"resolved_files": [
"templates/core/quality.md",
"templates/core/git.md",
@@ -39,6 +39,7 @@
"templates/security/security.md#CORS",
"templates/backend/auth.md#API keys (service-to-service)"
],
+ "budget": null,
"output_leak": null,
"skills": {
"add-check": 256,
@@ -48,14 +49,14 @@
"generate-context": 222,
"migrate-data": 79,
"regenerate": 520,
- "review": 146,
+ "review": 148,
"start-issue": 187,
"verify-finding": 272,
- "write-docs": 174,
+ "write-docs": 165,
"write-tests": 186
},
"outcome": "generated",
- "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark\\tests\\efficacy\\arms\\skills\\CLAUDE.md",
- "output_lines": 1351,
- "output_words": 9363
+ "output": "C:\\Work\\products\\solid-ai\\solid-ai-benchmark-regen\\tests\\efficacy\\arms\\skills\\CLAUDE.md",
+ "output_lines": 1370,
+ "output_words": 9448
}
\ No newline at end of file
diff --git a/tests/efficacy/arms/skills/skills/review/SKILL.md b/tests/efficacy/arms/skills/skills/review/SKILL.md
index 9aa8fa7..f0db124 100644
--- a/tests/efficacy/arms/skills/skills/review/SKILL.md
+++ b/tests/efficacy/arms/skills/skills/review/SKILL.md
@@ -7,9 +7,9 @@ description: Reviewing a pull request or a diff, or judging whether it is ready
## Priority order
-Review in this order, most critical first. `templates/core/quality.md`, and
-any language quality template the project carries, is the standard for
-items 2 to 4.
+Review in this order, most critical first. The quality rules, and any
+language quality rules the project carries, are the standard for items 2
+to 4.
1. **Security**: anything exploitable, any credential or licence problem
2. **Correctness**: wrong results, unhandled failures, race conditions
diff --git a/tests/efficacy/arms/skills/skills/write-docs/SKILL.md b/tests/efficacy/arms/skills/skills/write-docs/SKILL.md
index 802dd8a..1239c21 100644
--- a/tests/efficacy/arms/skills/skills/write-docs/SKILL.md
+++ b/tests/efficacy/arms/skills/skills/write-docs/SKILL.md
@@ -7,8 +7,7 @@ description: Writing or restructuring documentation, a decision record or a diag
## Standard documents
-- Carry these three in every project (MUST); their layout is the project's
- own, and `templates/core/agents.md` offers a default for the agent files
+- Carry these three in every project (MUST); their layout is the project's own
| File | Purpose |
| --- | --- |
diff --git a/tests/efficacy/generate_arm.py b/tests/efficacy/generate_arm.py
index 4bfef12..b8b8d27 100644
--- a/tests/efficacy/generate_arm.py
+++ b/tests/efficacy/generate_arm.py
@@ -144,6 +144,11 @@ def record_path(arm):
does not. Where the brief does not settle something, choose what the rules
already imply and move on; do not ask.
+The brief names no tools, and the project has chosen none. Where a rule asks
+for a type checker, a linter, a formatter, a test runner or a package
+manager, or a template shows a command as a placeholder, say what the check
+must do and name no tool and no command: that choice is the project's.
+
Output the finished `CLAUDE.md` and nothing else: no preamble, no
explanation, no code fence around the whole document.
@@ -237,6 +242,24 @@ def arm_clause(arm):
return "\n".join(lines) + "\n"
+# The tools a Python project most often chooses. Neither the brief nor the
+# templates name one, so a generated file that does invented it, and an arm
+# told a tool gets checks the other arms were never told to run. The list is
+# a guard against the common case, not a proof: a rarer tool is caught by
+# reading the generated file, which is committed and reviewed. It can afford
+# to be broad, since a false positive costs one more generation.
+TOOLING = re.compile(r"\b(mypy|pyright|ruff|flake8|pylint|black|isort|"
+ r"pytest|tox|nox|bandit|uv|pip|pipenv|poetry|hatch)\b",
+ re.IGNORECASE)
+
+
+def named_tooling(texts):
+ """The tool names the texts carry, lower-cased and sorted; empty where
+ they name none."""
+ return sorted({match.lower() for text in texts
+ for match in TOOLING.findall(text)})
+
+
def over_budget(document, budget):
"""Every way a file exceeds its (lines, width) budget, as sentences;
empty where it fits or has no budget."""
@@ -594,15 +617,31 @@ def self_test():
# 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]
+ named = named_tooling(told)
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")
+ # A model arm may still fill a template's command placeholder with a
+ # tool of its own choosing; such a file is refused.
+ if (named_tooling(["Run `mypy --strict .` and `uv run pytest`."])
+ != ["mypy", "pytest", "uv"]
+ or named_tooling(["Use Ruff for linting and Pyright for types."])
+ != ["pyright", "ruff"]
+ or named_tooling(["Run black --check . and isort --check ."])
+ != ["black", "isort"]
+ or named_tooling(["Type-check at the strictest setting; "
+ "lint and format clean."])
+ or "name no tool and no command" not in INSTRUCTION):
+ print("FAIL: a generated file naming a tool is not caught, a clean "
+ "one is, or the prompt does not forbid naming tools")
+ return 1
+ print("a generated file naming a tool is refused, and the prompt forbids "
+ "one")
+
files = ["templates/core/quality.md", "templates/backend/api.md"]
planted_brief = "`tariff` - a planted brief - Python 3.12 / Flask 3\n"
text = reference_text(files, planted_brief)
@@ -831,6 +870,14 @@ def main(argv):
"specification supplies: %r" % leak["hits"])
return write_record(options.root, record, started_at) or 1
+ tools = named_tooling(texts)
+ record["named_tooling"] = tools
+ if tools:
+ record["outcome"] = "refused: names tooling"
+ print("refused: the generated files name tools the brief does not: "
+ "%s" % ", ".join(tools))
+ return write_record(options.root, record, started_at) or 1
+
# A dry run of any arm stops here: it writes nothing under `arms/`,
# so it never replaces a committed file or its record.
if options.dry_run: