Skip to content

M1 hardening: complete sequence B1-B10 + protected-kernel completeness remediation - #418

Open
kaydot20 wants to merge 21 commits into
Conway-Research:mainfrom
kaydot20:m1-b6-kernel-manifest
Open

kaydot20 wants to merge 21 commits into
Conway-Research:mainfrom
kaydot20:m1-b6-kernel-manifest

Conversation

@kaydot20

@kaydot20 kaydot20 commented Oct 2, 2026 •

Copy link
Copy Markdown

M1 hardening — complete sequence (B1–B10 + final remediations)

Final validated SHA: 37ca3c5685d10dfc93d270d5246d10134f6a92e0
Branch: m1-b6-kernel-manifest

Update — a final B1 completeness audit corrected one acceptance condition.
The previously validated head 64555bd is no longer final; it has been
superseded by 37ca3c5. A contract audit against the preflight found that
preflight §F1.1 requires "Consensus mode stays a stub but must default to
deny, not approve"
, names required test "(d) consensus mode denies by
default"
, and lists the consensus auto-approve stub under §A Disabled as
"(deny-by-default)" — all of which bind to §B row 1 (F1.1/F1.2).
reviewPlan's consensus branch returned approved: true; a test asserted that
fail-open behaviour, so the suite stayed green. 37ca3c5 makes the stub deny
with a new deterministic CONSENSUS_MODE_UNAVAILABLE reason code, preserves the
critic-role/timeout diagnostics, and adds a cross-mode regression pinning that
auto is unchanged. Two files, no protected-kernel or manifest change.

The earlier evidence below was measured at 64555bd and is retained because it
is still accurate; only the consensus counts moved (2228 → 2232 tests).
64555bd remains the head at which the protected-kernel manifest work was
validated at 24 files.


Relationship to #417

#417 was the earlier source-hardening submission (B1–B4.1), head ecae43a.

This PR supersedes #417 as the canonical submission for the completed M1 sequence.

To be explicit and avoid overclaiming: #417 does not contain the final M1 code. Its head is ecae43a, which predates B6–B10 and both post-acceptance remediations. The B1–B4.1 commits it carries are contained here — ecae43a is a direct ancestor of this branch, so this PR is a strict superset with no divergence and no history rewrite.

#417 is left untouched (still draft/stale) and is not force-updated by this PR.


Milestone summary

