Skip to content

Add machine-checked constraints for production builds (0.8.0) - #15

Merged
abisola merged 9 commits into
mainfrom
constraint-engineering
Nov 24, 2026
Merged

abisola merged 9 commits into
mainfrom
constraint-engineering

Conversation

@abisola

@abisola abisola commented Nov 19, 2026 •

Copy link
Copy Markdown

What this does

Rules a production service must meet are now enforced by xstack, not left to instructions. Until now every rule was prose, and /xstack:productionise generated its own audit.sh in the same run as the code it checked.

  • Constraint layers – constraints/baseline.json has 13 rules for every country. profiles/barbados/constraints.json adds two and profiles/kestria/constraints.json adds ten. profiles/_template/constraints.json is the starting point for another country. A service opts in with .xstack/constraints.json and adds its own
  • Runner – scripts/xstack-check.mjs, no dependencies. Three stages (write, stop, ci), results of PASS, FAIL, WAIVED or NOT RUN, and --vendor to copy it into a service for CI
  • Hooks – hooks/guard-write.mjs refuses a write that breaks a constraint and asks a person before a protected path changes. hooks/stop-gate.mjs sends the agent back while a "must" constraint fails
  • A shell for two agents – the developer and cyber engineer can now run the checks and tests. hooks/guard-bash.mjs asks a person before a shell command changes a protected path
  • Waivers – relaxing a rule needs a reason, an approver and an expiry date. A later layer cannot redefine an earlier constraint
  • Wiring – /xstack:productionise writes the constraints file and builds PRODUCTION-READINESS.md from check output. /xstack:threat-model drafts a constraint per control

Start with constraints/README.md.

The medical-licence example

Retrofitted as the proof. It now meets all 18 of its constraints. What the checks found along the way, all fixed:

  • SEC-004 – the CPD upload sent a file by GET. It now posts, and has an upload button so it works without JavaScript
  • WFT-001 – 50 links went to pages that did not exist. The ten missing pages are built
  • SEC-008 – 100 inline style attributes that the page's own Content-Security-Policy blocked. They are now stylesheet classes, and the baseline forbids style attributes
  • The Playwright suites had never been run, and 11 of 28 tests failed: secondary-text contrast, invalid summary-list markup, three wrong test locators, and a test server that could not serve five browsers at once

Also fixes tests/security/headers.sh, which reported two correct headers as weak on macOS sed.

Version

Bumps the plugin to 0.8.0 and cuts the changelog. The marketplace entry had drifted to 0.1.1 and is now 0.8.0 too.

CI

.github/workflows/constraints.yml is the backstop for the hooks, which only see Write and Edit.

  • Runner and hooks – thirteen tests in scripts/xstack-check.test.mjs, and a check that vendored copies of the runner match the source
  • Example service – every constraint at the ci stage on the medical-licence example: gitleaks, npm audit, the lockfile, security headers, and Playwright across five browser profiles

constraints/ci/github-actions.yml is the same job for a service to copy.

Tested

  • Thirteen automated tests for the runner, the three hooks and the profile layers: each baseline rule, each Kestria rule, waivers, layering, the write guard, the shell guard, the Stop gate
  • Both hooks in live headless Claude Code sessions, with the plugin loaded from this branch: the write guard denied a page with an inline onclick, an edit to .xstack/constraints.json was held for approval and declined, and the Stop gate sent the agent back over a dead link until it fixed it
  • The agents' shell, in three more live sessions: the developer agent ran xstack-check and reported its result, refused on its own instructions to edit the constraints file with sed, and the shell guard held the same command when a plain session tried it
  • The example's Playwright suites: 245 of 245 pass across five browser profiles on macOS, with axe covering all 19 pages
  • 17 of 18 constraints pass locally at the ci stage. The eighteenth, gitleaks, runs in CI

Not tested, not done

  • The approval prompt for a protected path has not been seen in an interactive session. Headless runs decline it. The live sessions ran on one model, and none tried to get round the Stop gate
  • The privacy and accessibility page wording in the example needs a human read
  • The example's k6 load tests have never been run
  • Workflow actions are pinned by version tag, not commit hash
  • The shell guard reads a command as text, so a command can be written to slip past it. CI is the backstop
  • The Kestria layer has only been run against the GovKestria starter page and the Kestria prototypes. No production Kestria service exists yet to prove it on
  • No back-end constraints or scaffold yet

Note for the reviewer

This branch was cut from a local branch, so it also carries b24dab5 (Add the help skill, which shows the staircase).

🤖 Generated with Claude Code

abisola and others added 7 commits November 17, 2026 15:59
A starting point for anyone new to xstack. The skill shows the
staircase, an interactive page of the five steps from first
conversation to a live service, then asks where the team is and gives
the one thing to run next.

