Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix: fence outside revisions and explain sensitive paths [V3,B26]
Corey Olsonc8d6c17ec427
diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex 2114849d..9054b302 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -56,10 +56,10 @@ Each move checks its guards in this order and refuses with the first one that do| Move | From | To | Who | Guards, in order; result refusals || --- | --- | --- | --- | --- || intake | open | submitted | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), outsideSubmission (OUTSIDE_SOURCE) |-| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), checkProvesSomething (CRITERION_PROVES_NOTHING), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), builderFirstRefusal (REOPEN_HELD_FOR_BUILDER), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED) |+| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), checkProvesSomething (CRITERION_PROVES_NOTHING), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE or OUTSIDE_NATIVE_BUILD), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), builderFirstRefusal (REOPEN_HELD_FOR_BUILDER), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED) || release | open, claimed | open | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), releaseOwnsWork (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) || lapse | claimed | open | clock, when its lease runs out | none |-| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT or HOST_NAME), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), infraExplained (INFRA_NOTE_REQUIRED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or LAND_TIMEOUT_CUSTODY or LAND_GATE_OUTPUT or SLOT_DB_LOCKED or RUNNER_BROWSER_SLOT_REQUIRED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |+| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS or OUTSIDE_NATIVE_BUILD), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT or HOST_NAME), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), infraExplained (INFRA_NOTE_REQUIRED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or LAND_TIMEOUT_CUSTODY or LAND_GATE_OUTPUT or SLOT_DB_LOCKED or RUNNER_BROWSER_SLOT_REQUIRED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) || reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) || accept | submitted, verified | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or SANDBOX_PROVIDER_REQUIRED or SANDBOX_IMAGE_REQUIRED or SANDBOX_RUNTIME or SANDBOX_EXPORT or SANDBOX_EXECUTION or SANDBOX_CLEANUP_REQUIRED or SANDBOX_CHECK_REQUIRED or CHECK_NO_PROOF or OUTSIDE_SANDBOX_REQUIRED or SLOT_DB_LOCKED or CHECK_UNVERIFIED or GUARD_CANNOT_FAIL or GUARD_NOT_FOUND), proofNoted (PROOF_REQUIRED), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION) || reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) |@@ -102,7 +102,9 @@ Each move checks its guards in this order and refuses with the first one that do| NOT_YOURS | the caller holds the item, or is the coordinator | shout its holder, or the coordinator || NOT_YOURS | the caller holds the claim or is the builder yielding its active first-refusal window | release your own claim or reservation, or ask the current builder || NOT_YOURS | the caller holds the claim | pullboard claim <id> |+| OUTSIDE_NATIVE_BUILD | the caller holds the claim | the outside author revises the PR; ask the coordinator to return it, then intake the new exact head || WRONG_LANE | the item is in the caller's lane; the main checkout builds coordinator-lane items only | cd <the lane's worktree> && pullboard claim <id> |+| OUTSIDE_NATIVE_BUILD | the item is in the caller's lane; the main checkout builds coordinator-lane items only | the outside author revises the PR; ask the coordinator to return it, then intake the new exact head || ROUTE | the caller's route covers the item's: light, then mid, then strong | pullboard next, which offers only items your route covers || BLOCKED | every item it waits on is verified | claim another item, or shout the lane it waits on || REOPEN_HELD_FOR_BUILDER | a returned item waits for its original builder until its recorded deadline or builder release | wait until the named deadline, or ask its builder to run pullboard release <id> |diff --git a/src/board.js b/src/board.jsindex c601a306..df6fdd45 100644--- a/src/board.js+++ b/src/board.js@@ -4,6 +4,7 @@ import {} from './outside-store.js';import {outsideSandboxProblem,+ outsideBuildProblem,outsideSource,requireOutsideOwner,saveOutsideSource,@@ -982,6 +983,8 @@ export function claim(board, id, { agentId, lane, leaseMs, freeze, head = null,joined: null, checkProvesSomething: null,[IN_STATE]: (found) => new Refused('NOT_CLAIMABLE', `item #${id} is ${found.item_status}`),inLane: (found) => {+ const outside = outsideBuildProblem(board, found);+ if (outside) return outside;if (found.item_lane === lane) return null;return new Refused('WRONG_LANE',@@ -1128,7 +1131,7 @@ export function submit(board, id, { agentId, commit, tree, files = [], policyComchecks: {joined: null, checkProvesSomething: null,[IN_STATE]: notYours,- isHolder: (found) => (found.item_owner === agentId ? null : notYours()),+ isHolder: (found) => outsideBuildProblem(board, found) ?? (found.item_owner === agentId ? null : notYours()),correctionRefrozen: () => pendingRefreezeProblem(board, id),criterionUnchanged: null,treeClean: null,@@ -2466,7 +2469,7 @@ export function finishLandingBatch(board, { agentId, id, tip, landingFence }) {}/** File or refresh an outside source through the ordinary ordered engine. */-export function intakeOutside(board, options) { return applyOutsideIntake(board, options, { atomic, addItem, moveItem }); }+export function intakeOutside(board, options) { return applyOutsideIntake(board, options, { atomic, addItem, moveItem, validateItemAddition }); }/** Record the person's exact-commit owner approval. */export function approveOutside(board, id, options) { return applyOutsideApproval(board, id, options, atomic); }diff --git a/src/engine.js b/src/engine.jsindex 8df29895..d23d4f1f 100644--- a/src/engine.js+++ b/src/engine.js@@ -1,3 +1,4 @@+import { outsideSource } from './outside-source.js';import { requireOutsideReceipt } from './outside-proof.js';import { OUTSIDE_INTAKE_ENGINE } from './outside-intake-engine.js';import { ITEM_SHOUT_ENGINE } from './item-shout-engine.js';@@ -94,7 +95,8 @@ const OPERATION_ENGINE = Object.freeze({ draftSpecRow: ROW_DRAFT_ENGINE, orderMi/** Dependency edits, causes, sealed reviews, submission proofs, trunk conflicts, health observations and milestone targets retain distinct recorded engine meanings. */function minimumOperationEngine(operation, args, board, at) {- const outside = ['intakeOutside', 'approveOutside'].includes(operation) || operation === 'verify' && args[1]?.sandbox !== undefined;+ const outside = ['intakeOutside', 'approveOutside'].includes(operation) || operation === 'verify' && args[1]?.sandbox !== undefined+ || board && ['claim', 'submit', 'verify', 'merged'].includes(operation) && Boolean(outsideSource(board, args[0]));return Math.max(outside ? OUTSIDE_INTAKE_ENGINE : 1, minimumExistingOperationEngine(operation, args, board, at));}diff --git a/src/intake-github.js b/src/intake-github.jsindex b96d1e58..7292f39c 100644--- a/src/intake-github.js+++ b/src/intake-github.js@@ -1,3 +1,4 @@+import { outsideSensitivity } from './outside-sensitive.js';/** Read GitHub public source metadata; never post, execute PR programs or use its executable settings. */import { spawnSync } from 'node:child_process';import { Refused } from './refused.js';@@ -40,7 +41,6 @@ export function githubSource(root, url) {if (paths.some(path => typeof path !== 'string' || path.includes('\n') || path.startsWith('/') || path.split('/').includes('..'))) throw new Refused('OUTSIDE_FETCH', 'GitHub returned an invalid changed path; restore its file metadata');const changed = git(root, ['diff', '--name-only', '-z', `${data.base.sha}...${fetched}`]).split('\0').filter(Boolean);if (changed.length !== paths.length || changed.some(path => !paths.includes(path))) throw new Refused('OUTSIDE_FETCH', 'the changed-file list differs from the fetched exact commit; refresh GitHub metadata');- // Fail closed for command-bearing files as well as explicit trust boundaries.- const sensitive = paths.some(path => /(^|\/)(relay|hooks?|\.github|person|sealing|signing)(\/|[.-]|$)/iu.test(path) || /(^|\/)(package\.json|Makefile|Dockerfile|.*\.(?:sh|bash|zsh|cmd|ps1))$/iu.test(path) || /(^|\/)(bin|scripts)\//u.test(path));- return { ...common, commit: fetched, tree: git(root, ['rev-parse', `${fetched}^{tree}`]).trim(), base: data.base.sha, files: paths, sensitive };+ const sensitivity = outsideSensitivity(root, data.base.sha, fetched, paths);+ return { ...common, commit: fetched, tree: git(root, ['rev-parse', `${fetched}^{tree}`]).trim(), base: data.base.sha, files: paths, sensitivity, sensitive: sensitivity.length > 0 };}diff --git a/src/machine.js b/src/machine.jsindex d259e64e..74d95eec 100644--- a/src/machine.js+++ b/src/machine.js@@ -104,8 +104,8 @@ export const GUARDS = [{ id: 'coordinatorSaysAs', refuse: 'MAIN_IS_COORDINATOR', rule: 'in the main checkout, the caller says it is the coordinator', next: 'verify from your own worktree; the coordinator adds --as coordinator', source: 'cli' },{ id: 'holderOrCoordinator', refuse: 'NOT_YOURS', rule: 'the caller holds the item, or is the coordinator', next: 'shout its holder, or the coordinator', source: 'board' },{ id: 'releaseOwnsWork', refuse: 'NOT_YOURS', rule: 'the caller holds the claim or is the builder yielding its active first-refusal window', next: 'release your own claim or reservation, or ask the current builder', source: 'board' },- { id: 'isHolder', refuse: 'NOT_YOURS', rule: 'the caller holds the claim', next: 'pullboard claim <id>', source: 'board' },- { id: 'inLane', refuse: 'WRONG_LANE', rule: "the item is in the caller's lane; the main checkout builds coordinator-lane items only", next: "cd <the lane's worktree> && pullboard claim <id>", source: 'board' },+ { id: 'isHolder', alsoRefuses: [{ code: 'OUTSIDE_NATIVE_BUILD', next: 'the outside author revises the PR; ask the coordinator to return it, then intake the new exact head' }], refuse: 'NOT_YOURS', rule: 'the caller holds the claim', next: 'pullboard claim <id>', source: 'board' },+ { id: 'inLane', alsoRefuses: [{ code: 'OUTSIDE_NATIVE_BUILD', next: 'the outside author revises the PR; ask the coordinator to return it, then intake the new exact head' }], refuse: 'WRONG_LANE', rule: "the item is in the caller's lane; the main checkout builds coordinator-lane items only", next: "cd <the lane's worktree> && pullboard claim <id>", source: 'board' },{ id: 'routeAllows', refuse: 'ROUTE', rule: "the caller's route covers the item's: light, then mid, then strong", next: 'pullboard next, which offers only items your route covers', source: 'board' },{ id: 'dependenciesVerified', refuse: 'BLOCKED', rule: 'every item it waits on is verified', next: 'claim another item, or shout the lane it waits on', source: 'board' },{ id: 'builderFirstRefusal', refuse: 'REOPEN_HELD_FOR_BUILDER', rule: 'a returned item waits for its original builder until its recorded deadline or builder release', next: 'wait until the named deadline, or ask its builder to run pullboard release <id>', source: 'board' },diff --git a/src/next-step-words.js b/src/next-step-words.jsindex 7cf495e6..effe2ec7 100644--- a/src/next-step-words.js+++ b/src/next-step-words.js@@ -56,6 +56,7 @@ export function personRequestGuidance(message, { caller, leading = false } = {})/** @type {Readonly<Record<string, string>>} */export const NEXT_STEPS = Object.freeze({+ OUTSIDE_NATIVE_BUILD: 'the outside author revises the PR; ask the coordinator to return it, then intake its new exact head',CHECK_NO_PROOF: 'strengthen the trusted criterion so it fails before the outside change, then ask the coordinator to refreeze it',OUTSIDE_URL: 'use a GitHub issue or pull request URL with owner/repository and its positive number',OUTSIDE_FETCH: 'restore read-only gh API and Git fetch access, then intake the exact source again',diff --git a/src/outside-sensitive.js b/src/outside-sensitive.jsnew file mode 100644index 00000000..ca6cd141--- /dev/null+++ b/src/outside-sensitive.js@@ -0,0 +1,58 @@+/** Explain owner-sensitive outside changes from trusted main policy and exact Git objects, never execution. */+import { git } from './git.js';+import { Refused } from './refused.js';+import { mainPolicy } from './trusted-policy.js';++/** Fixed trust boundaries cannot be removed by a project's extensions or the contributed configuration. */+export const OUTSIDE_SENSITIVE_PATHS = Object.freeze([+ 'relay/', '.githooks/', '.husky/', '.github/workflows/', 'bin/',+ 'src/seal.js', 'src/sealed-pages.js', 'src/signature.js', 'src/relay-key.js', 'src/relay-device-keys.js',+ 'src/person.js', 'src/person-request.js', 'src/relay-requests.js', 'src/relay-request-execution.js', 'src/relay-sender.js',+ 'src/row-decisions.js', 'src/row-decision-state.js', 'src/spec-approval.js', 'src/spec-approval-baseline.js',+ 'src/hooks.js', 'src/commands/hook.js', 'src/commands/hooks.js', 'pullboard.json',+]);++/** Read a committed text blob; unreadable, binary and invalid UTF-8 input fails closed as sensitive. */+function textAt(root, commit, path) {+ const text = git(root, ['show', `${commit}:${path}`], { maxBuffer: 1024 * 1024 });+ if (text.includes('\0') || text.includes('\ufffd')) throw new Error('not readable text');+ return text;+}++/** Match only declared relative exact paths or trailing-slash prefixes, like lane ownership paths. */+function declared(path, pattern) {+ return path === pattern || pattern.endsWith('/') && path.startsWith(pattern);+}++/** Record a reason for every rule/path match; a display can explain the hold without rerunning the classifier. */+export function outsideSensitivity(root, base, commit, paths) {+ const configured = mainPolicy(root).config.intake?.sensitivePaths ?? [];+ if (!Array.isArray(configured) || configured.some(path => typeof path !== 'string' || !path || path.startsWith('/') || path.split('/').includes('..') || /[\r\n\0]/u.test(path))) {+ throw new Refused('BAD_CONFIG', 'intake.sensitivePaths in trusted main is a list of relative exact files or trailing-slash prefixes; correct it before intake');+ }+ const reasons = [];+ for (const path of paths) {+ for (const pattern of OUTSIDE_SENSITIVE_PATHS) if (declared(path, pattern)) reasons.push({ path, rule: 'declared-sensitive-path', detail: pattern });+ for (const pattern of configured) if (declared(path, pattern)) reasons.push({ path, rule: 'configured-sensitive-path', detail: pattern });+ if (/(^|\/)(?:\.?(?:huskyrc|lintstagedrc)(?:\..*)?|\.?lefthook(?:\..*)?|\.pre-commit-config\.(?:yaml|yml))$/iu.test(path)) reasons.push({ path, rule: 'hook-configuration', detail: 'hook tool configuration' });+ try {+ const content = textAt(root, commit, path);+ if (path === 'package.json') {+ const next = JSON.parse(content);+ let previous = {};+ try { previous = JSON.parse(textAt(root, base, path)); } catch { /* A new package has no earlier fields. */ }+ for (const field of ['scripts', 'engines', 'husky', 'lint-staged', 'simple-git-hooks']) {+ if (JSON.stringify(previous[field]) !== JSON.stringify(next[field])) reasons.push({ path, rule: 'package-execution-policy', detail: field });+ }+ }+ const diff = git(root, ['diff', '--no-ext-diff', '--no-textconv', '--unified=0', base, commit, '--', path], { maxBuffer: 2 * 1024 * 1024 });+ const added = diff.split('\n').filter(line => line.startsWith('+') && !line.startsWith('+++')).join('\n');+ if (/child_process|\b(?:spawn(?:Sync)?|exec(?:File)?(?:Sync)?|runProfiledShell(?:Async)?|runShell|runCommand|shell|runner)\s*\(/u.test(added)) {+ reasons.push({ path, rule: 'new-process-execution', detail: 'added child_process import, process-execution call or shell-runner call' });+ }+ } catch {+ reasons.push({ path, rule: 'unreadable-changed-file', detail: 'the classifier could not read and classify the exact committed file' });+ }+ }+ return reasons;+}diff --git a/src/outside-source.js b/src/outside-source.jsindex 276207a9..d4acc716 100644--- a/src/outside-source.js+++ b/src/outside-source.js@@ -31,3 +31,10 @@ export function outsideSandboxProblem(board, item, receipt) {}return null;}++/** Outside PR code is revised by its source author, never claimed or submitted as native build work. */+export function outsideBuildProblem(board, item) {+ return outsideSource(board, item.item_id)?.kind === 'pull-request'+ ? new Refused('OUTSIDE_NATIVE_BUILD', `outside item #${item.item_id} stays with its PR author; ask the coordinator to return it, then intake the author's new exact head`)+ : null;+}diff --git a/src/outside-store.js b/src/outside-store.jsindex fae42cf8..71987c59 100644--- a/src/outside-store.js+++ b/src/outside-store.js@@ -14,30 +14,35 @@ function validate(source, frozen) {!Number.isSafeInteger(source.number) || source.number < 1 || !/^[A-Za-z0-9-]{1,39}$/u.test(source.author ?? '') || !['open', 'closed'].includes(source.state) || typeof source.maintainerReplied !== 'boolean') {throw new Refused('OUTSIDE_SOURCE', 'intake needs GitHub source metadata; fetch the exact issue or pull request again');}- if (source.kind === 'pull-request' && (!/^[a-f0-9]{40}$/u.test(source.commit ?? '') || !/^[a-f0-9]{40}$/u.test(source.tree ?? '') || !frozen ||+ if (source.kind === 'pull-request' && (!/^[a-f0-9]{40}$/u.test(source.commit ?? '') || !/^[a-f0-9]{40}$/u.test(source.tree ?? '') || !frozen || typeof frozen.text !== 'string' || !Array.isArray(source.files) || !/^[a-f0-9]{40}$/u.test(source.base ?? '') || typeof source.sensitive !== 'boolean' ||createHash('sha256').update(frozen.text).digest('hex') !== frozen.digest)) throw new Refused('OUTSIDE_SOURCE', 'fetch the exact pull request commit and freeze its trusted criterion before intake');}/** Apply one replayable source refresh; refresh never silently replaces a submitted commit. */-export function applyOutsideIntake(board, options, { atomic, addItem, moveItem }) {+export function applyOutsideIntake(board, options, { atomic, addItem, moveItem, validateItemAddition }) {return atomic(board, () => {const { agentId, source, item, frozen } = options;validate(source, frozen);const existing = board.db.prepare("SELECT meta_key,meta_value FROM board_meta WHERE meta_key LIKE 'outside:%'").all().find(row => { const old = JSON.parse(row.meta_value); return old.repository === source.repository && old.kind === source.kind && old.number === source.number; });- if (existing) {- const id = Number(existing.meta_key.slice('outside:'.length));- const old = outsideSource(board, id);- if (source.kind === 'pull-request' && old.commit !== source.commit) throw new Refused('OUTSIDE_HEAD_CHANGED', 'the pull request head changed; ask the coordinator to reopen its recorded submission before intaking the new head');- saveOutsideSource(board, id, { ...old, state: source.state, maintainerReplied: source.maintainerReplied, updatedAt: source.updatedAt });- logEvent(board, agentId, 'outside-refresh', id, { source });- return id;+ const priorId = existing ? Number(existing.meta_key.slice('outside:'.length)) : null;+ const old = priorId ? outsideSource(board, priorId) : null;+ if (old && (source.kind === 'issue' || old.commit === source.commit)) {+ saveOutsideSource(board, priorId, { ...old, state: source.state, maintainerReplied: source.maintainerReplied,+ ...(source.kind === 'pull-request' ? { sensitive: source.sensitive, sensitivity: source.sensitivity } : {}), updatedAt: source.updatedAt });+ logEvent(board, agentId, 'outside-refresh', priorId, { source });+ return priorId;}- const id = addItem(board, { ...item, by: agentId });+ if (old && itemById(board, priorId).item_status !== 'open') throw new Refused('OUTSIDE_HEAD_CHANGED', 'the pull request head changed; ask the coordinator to reopen its recorded submission before intaking the new head');+ // Re-intake must obey the same coordinator-owned bar validation as the original addition.+ validateItemAddition(board, { ...item, by: agentId });+ const id = priorId ?? addItem(board, { ...item, by: agentId });saveOutsideSource(board, id, { ...source, ownerApproval: null, sandbox: null });if (source.kind === 'pull-request') moveItem(board, id, 'intake', {- checks: { joined: null, itemExists: null, inState: () => new Refused('NOT_CLAIMABLE', 'intake files a new outside item'), outsideSubmission: null },+ checks: { joined: null, itemExists: null, inState: () => new Refused('NOT_CLAIMABLE', 'intake files or re-intakes a normally returned outside item'), outsideSubmission: null },set: () => ({ item_built_by: `outside:github:${source.author}`, item_commit: source.commit, item_tree: source.tree,+ item_title: item.title, item_criterion: item.criterion, item_check: item.check, item_route: item.route ?? 'strong',+ item_owner: null, item_lease_until: null, item_review_by: null, item_review_until: null, item_verdict: null, item_verified_by: null,item_claim_head: source.base, item_frozen: frozen.text, item_frozen_digest: frozen.digest, item_files: source.files.join('\n') }),});logEvent(board, agentId, 'outside-intake', id, { source, frozen });diff --git a/src/outside-verify.js b/src/outside-verify.jsindex 16763b49..63c85f88 100644--- a/src/outside-verify.js+++ b/src/outside-verify.js@@ -37,7 +37,7 @@ export async function outsideVerdict(ctx, board, item, me, decision, values) {if (headCommit(ctx.info.root) !== head || !isClean(ctx.info.root) || untracked(ctx.info.root).length) throw new Refused('NOT_AT_COMMIT', 'the trusted reviewing checkout moved during sandbox verification; restore its clean head before reviewing again');const after = requireTrunkMerge(ctx.info.root, item.item_commit);if (after.commit !== trunk.commit) throw new Refused('VERDICT_TRUNK_MOVED', 'main moved during sandbox verification; review the outside change against current main');- review = { commit: item.item_commit, head: item.item_commit, trunk: trunk.commit, paths: [...new Set([...(item.outside.files ?? []), 'pullboard.json', 'SPEC.md', 'DOCTRINE.md'])] };+ review = { commit: item.item_commit, head: item.item_commit, trunk: trunk.commit, paths: [...new Set([...(item.outside.files ?? []), 'pullboard.json', 'SPEC.md', 'DOCTRINE.md'])].sort() };}return ordered(ctx, board, 'verify', [item.item_id, { agentId: me.id, decision, reason: values.reason,note: textArg(ctx.io, values, 'note') ?? '', head: item.item_commit, digest, policy: policy.config.verify.policy, familyPolicy: policy.config.verify.family,diff --git a/test/intake.test.js b/test/intake.test.jsindex b54b8db8..85668bea 100644--- a/test/intake.test.js+++ b/test/intake.test.js@@ -103,7 +103,9 @@ test('outside sealing and command-bearing changes require owner approval [B26,V3advanceOutsideFixture(box, 'src/seal.js', 'export const sealFixture = true;\n', ['relay/outside.js']);const filed = fixtureJSON(box, box.repo, 'intake', box.pull.html_url, '--criterion', 'the fixture behavior works', '--check', 'node --test test/contribution.test.js');const id = String(filed.item.item_id);- assert.equal(fixtureJSON(box, box.repo, 'show', id).outside.sensitive, true, 'the existing sealing boundary needs owner approval even without a relay change');+ const source = fixtureJSON(box, box.repo, 'show', id).outside;+ assert.equal(source.sensitive, true, 'the existing sealing boundary needs owner approval even without a relay change');+ assert.ok(source.sensitivity.some(reason => reason.path === 'src/seal.js' && reason.rule === 'declared-sensitive-path'));});test('a returned outside pull request cannot be claimed as native build work [V1,V3]', t => {@@ -134,3 +136,29 @@ test('an outside author revision is re-intaken only after normal return and cleaassert.equal(refreshed.item.outside.ownerApproval, null, 'the old owner approval never authorizes the new source commit');assert.equal(refreshed.item.outside.sandbox, null, 'the new outside head must be executed in the sandbox again');});+++test('outside process-execution detection and unreadable files explain their owner holds [B26,V3]', t => {+ const box = intakeFixture(t);+ advanceOutsideFixture(box, 'lib/plain.js', "import { execFile } from 'node:child_process'; export const run = () => execFile('true');\n", ['relay/outside.js']);+ advanceOutsideFixture(box, 'assets/opaque.bin', Buffer.from([0, 255, 254]));+ const filed = fixtureJSON(box, box.repo, 'intake', box.pull.html_url, '--criterion', 'the fixture behavior works', '--check', 'node --test test/contribution.test.js');+ const reasons = filed.item.outside.sensitivity;+ assert.ok(reasons.some(reason => reason.path === 'lib/plain.js' && reason.rule === 'new-process-execution'));+ assert.ok(reasons.some(reason => reason.path === 'assets/opaque.bin' && reason.rule === 'unreadable-changed-file'));+});++test('only trusted main can extend outside sensitive paths and ordinary source stays ordinary [B26,V4]', t => {+ const box = intakeFixture(t);+ const configPath = new URL('pullboard.json', 'file://' + box.repo + '/');+ const config = JSON.parse(readFileSync(configPath, 'utf8'));+ config.intake = { sensitivePaths: ['data/regulated.json'] };+ writeFileSync(configPath, JSON.stringify(config));+ box.git(box.repo, 'add', 'pullboard.json');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: declare private sensitive data');+ advanceOutsideFixture(box, 'data/regulated.json', '{"fixture":true}\n', ['relay/outside.js']);+ advanceOutsideFixture(box, 'lib/ordinary.js', 'export const add = (left, right) => left + right;\n');+ const filed = fixtureJSON(box, box.repo, 'intake', box.pull.html_url, '--criterion', 'the fixture behavior works', '--check', 'node --test test/contribution.test.js');+ assert.ok(filed.item.outside.sensitivity.some(reason => reason.path === 'data/regulated.json' && reason.rule === 'configured-sensitive-path'));+ assert.equal(filed.item.outside.sensitivity.some(reason => reason.path === 'lib/ordinary.js'), false, 'source files are not all sensitive just for being source');+});