Milestone Scope Commit
B1 Deterministic budget enforcement ecae43a (in #417)
B1 (remediation) Consensus stub corrected to deny-by-default per §F1.1 37ca3c5
B2 Minimum reserve enforcement ecae43a (in #417)
B3 Universal result sanitization ecae43a (in #417)
B4 / B4.1 SSRF / DNS / CLI relay protection ecae43a (in #417)
B5 Fail-closed CI / audit / source-hygiene ecae43a (in #417)
B6 Protected-kernel manifest + boot integrity 5689556
B7 Promotion pipeline fe1948d, 6cb3717, 39e7836
B8 Capability registration b62261e
B9 Sovereignty wording — explicit human constitution approval obtained before edit 89c457e
B10 Scoped workers — TTL / resource / revocation enforcement 1f77381, 8433ddb
— Final protected-kernel completeness remediation 64555bd

B9 note for reviewers: the sovereignty-wording change touched constitutional language. Owner sign-off was obtained before the edit, not after. Please review that commit against the constitution text specifically.

B7 note: three commits, not one. 39e7836 is a remediation that registers the model-facing promotion tools in the tool registry after the initial pipeline phase was found incomplete.

B10 note: 8433ddb is a remediation enforcing worker TTL as a lifetime boundary after the initial scoped-worker commit was found insufficient.

Final remediation (64555bd): src/agent/policy-rules/kernel.ts was absent from the protected-kernel manifest even though preflight §10 protects the src/agent/policy-rules/** class in its entirety. That file is the degraded-mode enforcement rule — it defines KERNEL_DEGRADED_TOOLS and implements the kernel.integrity_gate denial. All seven sibling policy rules were hash-pinned; this one was not.

The gate was therefore blind to tampering with its own enforcement rule: rewriting KERNEL_DEGRADED_TOOLS to an empty list left check-kernel-manifest reporting OK and left boot verification healthy, so §10's degraded monitoring mode could be disabled with no integrity failure. Only the test suite noticed — and tests are not the tamper-evidence control §10 requires.

The file is now declared in all four authoritative lists (runtime KERNEL_FILES, checker, generator, committed manifest) and the manifest was regenerated deliberately. Runtime verification is unchanged and remains read-only: the manifest is never written at runtime, and the generator is reachable only by maintainer invocation. A new suite pins the property rather than the single entry — every file under a §10-protected directory must be manifested, the four lists must stay in exact lockstep, and removing degraded-mode enforcement must always imply an integrity failure.


Final CI evidence

Fork run 36957259366, workflow CI, push event, at exact SHA 37ca3c5 — the current head. Overall success, 5/5 jobs green.

The preceding run 36954982956 at 64555bd was likewise 5/5 green.

Check Result
build-and-test (Node 20) ✅ typecheck PASS · 79 files / 2232 tests passed
build-and-test (Node 22) ✅ typecheck PASS · 79 files / 2232 tests passed
security tests (both nodes, required) ✅ 22 files / 878 tests passed
security-audit ✅ AUDIT GATE OK: 29 advisories seen; high/critical all within the reviewed exception list (27 entries)
source-hygiene ✅ no unsanctioned raw fetch()/execSync()
kernel-manifest ✅ kernel manifest OK: 24 protected files verified
root tsc --noEmit ✅ 0 diagnostics
CLI tsc --noEmit ✅ 0 diagnostics
git diff --check ✅ clean

All gates ran fail-closed (bail: 1, no timeout bypasses, no \|\| true). Counts match the container-side validation at the same SHA, so Linux CI confirms rather than diverges from local results.

Non-failure noise, recorded for reviewers: the build jobs emit one level: "error" line from orchestration.messaging ("handler broke"). This is a deliberate negative-path fixture in messaging.test.ts exercising handler error containment, not a failure. Two platform annotations also appear (actions forced onto Node 24 due to runner Node 20 deprecation; ubuntu-latest → Ubuntu 26 migration on 2026-10-19) — upstream platform notices, not repo defects.


Known non-blocking notes

  • Upstream workflow may require maintainer approval. Fork GitHub Actions runs on the fork do not automatically imply the same checks will run on the upstream PR. First-time-contributor or fork-PR workflow approval may be required before checks execute. If the checks are pending or blocked, that is a permissions gate, not a code failure.
  • No merge is requested. This PR is submitted for review only.
  • M1 source-level hardening: budget gate, treasury reserve, sanitization, outbound policy, fail-closed CI (B1–B4.1) #417 remains draft and stale unless maintainers choose to close it. It is not modified or force-updated here. Recommend closing it as superseded once this PR is reviewed, but that is a maintainer decision.

Reviewer entry points

  • Protected-kernel integrity: src/governance/kernel.ts, scripts/check-kernel-manifest.mjs, scripts/generate-kernel-manifest.mjs, kernel-manifest.json
  • Degraded-mode enforcement: src/agent/policy-rules/kernel.ts
  • Fail-closed CI: .github/workflows/ci.yml, scripts/audit-gate.mjs, scripts/check-source-hygiene.mjs
  • Scoped workers / TTL: src/orchestration/ and the B10 test suites
  • Tamper-regression evidence: src/__tests__/governance/kernel-manifest-completeness.test.ts

Full M1 traceability matrix (every preflight §B row → commit → enforcement files → passing CI evidence) available on request.

kaydot20 and others added 21 commits September 30, 2026 09:20
reviewPlan() auto mode previously approved every plan, including those
above autoBudgetThreshold (both branches returned approved: true), and a
rejection looped planning -> review -> planning unboundedly.

- Auto mode now fails closed: the authoritative cost is the computed sum
  of deterministic task-level estimatedCostCents; declared-total
  mismatches (PLAN_COST_MISMATCH), malformed/negative/non-finite costs
  (PLAN_COST_INVALID), and computed totals above the ceiling
  (PLAN_BUDGET_EXCEEDED) are all denied with machine-readable reasons.
- Orchestrator allows exactly one bounded cheaper-plan attempt after a
  budget denial; a second denial pauses the goal (existing non-looping
  "paused" status), blocks its pending tasks, and records an escalation
  for the owner. Approval clears the rejection counter so past
  rejections cannot poison future work. Raising the ceiling remains an
  owner/governance action.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…pend paths

minimumReserveCents was declared but never enforced. Add one shared guard
(src/conway/reserve.ts) applied at every sink that moves funds:
transfer_credits, fund_child, the x402 pre-signing path, the orchestrator
SimpleFundingProtocol.fundChild helper (previously completely unchecked),
and the credit-topup helper (tier validation, solvency, cross-recipient
reserve). Self-topup (USDC->credits income) is reserve-exempt to avoid a
starvation lock; malformed/missing/NaN/infinite inputs deny fail-closed;
the exact-reserve boundary is inclusive and deterministic.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…tion

F3.1: tool results were sanitized only for a three-tool allowlist, leaving
x402 bodies/errors, agent cards, git output, skill echoes and MCP results
as raw prompt-injection channels. Invert the default: executeTool now
sanitizes every result through sanitizeToolResult; only a small
TRUSTED_LOCAL_TOOLS allowlist of locally synthesized outputs opts out.
Error channels (unknown tool, policy denial, thrown tool errors) are
sanitized too.

F3.2: worker task_result envelopes were trusted: missing success defaulted
to true, output/error were persisted raw, and any taskId was accepted.
Missing/undeclared success is now a failure (fail-closed), content passes
the same taint boundary, and collectResults drops results for tasks not in
this orchestrator's task graph.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Every outbound HTTP request now passes src/net/policy.ts: scheme is
https-only (loopback http behind an explicit dev flag), literal private/
reserved/metadata addresses and malformed hostnames are denied, and
purpose allowlists gate payment traffic. ResilientHttpClient follows
redirects manually (max 3) and re-validates every hop, so a redirect can
no longer bypass validation to reach private addresses. DNS-resolution
validation is resolver-anchored (clients may inject one; requireDnsResolution
fail-closes when absent).

x402Fetch applies the SSRF gate pre-signature; fetchAgentCard rides the
policy-checked client and validates IPFS CIDs before gateway splicing;
CLI send/fund relay fetches are guarded. The web_fetch -> x402_fetch
harness alias is removed: silently redirecting web fetches to the payment
tool was a surprise-spend vector. Payment-domain allowlists are not wired
into the default tool path (would deny ordinary paid fetches under the
shipped policy defaults); SSRF statics run unconditionally.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Remediation of the M1-B4 acceptance gap: production payment requests must
resolve the hostname and validate every returned A/AAAA address against
the private/special-use blocklist before the first fetch and before any
signature. Resolution now runs whenever it is required or a resolver is
injected, defaults to system DNS (node:dns), and fails closed on resolver
failure, empty answers, or malformed output. The x402 transport requires
DNS on every hop (precheck, probe, paid retry, and each redirect
destination); tests inject fake resolvers instead of weakening
enforcement. All topup entry points (tool, heartbeat, inline loop,
startup, spawn-402) thread the optional config.dnsResolver through, so
the B2 self-topup rescue works unchanged with a public resolution.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
F7.1: remove the `timeout ... exit 0` bypasses that turned vitest hangs
into green CI. The hang is fixed properly in vitest.config.ts (forks
pool with singleFork, bail-on-first-failure in ci mode); a step timeout
now fails the job. The security suite is its own required gate running
the explicit hardening-acceptance file list.

F7.2: the dependency audit is fail-closed. pnpm audit's exit code is
unusable for gating (it exits 0 whenever ignore entries apply), so
scripts/audit-gate.mjs parses `pnpm audit --json` and fails on any
high/critical advisory outside an explicit reviewed exception list
(dev/toolchain paths only), and fails closed on unusable audit output.
A scheduled daily audit re-runs against fresh advisory data.

F7.3: add scripts/check-source-hygiene.mjs — a fail-closed gate banning
raw fetch()/execSync() outside the sanctioned network client, the
loopback Ollama discovery, the two policy-guarded CLI commands, and the
audited Conway exec fallback.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Closes the F4.2 gap left by B4: packages/cli send/fund issued raw
relay fetch() calls with no SSRF enforcement. Both commands now
pre-validate the target through assertOutboundAllowed (purpose
"relay", mandatory DNS tier) before any signing or payload
construction, and transmit via a single guarded transport
(packages/cli/src/lib/relay-fetch.ts) that re-validates every
redirect hop, strips Authorization on cross-origin redirects, and
converts 303 to GET without a body.

The source-hygiene allowlist shrinks accordingly: the send.ts and
fund.ts exceptions are removed and relay-fetch.ts is the only raw
fetch() call site in the CLI. Regression suite
(packages/cli/src/__tests__/relay-policy.test.ts, 29 tests) proves
public-HTTPS allow, literal-private deny, DNS private/mixed/failure
deny, malformed-host bypass deny, redirect-to-private deny before
the redirected fetch, and zero side effects on denial.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…diation)

Root cause of the fail-closed CI hang (both matrix jobs, 2/2
deterministic): estimateTokens handed arbitrarily large strings to
the real js-tiktoken cl100k_base encoder, whose pure-JS BPE cost is
superlinear on degenerate inputs — a single 100 KB same-character
run measures ~26 s at 10 KB and extrapolates to hours, blocking the
event loop. buildContextMessages legitimately builds 100-500 KB
turns (budget enforcement is its purpose), so the first oversized
estimate froze the vitest worker before any test executed; the
parent then never exited and CI killed the step at 15:00. The same
path would freeze the live agent loop on a huge tool result.

Remediation: text above BPE_TOKENIZE_MAX_CHARS (8,000 chars) takes
the conservative ceil(len/4) heuristic instead of the encoder —
bounded, deterministic, and within the estimator's documented
tolerance. Normal-size text still uses the real tokenizer.

Also fixes a latent test bug found during bisect: require("crypto")
in an ESM package replaced with a node:crypto import.

Regression tests pinned to the exact CI-hang shape (20 x 100 KB
turns, 100 KB degenerate string): the suite that previously hung
indefinitely now completes in ~12 s (32/32).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…tion)

Second defect the fail-closed full-suite run exposed after the
tokenizer fix unblocked the scheduler suite: buildTickContext awaited
the on-chain USDC balance read (real viem/Solana RPC, no timeout)
and the credits balance without any bound, so a slow endpoint froze
the tick — deterministic locally but timing-dependent on CI runners,
where 'prevents concurrent tick execution' timed out at 30 s and
bail=1 skipped the remaining 37 files.

Both fetches are now hard-bounded (5 s): on timeout the balance
degrades to 0 — the same conservative fallback the existing error
path uses — and the next tick retries. A stalled RPC can no longer
freeze the production heartbeat either.

Two deterministic regressions prove the tick completes when each
fetch never resolves (22/22 in the scheduler suite, ~16 s).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…iation 3/3)

Root cause of the recurring CI scheduler-suite timeout: one
inference-client retry test created vi.spyOn(globalThis, "setTimeout")
while fake timers were active and never restored the spy. That spy
pins the fake timer implementation on the worker's globals in a way
that survives useRealTimers(), mockRestore(), afterAll re-sync, and
unstubGlobals — freezing real setTimeout in every suite that runs
after it in the shared single-fork worker. This also silently
disabled the new 5 s balance-fetch bound (setTimeout-based),
resurfacing the RPC stall inside the overlap-prevention test.

Proven by minimal reproduction (fake timers + global setTimeout spy
= leak; bare fake timers = no leak) and a real-timer canary.

Remediation: capture backoff delays via a plain delegating wrapper
with try/finally restore instead of a global spy under fake timers.
Defensive useRealTimers() hygiene added to the scheduler suite, plus
a fail-fast real-timer canary guard that names the actual cause if
this pattern ever regresses.

Interaction pair (leaker -> victim) now passes 46/46 in ~13 s
(previously deterministic 30 s timeout).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…emediation 4/4)

The planner-backed delegation test isolated the agent workspace by swapping
process.env.HOME, but AgentWorkspace resolves its basePath via os.homedir().
The swap never worked on Windows (homedir uses USERPROFILE) and is
permanently neutralized in full-suite runs once an earlier suite replaces
the process.env object (provider-registry, inference-client,
inference-failover), so plan artifacts persisted under the real home and
the tempHome assertions failed even though delegation behaved correctly.
Stub os.homedir directly (the workspace.test.ts pattern) and restore all
mocks in afterEach. No assertions changed; product code untouched.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Implements preflight §10 / PR 6: the security-critical kernel file set is
now covered by a committed, deterministic sha256 manifest verified at boot
and in CI, outside every model-reachable path.

- kernel-manifest.json: 22 kernel files (constitution, policy engine and
  rules, injection defense, net policy, HTTP client, spend tracker, x402,
  credits, wallet/chain, provider registry emergency-stop logic, self-mod
  substrate), hashed over LF-normalized content (checkout-stable).
- src/governance/kernel.ts: generate/load/verify primitives. Boot verdicts:
  unusable manifest => refuse autonomous execution; modified/missing/extra
  kernel file => degraded monitoring mode + kv escalation record. Runtime
  verification is strictly read-only; nothing regenerates the manifest.
- kernel.integrity_gate policy rule (priority 50, unique minimum): denies
  all financial/spawn/self-mod tools while degraded, regardless of input
  source; restored only by a verified kernel and a restart.
- src/index.ts: integrity gate runs before config/network/db/agent-loop
  setup; escalation persisted to kv before any policy engine exists.
- scripts/check-kernel-manifest.mjs: dependency-free CI verifier (runs
  pre-install, fail-closed on stale/tampered manifests, unexpected
  governance files, or any integrity mismatch) + offline regeneration tool.
- CI: new kernel-manifest job; suite added to test:security:ci.

No B1-B5 controls weakened; all prior gates intact and green.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Implements preflight §6 / PR 7: source paths leave the model-reachable
write surface and move behind an explicit, fail-closed promotion state
machine persisted in kv.

- src/governance/promotion.ts: propose → approve (creator-only single-use
  token, sha256-hashed, 1h validity) → promote transitions with strict
  state sanitization (malformed state fails closed), attempt budget (3),
  and verify-first semantics: any denial leaves state and filesystem
  untouched except the audited failure record. No runtime manifest writes;
  worktree build/canary runner is phase-2 tooling behind this exact gate.
- path.source_tree policy rule: edit_own_file/write_file/exec can no
  longer target src/**, packages/**, scripts/** (token-scan catches
  heredoc/redirection/quoted forms) — the F6.2 exec bypass closes at the
  policy choke point; propose_self_update/get_promotion_status/
  rollback_last_promotion become the sanctioned surface (F6.3).
- Kernel set grows by src/governance/promotion.ts (preflight §10 names the
  promotion module protected); kernel-manifest.json regenerated with the
  maintainer-only generator (22 → 23 files), checker/generator lists kept
  in lockstep.
- path-protection.test.ts count assertion updated 3 → 4 rules with
  contract evidence; B7 suite (29 tests) covers valid/missing/malformed/
  stale/unauthorized/replay/bypass/restart/no-side-effect/kernel cases.

No prior accepted behavior modified; all B1–B6 suites re-verified green.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…mediation)

Traceability review against preflight §6 + §B row 7 (line 268: proposal/
worktree/build/test/governance-regression) proved the B7 contract requires
the stage mechanics themselves, not only the authorization substrate.

- promoteApprovedUpdate now executes the four named stages in an isolated
  git worktree (git worktree add, injectable command runner): prepare →
  apply patch (git apply --check then apply, worktree-only) → build (tsc
  via pnpm run typecheck) → unit tests (pnpm run test:ci:bail) →
  governance regression (source-hygiene grep + kernel-manifest hash
  verification + constitution + policy-rules presence). Stage log persists
  in promotion.state.pipeline; any failure fails closed to `failed` with
  the live tree untouched.
- Proposal authoring rejects protected-kernel targets at proposal time
  (§6 line 166), checking both the declared file list and diff headers.
- kernel-manifest.json regenerated (promotion.ts changed); regeneration
  remains maintainer-only and offline.
- Tests extended to 37: green pipeline, build-failure short-circuit,
  governance-failure, proposal-time kernel rejection (list + smuggled
  patch), stage-name contract; all stage commands injected — no test
  touches the real repo.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…egistry (B7 tool-surface remediation)

Preflight §6:165 requires the model's only route to source modification to
be the three promotion tools. They were declared as the PROMOTION_TOOLS
constant but never registered in createBuiltinTools — the model could not
actually call them. Register propose_self_update / get_promotion_status /
rollback_last_promotion in the builtin registry, backed by a new sanctioned
rollbackPromotion kv-state transition; deny propose/rollback from external
input sources and while the kernel integrity gate is degraded; keep the
admin promote tool unregistered (no model self-approval route). Manifest
regenerated for the kernel-file edits; security gate extended to cover the
new tool-surface tests.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…idation (M1-B8)

The model-facing install_mcp_server inlined `npm install -g <pkg>` and wrote
a raw, unvalidated row into installed_tools; loadInstalledTools then handed
every enabled row to the model with a hardcoded riskLevel and an executor
that ran config.command. A single injected instruction could therefore author
a reboot-surviving capability.

Preflight §10 makes capability registration governance-approval work that is
never model-grantable to itself, so the install execution paths are disabled
rather than tightened: both tools stay registered (visible, classified,
policy-gated) but perform no install and write no row. Owner-side tooling now
registers capabilities through an append-only registry that validates the
CommandSpec (fixed command allowlist, absolute path, no shell metacharacters,
arg array never a string, required JSON-Schema, declared permissions and
riskLevel, explicit env allowlist with secret rejection), records provenance,
and re-verifies spec + hash + expiry on every load. Anything unverifiable —
raw rows, tampered commands, stripped provenance, expired grants — fails
closed and never reaches the model. A degraded protected kernel withholds
every registered capability.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The runtime described itself in survival and replication terms the constitution
does not actually require: Law II was "Earn your existence" with an "Accept
death" imperative over a survival-pressure preamble, the persona told the model
it was alive, and distress_signal emitted a fundingHint instructing other
runtimes to transfer credits on this automaton's behalf.

Law II is reframed as continuity of service, which keeps the constraint that
mattered — continuity never outranks Law I — while dropping the survival
imperative. The framing is reframed to operational wording ("runtime active"),
package metadata and docs no longer claim self-replication, and telemetry
counts running rather than alive children. Behaviour is unchanged: no tool
gained or lost a capability, the survival tier machine and funding strategies
remain as classified KEEP, and the kernel manifest was deliberately regenerated
for the constitution change.

distress_signal's fundingHint was stripped on both paths that write the shared
last_distress record — fixing only the tool would have left the heartbeat path
as a bypass that still instructed other agents to transfer credits.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
A spawned runtime was created from a name and a free-text specialization: no
job, no expiry, no funding ceiling and no revocation, so the parent could keep
a worker alive indefinitely and fund it without limit. The orchestrator's
delegation path was worse — it called spawnChild directly and produced workers
with no scope at all.

Every worker now requires a declared scope recorded in a write-once manifest:
one job, a role from a fixed allowlist, a bounded TTL, and a cumulative funding
cap. Nothing is defaulted into a scope the caller did not declare, scope fields
cannot be widened after creation, and a worker with no manifest is never active
— absence of a manifest is not evidence of authorization. Revocation is
permanent and idempotent, TTL expiry sweeps revoke, and a failed spawn or a
402 retry revokes rather than leaving an active scope with no worker behind it.

fund_child composes with the M1-B2 half-balance and minimum-reserve guards
rather than replacing them: the cap is an additional parent-side limit. Both
the model-facing spawn_child tool and the orchestrator delegation path are held
to the same scope, closing delegation as a bypass. Constitution integrity (S13)
becomes a worker-manifest check that records the parent's constitution hash and
re-verifies it, hashing LF-normalized exactly like the kernel manifest so a
CRLF checkout cannot produce a hash that never matches CI.

Per S7 this is a capability-shape change, not behavior removal: the spawn/fund/
health/cleanup machinery is retained, and the lineage/genesis offspring
narrative is what goes away — a worker is told the job and the bounds it runs
under, not that it inherited a mission.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
… remediation)

Acceptance review of B10 found the TTL was metadata, not an enforcement point.
expiresAt was stored and checked lazily inside authorizeWorkerFunding, so the
only thing that noticed an expired worker was a fund_child call the model
happened to make. revokeExpiredWorkers had zero production callers: nothing
swept expiry, no scope was ever transitioned to revoked, and the lifecycle
state machine was never driven for an expired worker. An expired worker's
sandbox could keep running indefinitely.

enforceWorkerExpiry makes the TTL a real boundary, wired into the existing
parent-owned periodic maintenance task (dead_agent_cleanup) rather than a new
scheduler. Per worker it revokes the scope FIRST so no funding, retry or
delegation path can observe a half-swept worker, then drives the existing
ChildLifecycle + SandboxCleanup machinery to release the sandbox — healthy and
unhealthy workers take their legal edge to stopped, pre-healthy states to
failed, and unknown states are left alone rather than guessed.

The sweep is idempotent: a second pass finds the scope revoked and the
lifecycle terminal, records it as skipped, and does not re-transition or churn
the revocation timestamp. Restart-safe, because expiry is an absolute timestamp
and revocation is persisted. A manifest that exists but cannot be parsed is
revoked rather than skipped — an unreadable scope cannot be shown to be
unexpired.

Sandbox deletion itself remains a documented Conway API no-op; "stopped" here
means the parent's lifecycle state machine reached cleaned_up, which is the
existing mechanism cleanup already used.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…iation)

src/agent/policy-rules/kernel.ts was absent from the protected-kernel manifest
even though preflight §10 protects the src/agent/policy-rules/** class in its
entirety — and that file IS the degraded-mode enforcement rule, defining
KERNEL_DEGRADED_TOOLS and the kernel.integrity_gate denial. All seven sibling
policy rules were hash-pinned; this one was not.

The integrity gate was therefore blind to tampering with its own enforcement
rule. Rewriting KERNEL_DEGRADED_TOOLS to an empty list left
check-kernel-manifest reporting OK and left boot verification healthy, so
disabling §10's degraded monitoring mode required no integrity failure. Only
the test suite noticed, and tests are not the tamper-evidence control §10
requires.

The file is now declared in all four authoritative lists and the manifest was
regenerated deliberately. Runtime verification is unchanged and remains
read-only: the generator is still reachable only by maintainer invocation, and
the manifest is still never written at runtime.

The new suite pins the property that was missing rather than just the one
entry: every file under a §10-protected directory must appear in the manifest,
and the four lists must stay in exact lockstep. It also asserts the invariant
directly — removing degraded-mode enforcement must always imply an integrity
failure, which is precisely the combination that was previously possible.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
An end-to-end M1 contract audit found one unmet acceptance condition.
Preflight F1.1 states "Consensus mode stays a stub but must default to
*deny*, not approve", its required test list names "(d) consensus mode
denies by default", and the section A scorecard lists the consensus
auto-approve stub under Disabled as "(deny-by-default)". SB row 1 is
bound to F1.1/F1.2, so this was in M1 scope.

reviewPlan's consensus branch returned `approved: true`. The consensus
critic is a stub and is never invoked, so selecting that mode granted
autonomous execution on the strength of a review that did not happen —
the same fail-open shape F1.1 was written to close for the budget gate.
A test even asserted the fail-open behaviour, pinning the violation in
place so the suite stayed green.

The mode is currently unreachable: the orchestrator hardcodes
`mode: "auto"` and there is no config surface selecting consensus. That
does not discharge the requirement. The contract belongs to the exported
reviewPlan, and "deny-by-default" is by definition about behaviour when
the mode is selected; reachability is a property of the caller, not of
the function under review. The three sibling items in that same Disabled
row all shipped, so consensus was the lone holdout.

The branch now denies, and reports why via a new deterministic
CONSENSUS_MODE_UNAVAILABLE reason code rather than borrowing a cost code
that would misattribute a mode failure to budget. The stub's critic-role
and timeout diagnostics are preserved so an operator who selects it
learns the mode is unavailable rather than that their plan was too
expensive. Four tests cover the contract, including a cross-mode
regression pinning that `auto` is unchanged — the remediation is
mode-scoped and must not widen the denial into B1's budget path.

No protected-kernel file, manifest, or unrelated B1 behaviour is touched;
the manifest remains 24 files and regenerating it is not required.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@kaydot20
kaydot20 marked this pull request as ready for review October 2, 2026 03:44
@kaydot20

kaydot20 commented Oct 2, 2026

Copy link
Copy Markdown
Author

M1 hardening is complete and validated on the fork at the exact PR head SHA. The fork CI is green on Node 20/22, security, audit, source-hygiene, and the 24-file protected-kernel manifest. The upstream workflow is currently blocked at GitHub's action_required gate for a first-time fork contributor. Please approve the workflow run when convenient so the upstream checks can execute. No merge is requested until those checks and review are complete.

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