@farmslot/agent-runtime 0.39.5 → 0.39.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,14 @@
8
8
 
9
9
  - Active-development baseline; add user-facing changes here before release or package publication.
10
10
 
11
+ ## 0.39.7 - 2026-10-28
12
+
13
+ - Wait for Codex review folder consent before completing terminal startup; provisional startup frames no longer bypass Open restricted.
14
+
15
+ ## 0.39.6 - 2026-10-28
16
+
17
+ - PR completion keeps linked criteria as evidence and checks worker-derived requirements without waiting for review.
18
+
11
19
  ## 0.39.5 - 2026-10-28
12
20
 
13
21
  - Cache native process metadata for up to a minute during passive polling while keeping fresh identity checks for cleanup and controls.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farmslot/agent-runtime",
3
- "version": "0.39.5",
3
+ "version": "0.39.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "@farmslot/adapter-sdk": "0.25.1",
72
- "@farmslot/protocol": "0.73.1"
72
+ "@farmslot/protocol": "0.74.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/node": "^22.0.0",
@@ -28,8 +28,6 @@ function effectiveAcceptanceContract(taskDir, base, baseBytes) {
28
28
  !Number.isSafeInteger(revision.revision) ||
29
29
  revision.revision < 1 ||
30
30
  !Array.isArray(revision.proofModes) ||
31
- typeof revision.claimReviewGate !== 'boolean' ||
32
- typeof revision.publicationReview !== 'boolean' ||
33
31
  revision.baseContractHash !== createHash('sha256').update(frozenBase).digest('hex')
34
32
  )
