Skip to content

Pass the operator's reviewed policy to inspection commands and the authoring MCP server (#834) - #849

Merged
jimhoyd merged 5 commits into
mainfrom
claude/validation-context-834
Sep 28, 2026
Merged

jimhoyd merged 5 commits into
mainfrom
claude/validation-context-834

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

The #843 proof (#848, which this PR is stacked on) found the gap #834 describes. A site whose routes need operator-granted bindings could not be validated or tested from the authoring MCP server, and the inspection commands needed PROJECT_SHA256 exported by hand. bootstrap did name --policy and --origin under prerequisites, but nothing could accept a policy, so its commands never became complete.

This PR lets the operator's reviewed policy reach those tools:

  • --policy on bootstrap, context, explain, review, plan-feature and mcp. A verified policy pins the host file to its projectSha256, so no PROJECT_SHA256 export is needed. bootstrap and context repeat it in every emitted command and drop it from prerequisites. bootstrap names a policy inside the site relative to the site root, since its commands run from there.
  • MCP. The server reads and verifies the policy once at startup. run_validate, run_test and run_audit forward the same file (as an absolute path), next to the --host-file and --origin they already forwarded, and in-process run_tests uses its grants.
    • This reverses a documented choice ("urlcode mcp accepts no --policy"). The file is chosen only by the operator on the server's command line. No tool argument can name, create or change it, and editing the project still invalidates it until the operator reviews and replaces the file. Please veto this if you want MCP to stay grant-free.
  • Named policy-file errors ([Bug]: an empty, unparseable or missing --policy file answers "Operation failed" without naming it #847). An empty, unparseable or missing file now says which file and what's wrong, instead of "Operation failed".
  • Bootstrap serving hint. The site's data/ directory (operator databases and keys; init's .gitignore already excludes it) is no longer offered for serving. The hint for other directories now says operator code, credentials and data stay outside the project.

extensions is now the only host-loading command without --policy; the #723 test moved to it.

Verification

  • New test/validation-context.test.ts covers:
    • bootstrap commands carry --policy and run as printed; data/ is excluded.
    • context and explain load a host that refuses without a reviewed revision.
    • The MCP server refuses without the policy; with it, run_validate passes, run_tests passes 1/1 and get_context commands carry the policy.
    • Policy-file errors name the file.
  • test:proof gains the connected MCP workflow: urlcode mcp --allow-authoring --host-file host.mjs --origin … --policy … on the packed Better Auth site, where run_validate exits 0 and run_test passes all 34 cases. Now 12/12.
  • By hand on the packed proof site with PROJECT_SHA256 unset, over MCP: run_validate 0, run_test 34/34, run_audit 0, and get_context {bootstrap: true} returns complete commands with no prerequisites. On the CLI, context, explain, review and plan-feature all succeed.
  • npm run verify steps all pass: core npm test 1,097 tests, workspace suites, audit:packages, test:addons, test:proof, check:code, check:docs. npm run test:package passes.
  • The core package's unpacked budget is raised from 3445 to 3460 KiB, with the measurement recorded (887,241 packed / 3,532,433 unpacked bytes, 499 entries). Prove embedded Better Auth in one local URLCode site (#843) #848 was already within 700 bytes of the old budget.
  • Not run on Windows here. The Windows teardown fix for test:proof is on Prove embedded Better Auth in one local URLCode site (#843) #848.

Compatibility and security

  • CLI flags are additive. The MCP tool descriptions and docs/TOOLING.md now describe the forwarded policy. No YAML or schema change.

  • Grants still come only from an operator file outside the project, pinned to the reviewed revision. Nothing computes, writes or repins a policy. Runner children still get only PATH (plus PROJECT_SHA256 in the old host-without-policy case).

  • Changes match the documented portable contract; docs/examples are updated where needed.

  • Relevant tests and package checks pass, or limitations are explained above.

  • No credentials, customer data or private project material are included.

  • Runtime/starter changes remain aligned where applicable. (Starter assets regenerated; no change.)

🤖 Generated with Claude Code

jimhoyd and others added 4 commits September 28, 2026 08:57
Adds proofs/private-requests: a packed-consumer site where Better Auth
1.7.6 on node:sqlite owns accounts, sessions and its tables, an operator
adapter mounts its native handler and turns its verified session into
the request principal and #840's request-bound `identity` capability,
and ordinary function routes implement owner-private requests and one
reviewer-only approval with parameterized SQL.

The adapter refuses before serving on a missing secret, an uninitialized
schema, an origin or basePath mismatch, telemetry left on, or a disabled
rate limiter; forwards only an exact allowlist of Better Auth paths
(disabledPaths misses parametric routes); and supplies the admitted client
address for throttling in a header it always overwrites.

test/private-requests.integration.ts (npm run test:proof) packs this
checkout, installs it into a copy of the site, and exercises setup,
explicit policy approval, provider/target refusals, declarative fixtures
with audit ready, and the HTTP flow including foreign-owner and reviewer
denial, malformed input, concurrent approval, cancellation, sign-out,
revocation and throttling.

Core: explain/report state that an extension mount's subpaths are
provider-defined and not inspected, and list the capabilities a
registration declares on the routes it protects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion

verify:workspaces and the workspace-integration job now run
npm run test:proof after test:addons. The proof packs the already-built
core with --ignore-scripts, like the other packaging tests, so prepare
never rebuilds dist under another test. Changes under proofs/ or to the
proof's test are high-impact, so they select that job on a pull request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t a shell

On Windows the proof's behavior passed but teardown did not: separate
t.after hooks run in registration order, so the temp site was removed
while the served runtime still held its SQLite files (EBUSY), the
server-stop hook never ran, and the live child kept the test process
alive until the job timeout. One unwind stack now attempts every
closer, newest first. npm runs through npm_execpath under this Node, so
Windows needs no shell (DEP0190).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thoring (#834)

bootstrap, context, explain, review, plan-feature and mcp accept the
operator's --policy. A verified policy pins the host file to its reviewed
projectSha256, so no PROJECT_SHA256 export is needed; bootstrap and
context repeat it in their emitted commands and drop it from
prerequisites. The MCP server verifies it once at startup and its
run_validate/run_test/run_audit runners forward the same file, and
run_tests uses its grants. No tool argument can name, create or change
a policy; an edited project still invalidates it until the operator
reviews and replaces the file.

An empty, unparseable or missing policy file is now named (#847).
bootstrap no longer offers the site's data/ directory for serving, and its
serving hint says operator code, credentials and data stay outside the
project.

The #843 proof now runs its connected MCP workflow: run_validate and
run_test pass on the packed site with only the operator's flags.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…text-834

# Conflicts:
#	proofs/private-requests/README.md
#	test/private-requests.integration.ts
@jimhoyd
jimhoyd merged commit b0349f2 into main Sep 28, 2026
30 checks passed
@jimhoyd
jimhoyd deleted the claude/validation-context-834 branch September 28, 2026 16:10
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