Skip to content

feat: implement project verification goals and proof runs (#187) - #331

Closed
Joncallim wants to merge 65 commits into
mainfrom
architecture/issue-187-goal-run-policy-final
Closed

feat: implement project verification goals and proof runs (#187)#331
Joncallim wants to merge 65 commits into
mainfrom
architecture/issue-187-goal-run-policy-final

Conversation

@Joncallim

@Joncallim Joncallim commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Status: superseded by Forge VNext

This pre-VNext monolithic delivery PR is intentionally closed without merge.

The verification-goal registry/import/revision foundation already landed through PRs #328#330. Remaining useful requirements from this branch have been moved to current, dependency-scoped issues:

The old branch remains historical evidence for reviewed test cases/edge conditions only. New implementation must start from current main; do not rebase/cherry-pick this 65-commit branch wholesale.

Reason: continuing it would create project-specific execution/scheduling truth beside ADR 0014 and carries substantial unrelated branch drift.

…(issue #187)

Implements the PR #331 architecture for issue #187 verification goals:

- Add migration 0035 with protected policy, run, event, evidence, and
  schedule tables plus shared-ledger dual execution subjects.
- Add TypeScript contracts for policy, run lifecycle, system limits,
  Git safety profile, and operation execution profiles.
- Add trusted executable registry, filesystem authority loader, repository
  profile computer, and root-anchored command launcher.
- Add manual run admission, synchronous runner, and POST/GET API route.
- Update privilege reconciliation, CI ACL inventory, and installer checks
  for the nine new protected tables and protected routines.
- Add schema-content tests and update existing schema/ingress tests.

This is a partial implementation. Remaining architecture slices:
- Redis-delivered worker queue claim/ACK instead of synchronous API run.
- TrustedProjectRootLease retention across the full runner lifecycle.
- History/aggregate evidence reader and reliability-v2 child ingest.
- Bounded scheduler with schedule bindings/heads/slots.
- Queue expiry/recovery, capacity enforcement, and policy settings API.
- Comprehensive adversarial/Git/root/lease tests and operator docs.

Validation: npm run test (2116 passed, 64 skipped), npm run lint,
npx tsc --noEmit, npm run build.
…eduler authority (issue #187 Slice C/E)

Migration 0036 adds the protected business routines the worker, dispatcher,
scheduler, and API depend on: capacity-checked idempotent admission, lease
claim/renew with a recovery fence, child-operation finalization with the
closed v2 outcome mapping, repository/environment snapshot recorders, queue
expiry, the Redis dispatch marker, the prefix-validating atomic terminalizer,
and schedule binding/slot authority keyed per (project, goal).

It also drops the unreleased 0035 terminalizer that accepted a
caller-supplied outcome without prefix validation, and the manual runner now
finalizes children and runs exclusively through the protected routines.

Fresh-install validation against PostgreSQL 16 (installer-equivalent chain
through 0036 plus the privilege reconciler) surfaced and fixed:

- 0035: missing temporary REFERENCES grants, a missing composite identity
  unique index, run events referencing later snapshot surfaces, and the
  shared-ledger expansion running under the wrong role;
- 0036: extract() call grammar, the operation_runs CHECK role boundary,
  reconcile FOUND capture, verifier-required mapping, admission/claim guards,
  and capacity-blocked schedule slot retention;
- the legacy normalizer/proof contamination counts for the 49-table
  latest position.

Privilege reconciliation now verifies the exact runtime-routine owner/ACL
boundary, and migrate-through-0036 joins the managed-migration proofs.
- claim routine accepts queued rows only; expired running rows belong to
  the recovery fence, never to a competing worker
- finalize child operation now carries the claim lease token so proof
  writes are fenced to the current lease holder
- idempotent manual replay resolves before capacity accounting so a
  retried identical request returns its run even at a capacity limit
- begin child appends the child_begun event
- terminalizer requires repository and environment evidence for passed
- reconcile script tracks the 9-arg finalize and 6-arg slot-claim
  signatures
- add the immutable launcher contract digest for run environment evidence
- re-verify the pinned executable identity (device, inode, content digest)
  immediately before launch; a replaced executable disables execution
  instead of launching the new file
- classify spawn-level failures (ENOENT, EACCES, STDIO_MAXBUFFER) as
  spawnError, never as exit 0; killed children classify as timedOut
- pin the launch promise as observed at creation so an abort during the
  handle-close window cannot trip process-level unhandled-rejection policy
- buildSafeLaunchEnvironment strips NODE_OPTIONS/NODE_PATH and all GIT_*
  path redirections even when passed through overrides
…sue #187)

- admission now calls forge_admit_verification_goal_run_v1, the single
  authoritative write path; the direct INSERT (for which the application
  login has no privilege) is removed
- the live policy head revision id and sequence travel as real routine
  parameters; the JSON resolved policy serializes the sequence as text so
  a bigint never crosses the JSON boundary
- code-owned eligibility is enforced at admission: an operation outside
  the reviewed allowlist/profile throws before any run row is created
- the route resolves the live policy head (or seeds the default) and
  maps the closed SQLSTATE set: P1871/P1872/P1873/P1876 to 409 and
  P1874 to 429
- trusted executable resolution anchors to the project root as well as
  the worker cwd
…h (issue #187)

- keep the business lease renewed on the reviewed 10-second cadence; any
  renewal failure or non-owner response disables further proof writes and
  a lost lease is never re-claimed by the runner
- execute the exact bound operations in canonical ordinal order via the
  reviewed eligibility binding; verifier/classifier/profile drift against
  the stored digests terminalizes as operation_contract_changed
- record the repository and environment evidence snapshots before a
  passed terminalization, including the launcher contract digest, trusted
  executable identities, and the git safety profile digest
- finalize child operations with the claim lease token
- compute the repository profile through the retained project-root
  descriptor (/dev/fd) with the safe launch environment and deterministic
  metadata fingerprint; expose headOid on the profile
- map launcher failures to specific terminal codes instead of a generic
  internal error
- launcher: exit classification, spawnError for ENOENT/STDIO_MAXBUFFER
  (never exit 0), killed-as-timeout, executable change, root dev/ino
  mismatch, abort, and safe-environment stripping under overrides
- runner: happy path with evidence snapshots and lease-fenced finalize,
  legacy policy key, spawnError, digest drift, lease loss, launcher
  error, and dirty repository
- admission: protected routine call shape, real bigint params, idempotent
  replay, and allowlist/capability enforcement before any DB call
- migration: text assertions on the hardened routine signatures, claim
  guard, lease-token fencing, passed-evidence guard, and child_begun
  event, mirrored in the reconcile script
- route: POST/GET happy paths, 401/503/400/404/409 guards, SQLSTATE
  mapping to 409/429, and generic 500 without secret leakage

Copy link
Copy Markdown
Owner Author

Superseded by VNext — implementation branch retired

This PR is now intentionally superseded and should not be rebased, merged, or cherry-picked wholesale.

The repository-wide VNext readiness pass confirmed:

The reviewed requirements have been preserved in the canonical current plan:

Useful test/design ideas from this PR (bounded command/resource policy, restart/idempotency cases, output/redaction limits, schedule dedupe cases and run-history semantics) remain historical evidence and may be reimplemented where they fit the current contracts. The branch structure/table/module choices are not authoritative.

No code from this PR should be treated as the implementation base for new work. New implementation branches start from current main after their declared dependencies close.

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