35
33
  throw new Error(
@@ -61,11 +59,11 @@ function effectiveAcceptanceContract(taskDir, base, baseBytes) {
61
59
  proofModes.set(row.id, row);
62
60
  }
63
61
  const {
64
- handoffAcceptanceCriteria,
62
+ workerAcceptanceCriteria,
65
63
  readAcceptanceLedger,
66
64
  inheritedCriterionIdsForTask,
67
65
  } = require('./acceptance-ledger.cjs');
68
- const criteria = handoffAcceptanceCriteria(taskDir);
66
+ const criteria = workerAcceptanceCriteria(taskDir);
69
67
  const inherited = inheritedCriterionIdsForTask(taskDir, criteria);
70
68
  const recordedInherited = revision.inheritedCriterionIds ?? [];
71
69
  if (
@@ -78,10 +76,6 @@ function effectiveAcceptanceContract(taskDir, base, baseBytes) {
78
76
  if (inherited.has(criterion.id)) continue;
79
77
  const row = ledger?.criteria?.find((candidate) => candidate.id === criterion.id);
80
78
  const mode = criterion.proofMode ?? row?.proofMode;
81
- if (['visual', 'mixed'].includes(mode) && base.claimReviewSupported === false)
82
- throw new Error(
83
- `${criterion.id}: captured visual completion review is unsupported for this run policy.`,
84
- );
85
79
  if (
86
80
  mode &&
87
81
  (proofModes.get(criterion.id)?.proofMode !== mode ||
@@ -93,11 +87,6 @@ function effectiveAcceptanceContract(taskDir, base, baseBytes) {
93
87
  }
94
88
  return {
95
89
  ...base,
96
- claimReviewGate: revision.claimReviewGate,
97
- publicationReview: revision.publicationReview,
98
- acceptanceReviewCriteria: revision.proofModes
99
- .filter(({ id, proofMode }) => proofMode === 'review' && !inherited.has(id))
100
- .map(({ id }) => id),
101
90
  inheritedAcceptanceCriteria: [...inherited],
102
91
  };
103
92
  }
@@ -116,6 +116,15 @@ function requireHandoffAcceptanceCriteria(taskDir) {
116
116
  return criteriaFromHandoff(handoff, taskDir);
117
117
  }
118
118
 
119
+ /** PR completion checks worker-derived requirements; original ACs remain evidence. */
120
+ function workerAcceptanceCriteria(taskDir) {
121
+ const criteria = requireHandoffAcceptanceCriteria(taskDir);
122
+ if (readJson(path.join(taskDir, HANDOFF_INPUT)).flow !== 'pr-complete') return criteria;
123
+ const { registration } = readJson(path.join(taskDir, ACCEPTANCE_REGISTRATION_INPUT));
124
+ const derived = new Set((registration?.derived ?? []).map(({ id }) => id));
125
+ return criteria.filter(({ id }) => derived.has(id));
126
+ }
127
+
119
128
  /** One message shape for a handoff the acceptance rule cannot read. */
120
129
  function handoffReadRefusal(detail) {
121
130
  return (
@@ -349,7 +358,12 @@ function acceptanceContractIssues(taskDir, options = {}) {
349
358
  `Acceptance derivation ${unit.id} is pending${unit.error ? `: ${unit.error}` : '; complete the source classification subtask'}.`,
350
359
  );
351
360
  if (criteria.length === 0) return [];
361
+ const completion = readJson(path.join(taskDir, HANDOFF_INPUT)).flow === 'pr-complete';
352
362
  const known = new Set(criteria.map(({ id }) => id));
363
+ if (completion) {
364
+ criteria = workerAcceptanceCriteria(taskDir);
365
+ if (!criteria.length) return [];
366
+ }
353
367
  try {
354
368
  const inherited = inheritedCriterionIdsForTask(taskDir, criteria, options.requireFresh);
355
369
  criteria = criteria.filter(({ id }) => !inherited.has(id));
@@ -398,13 +412,13 @@ function acceptanceContractIssues(taskDir, options = {}) {
398
412
  );
399
413
  continue;
400
414
  }
401
- const reviewDeferred =
415
+ const retainedReviewEvidence =
416
+ completion &&
402
417
  entry.verdict === 'awaiting-review' &&
403
- entry.proofMode === 'review' &&
404
- options.deferReviewCriteria?.includes(criterion.id);
418
+ ['visual', 'mixed', 'review'].includes(entry.proofMode);
405
419
  if (
406
- options.deferClaimVerdicts !== true &&
407
- !reviewDeferred &&
420
+ (completion || options.deferClaimVerdicts !== true) &&
421
+ !retainedReviewEvidence &&
408
422
  (entry.verdict === 'failed' ||
409
423
  entry.verdict === 'awaiting-review' ||
410
424
  (!options.allowWeak && (entry.verdict === 'missing' || entry.verdict === 'weak')))
@@ -425,6 +439,7 @@ module.exports = {
425
439
  ACCEPTANCE_VERDICTS,
426
440
  AcceptanceRefusal,
427
441
  acceptanceContractIssues,
442
+ workerAcceptanceCriteria,
428
443
  acceptanceCriterionId,
429
444
  acceptanceRowExecution,
430
445
  acceptanceStatusList,
@@ -589,10 +589,16 @@ if (
589
589
  flags.has('--require-acceptance-status') ||
590
590
  (terminalCommand === 'complete' && !isReviewTerminal)
591
591
  ) {
592
+ const owningFlow =
593
+ readJsonArtifact('inputs/handoff.json', 'handoff')?.flow ?? terminalContract?.flowType;
592
594
  let deferClaimVerdicts = false;
593
595
  const ledger = readAcceptanceLedger(taskDir);
594
596
  // ADR-062 Amendment 18: only the run's publication code review checks a `review` claim.
595
- if (terminalCommand === 'complete' && terminalContract?.publicationReview !== true) {
597
+ if (
598
+ terminalCommand === 'complete' &&
599
+ owningFlow !== 'pr-complete' &&
600
+ terminalContract?.publicationReview !== true
601
+ ) {
596
602
  for (const row of Array.isArray(ledger?.criteria) ? ledger.criteria : []) {
597
603
  if (
598
604
  row?.proofMode === 'review' &&
@@ -605,6 +611,7 @@ if (
605
611
  }
606
612
  if (
607
613
  terminalCommand === 'complete' &&
614
+ owningFlow !== 'pr-complete' &&
608
615
  terminalContract?.claimReviewGate === true &&
609
616
  ledger?.schemaVersion === 2
610
617
  ) {
@@ -614,10 +621,6 @@ if (
614
621
  deferClaimVerdicts = integrityIssues.length === 0;
615
622
  }
616
623
  for (const issue of acceptanceContractIssues(taskDir, {
617
- deferReviewCriteria:
618
- terminalContract?.publicationReview === true
619
- ? terminalContract.acceptanceReviewCriteria
620
- : undefined,
621
624
  allowWeak: terminalContract?.acceptance?.allowWeak === true,
622
625
  requireFresh: terminalContract?.acceptance?.requireFresh === true,
623
626
  deferClaimVerdicts,
@@ -19,19 +19,15 @@ const ENDINGS = [
19
19
  // need review" (enter confirm · esc skip); unknown ones must fail, not wait out.
20
20
  const PROMPT_MARKERS =
21
21
  /folder access|open restricted|trust this folder|trust and continue|trust all|hooks need review|update available|enter continue|enter confirm|esc quit|esc back|esc skip|press enter|\(y\/n\)/i;
22
- const WORKING = /esc to interrupt/;
23
- const COMPOSER = /\? for shortcuts/;
24
- // The boot splash, and a header frame right after it, already paint the composer
25
- // footer before Folder access appears, so an idle composer only counts as ready
26
- // once it has held this long.
27
- const LOADING = /OpenAI Codex \(v[^)]*\) loading/;
28
- const IDLE_READY_MS = 1_500;
22
+ // Codex 0.165 paints its editable startup composer while folder consent is
23
+ // still pending. Neither an idle footer nor "esc to interrupt" completes this
24
+ // handshake: this untrusted review must observe and answer Open restricted.
29
25
 
30
26
  const collapse = (text) => text.replace(/\s+/g, ' ').trim();
31
27
 
32
28
  /**
33
29
  * Classify a captured Codex pane: the exact Folder access screen for one of
34
- * `folders`, any other prompt, a working turn, an idle composer, or starting.
30
+ * `folders`, any other prompt, or starting. Composer text is not startup evidence.
35
31
  */
36
32
  function classifyCodexLaunchScreen(pane, folders) {
37
33
  const text = collapse(pane);
@@ -44,8 +40,6 @@ function classifyCodexLaunchScreen(pane, folders) {
44
40
  return { kind: 'folder-access' };
45
41
  }
46
42
  if (PROMPT_MARKERS.test(text)) return { kind: 'prompt' };
47
- if (WORKING.test(text)) return { kind: 'working' };
48
- if (!LOADING.test(text) && COMPOSER.test(text)) return { kind: 'idle' };
49
43
  return { kind: 'starting' };
50
44
  }
51
45
 
@@ -57,18 +51,16 @@ const excerpt = (pane) =>
57
51
  .join('\n');
58
52
 
59
53
  /**
60
- * Watch a freshly launched Codex pane until it is working on the prompt, or idle
61
- * at its composer for IDLE_READY_MS. Returns 'restricted' when it answered the
62
- * Folder access screen, null otherwise. Throws on any other prompt, or when the
63
- * screen is still there after its one answer. `claimAnswer` must atomically claim
64
- * the launch's single answer (false when another watcher of the same launch, or
65
- * an earlier interrupted one, already holds it); without the claim Folder access
66
- * is only waited out.
54
+ * Watch this untrusted review launch until the exact Folder access screen has
55
+ * been answered and disappeared. Other prompts, a dead terminal, or a deadline
56
+ * before that handshake fail the launch. `claimAnswer` atomically claims its
57
+ * single Enter; a replay may only wait for the already-claimed answer to settle.
67
58
  */
68
59
  async function answerCodexFolderAccess({
69
60
  capture,
70
61
  sendEnter,
71
62
  claimAnswer = () => true,
63
+ isAnswerClaimed = () => false,
72
64
  folders,
73
65
  timeoutMs = 15_000,
74
66
  settleMs = 2_000,
@@ -78,23 +70,18 @@ async function answerCodexFolderAccess({
78
70
  }) {
79
71
  const deadline = now() + timeoutMs;
80
72
  let answeredAt = null;
81
- let idleSince = null;
82
- while (now() < deadline) {
73
+ while (now() < deadline || (answeredAt !== null && now() - answeredAt < settleMs)) {
83
74
  await sleep(pollMs);
84
75
  const pane = capture();
85
- // The session ended; the run monitor reports a dead reviewer.
86
- if (pane === null) break;
76
+ if (pane === null) throw new Error('Codex terminal exited before Folder access completed');
87
77
  const screen = classifyCodexLaunchScreen(pane, folders);
88
- if (screen.kind === 'working') break;
89
- if (screen.kind === 'idle') {
90
- idleSince ??= now();
91
- if (now() - idleSince >= IDLE_READY_MS) break;
92
- continue;
93
- }
94
- idleSince = null;
78
+ if (answeredAt === null && isAnswerClaimed()) answeredAt = now();
95
79
  if (screen.kind === 'prompt')
96
80
  throw new Error(`Codex showed an unexpected launch prompt:\n${excerpt(pane)}`);
97
- if (screen.kind !== 'folder-access') continue;
81
+ if (screen.kind !== 'folder-access') {
82
+ if (answeredAt !== null && now() - answeredAt >= settleMs) return 'restricted';
83
+ continue;
84
+ }
98
85
  if (answeredAt === null) {
99
86
  if (claimAnswer()) sendEnter();
100
87
  answeredAt = now();
@@ -104,7 +91,7 @@ async function answerCodexFolderAccess({
104
91
  );
105
92
  }
106
93
  }
107
- return answeredAt === null ? null : 'restricted';
94
+ throw new Error('Codex Folder access did not complete before the launch deadline');
108
95
  }
109
96
 
110
97
  module.exports = { answerCodexFolderAccess, classifyCodexLaunchScreen };
@@ -23,6 +23,7 @@ const target = input.session;
23
23
  async function codexHandshake(marker, claim, record, folders) {
24
24
  try {
25
25
  await answerCodexFolderAccess({
26
+ isAnswerClaimed: () => fs.existsSync(claim),
26
27
  capture: () => {
27
28
  const pane = tmux(['capture-pane', '-p', '-t', target]);
28
29
  return pane.status === 0 ? pane.stdout : null;