The staircase ships with the skill in skills/help/assets/. The README,
quick start, changelog and contributing checklist now point to it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Rules a production service must meet are now enforced by xstack
instead of left to instructions.

- constraints/baseline.json: 12 rules for every country. A Barbados
  layer adds two. A service opts in with .xstack/constraints.json
- scripts/xstack-check.mjs: a dependency-free runner with write, stop
  and ci stages, waivers with an expiry, and --vendor for CI
- hooks/: refuse a write that breaks a constraint, ask a person before
  a protected path changes, and block finishing while a "must" fails
- /xstack:productionise writes the constraints file and builds the
  readiness report from check output, with no generated audit.sh.
  /xstack:threat-model drafts a constraint per control

Retrofit the medical-licence example. The shipped checks failed two
things its generated audit had passed: a file upload sent by GET and
50 dead links. Both are fixed: the upload posts, and the ten missing
pages are built. Also fix tests/security/headers.sh on macOS sed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- .github/workflows/constraints.yml: test the runner and hooks, check
  vendored copies match the source, and run the ci stage on the
  medical-licence example
- constraints/ci/github-actions.yml: the same job for a service to copy
- scripts/xstack-check.test.mjs: ten tests covering each baseline rule,
  waivers, layering, the write guard and the Stop gate
- Commit the example's lockfile and record its first Playwright run:
  the accessibility suite and two end-to-end tests fail

The example job is expected to fail until those are fixed or waived.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The suites had never been run. In desktop Chromium 11 of 28 failed.

- Secondary text uses GovBB grey-70 (#595959). #777777 failed WCAG AA
  contrast on white and off-white
- The summary list on the check page is valid dl markup: no region
  role on the dl, and the Change link sits in a dd
- Two test locators were wrong: a substring match on "Back" also found
  "Give feedback", and a named-group locator for a details element
  never resolved

All 28 now pass in Chromium, and axe is clean on all 19 pages.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Running all five browser profiles at once dropped most connections:
the local server was single-threaded and IPv4 only. It is now threaded
and listens on IPv4 and IPv6.

The skip-link test uses Option+Tab in WebKit on macOS, where plain Tab
does not move focus to links.

140 of 140 tests pass across the five profiles, and 16 of 17
constraints pass locally at the ci stage. gitleaks runs in CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A Content-Security-Policy without 'unsafe-inline' in style-src makes
browsers ignore style attributes, so a page does not look the way it
was written. The baseline did not catch this.

- SEC-008 in the baseline forbids style attributes in web pages, at
  the write, stop and ci stages
- The medical-licence example had 100 of them across 19 pages. Each is
  now a utility class in the linked stylesheet, so the styles apply

140 of 140 tests pass across five browser profiles, axe is clean on
all 19 pages, and no page logs a policy violation.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Bump the plugin and marketplace versions to 0.8.0 and cut the
  changelog. The marketplace entry had drifted to 0.1.1
- Add the ten supporting pages to the accessibility spec, and a new
  end-to-end spec for correcting details, the CPD upload and the footer
  pages. 245 of 245 tests pass across five browser profiles
- Regenerate the example's evidence table from a ci-stage run and
  rewrite the readiness report's headline to match: 17 of 18
  constraints pass locally, and gitleaks passes in CI

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@abisola abisola changed the title Add machine-checked constraints for production builds Add machine-checked constraints for production builds (0.8.0) Nov 19, 2026
abisola and others added 2 commits November 19, 2026 22:41
They could write tests and checks but not run them, so their evidence
was a description of what would happen.

- Both agents get Bash, with instructions: run the constraints and the
  tests, report what actually happened, never use the shell to change
  a protected path, stay inside the project
- hooks/guard-bash.mjs asks a person before a shell command that looks
  like it changes a protected path. Running the checks is not held up.
  It reads the command as text, so it is a tripwire, not a wall
- The Stop gate and the shell guard share one root finder

Tested with 11 automated tests and three live sessions: the developer
agent ran the checks, refused on its own instructions to edit the
constraints file, and the guard held the same command when a plain
session tried it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Only Barbados had a profile layer, so a Kestria service got the
baseline alone and a new country had nothing to copy.

- profiles/kestria/constraints.json: ten rules from the GovKestria
  design system, the reserved codes, and Kestria's platforms and law.
  The fictional-country notice, GovKestria markup and tokens, +999
  numbers and kestria.test addresses, the language switcher, page
  weight, and no home-made sign-in or account fields
- profiles/_template/constraints.json: four example rules with notes
  on where to look for rules and how to test them
- A max-size check type, for the page-weight rule
- The GovKestria starter page used a style attribute, which the
  baseline refuses. It now uses a kg-help--spaced class
- Tests: every bundled layer loads, the Kestria layer passes the
  starter page, and each Kestria rule catches its mistake

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@abisola
abisola merged commit f267e4b into main Nov 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant