diff --git a/docs/CHECKS.md b/docs/CHECKS.md
index 268c2c6..b57b0bf 100644
--- a/docs/CHECKS.md
+++ b/docs/CHECKS.md
@@ -50,7 +50,7 @@ requires Bun 1.4 or later. See [Live review](LIVE-REVIEW.md).
| `JOB_BINDING_INVALID` | The private sibling/outbox is tracked or not effectively ignored, the binding is malformed, unavailable or mismatched, or a job command has invalid arguments. Restore effective private ignores. Restore the matching writer-owned binding through `job open`, then retry publication into the existing job. |
| `JOB_PRIVATE_STORAGE_INVALID` | Private publication storage has unsafe permissions, type or symlinks. Restore owner-only real directories and regular files. |
| `JOB_OUTBOX_INVALID` | A private publication receipt is absent, malformed or unreadable. Restore its writer-owned bytes before reconciling. The check reports this as a HOLE. |
-| `JOB_ASK_PENDING` | A bound writer would publish a different target while the job has an owner ask with no ingested act. The message names the job and pending asks. Have the owner finish those asks, run `job acts` and ingest the acts with the printed commands, then retry the writer to publish into the existing job. Refusal preserves `project.json` and the job state byte-identically. |
+| `JOB_ASK_PENDING` | A bound writer, or `job open --question`/`--plan`, would publish a different target while the job has an owner ask with no ingested act. Publishing supersedes the open ask, so a second interview question waits for the first. The message names the job and pending asks. Have the owner finish those asks, run `job acts
--wait` and ingest the acts with the printed commands, then retry the command to publish into the existing job. Refusal preserves `project.json` and the job state byte-identically. |
| `JOB_PUBLICATION_ASK_REQUIRED` | A bound version writer would replace an open publication with no owner ask. Keep the open page and use `job open` when the next review is ready. The refusal leaves the record and outbox unchanged. |
| `JOB_ASK_REFUSED` | A publication is acknowledged, but Review refused the ask for one of its declared subjects. The message names each subject and Review's code. The publication is not pending. Restore the published record bytes and run `job open` to ask again. |
| `JOB_DRAFT_UNKNOWN` | `job open --draft ` names a draft the record does not hold. Record the draft with `draft-rig` or name a recorded draft. |
diff --git a/docs/LIVE-REVIEW.md b/docs/LIVE-REVIEW.md
index 9447f63..7260f41 100644
--- a/docs/LIVE-REVIEW.md
+++ b/docs/LIVE-REVIEW.md
@@ -155,9 +155,10 @@ and leaves the open page and outbox unchanged. Its text output identifies the
missing evidence. Run the preparation moves shown by `next` and then
`job open --draft ` to show the prepared draft in the same job.
-A bound writer that reports `JOB_ASK_PENDING` needs the owner to finish the
-current asks. Run `job acts`, ingest with the printed commands, then retry
-the writer to publish into the existing job.
+A bound writer or `job open --question`/`--plan` that reports
+`JOB_ASK_PENDING` needs the owner to finish the current asks. Run
+`job acts --wait`, ingest with the printed commands, then retry the command
+to publish into the existing job.
A bound version writer refuses with `JOB_PUBLICATION_ASK_REQUIRED` before
committing if its candidate would replace an open page without an owner ask.
@@ -421,9 +422,12 @@ Review's code. Run `job open` to retry the ask.
| `plan-approved`, `rigging-interview`, `post-interview` | record plan | `job open --plan` in the approval stage |
| `interview` | record plan, using release-pinned Review 4.9.1 with the interview carrier ([Review #803](https://github.com/rig-c/review/pull/803), issue #800) | `job open --plan` after `interview --check` passes and the displayed plan has steps; ingest `signoff interview --from-review `, then `advance plan-approved` |
-Interview picks use `job open --question `. After ingesting every pick,
-run `interview --check`, then `job open --plan` for the interview signature.
-This record route is supported by release-pinned
+Interview picks use `job open --question `, one question at a time: a
+new publication supersedes the open ask, so publish one question, run
+`job acts --json --wait`, ingest its act, then publish the next. A
+second `--question` while an ask is open refuses `JOB_ASK_PENDING`. After
+ingesting every pick, run `interview --check`, then `job open --plan` for
+the interview signature. This record route is supported by release-pinned
[Review 4.9.1](https://github.com/rig-c/review/tree/v4.9.1), including the
[Review #803](https://github.com/rig-c/review/pull/803) carrier (issue #800).
The record subject is `plan`, with non-empty
diff --git a/src/job-acts.ts b/src/job-acts.ts
index 599b9df..7c5d1e3 100644
--- a/src/job-acts.ts
+++ b/src/job-acts.ts
@@ -1,7 +1,8 @@
/** Writer routing for finalized acts. No event transport or automatic ingestion. */
-import type { ActV3, JobEventV3, JobOwnerHost, JobSelector, PendingAskV3, SourceV3 } from '@rig-c/review/job-host';
+import type { ActV3, JobEventV3, JobOwnerHost, JobSelector, PendingAskV3, RecordResult, SourceV3 } from '@rig-c/review/job-host';
import { isDeepStrictEqual } from 'node:util';
import { asArray, collectItems, collectSignoffs, isObject, loadCollection, type Finding } from './check.ts';
+import { optionFile } from './choices.ts';
import { existsSync, readFileSync } from './check-reads.ts';
import { join } from 'node:path';
import { recordedPartsVerdict } from './parts-verdict-record.ts';
@@ -278,6 +279,15 @@ function actMatchesAsk(act: ActV3, ask: PendingAskV3): boolean {
}
}
+/** A publication target: a package selector, or a record result (`--question` option set or `--plan`). */
+export type JobAskTarget = JobSelector | RecordResult;
+
+function sameTarget(source: SourceV3, target: JobAskTarget): boolean {
+ if ('selector' in source && source.selector) return isDeepStrictEqual(source.selector, target);
+ if ('selection' in source && source.selection) return isDeepStrictEqual(source.selection, target);
+ return false;
+}
+
function sourceTargetInfo(source: SourceV3): { label: string; selector: JobSelector | null; version: number | null } {
if ('selector' in source && source.selector) {
const selector = source.selector;
@@ -328,12 +338,34 @@ function signoffSettlesAsk(project: JsonObject, ask: PendingAskV3): boolean {
});
}
+/**
+ * An owner-chat interview answer (`interview-answer --owner-chat`) creates no Review act.
+ * It settles the interview-picks ask when the question's current answer is bound to the
+ * same option set the ask published: path and sha256, and the set id they resolve to.
+ */
+function ownerChatAnswerSettlesAsk(project: JsonObject, root: string, ask: PendingAskV3): boolean {
+ if (ask.status !== 'pending' || ask.subject.kind !== 'interview-picks') return false;
+ const source = ask.source;
+ if (!('selection' in source) || source.selection?.kind !== 'option-set' || !source.optionSet || !source.optionSetFile) return false;
+ const { questionId, setId } = source.selection;
+ if (ask.subject.questionId !== questionId || ask.subject.setId !== setId || source.optionSet.id !== setId) return false;
+ let item: ReturnType[number] | undefined;
+ try { item = collectItems(project, { collection: loadCollection(root, project) }).find(candidate => candidate.id === questionId); }
+ catch { return false; }
+ if (!item || (item.state.state !== 'user' && item.state.state !== 'delegated') || item.state.answer !== item.raw) return false;
+ const answer = item.state.answer;
+ if (answer.source !== OWNER_CHAT_SOURCE || !isObject(answer.choice)) return false;
+ const binding = answer.choice.set;
+ if (!isObject(binding) || binding.path !== source.optionSetFile.path || binding.sha256 !== source.optionSet.sha256) return false;
+ try { return optionFile(root, binding).set.id === setId; } catch { return false; }
+}
+
export function pendingJobAsksForTarget(
project: JsonObject,
asks: readonly PendingAskV3[],
acts: readonly ActV3[],
root: string,
- target: JobSelector,
+ target: JobAskTarget,
): PendingTargetAsk[] {
// Retired reopens stay visible in job acts and job close, but cannot gate a new target.
const actionableAsks = asks.filter(ask => ask.subject.kind !== 'reopen');
@@ -345,16 +377,16 @@ export function pendingJobAsksForTarget(
for (const ask of actionableAsks) {
if (ingestedActs.some(act => actMatchesAsk(act, ask))) continue;
const info = sourceTargetInfo(ask.source);
- if (info.selector && isDeepStrictEqual(info.selector, target)) continue;
+ if (sameTarget(ask.source, target)) continue;
const hasUnIngestedAct = actionableActs.some(act => unIngestedIds.has(act.actId) && actMatchesAsk(act, ask));
- if (!hasUnIngestedAct && signoffSettlesAsk(project, ask)) continue;
+ if (!hasUnIngestedAct && (signoffSettlesAsk(project, ask) || ownerChatAnswerSettlesAsk(project, root, ask))) continue;
if (!hasUnIngestedAct && info.selector?.kind === 'draft' && target.kind === 'draft') continue;
pending.push({ label: `${askSubjectText(ask.subject)} on ${info.label}`, version: info.version });
}
for (const act of actionableActs) {
if (!unIngestedIds.has(act.actId) || actionableAsks.some(ask => actMatchesAsk(act, ask))) continue;
const info = sourceTargetInfo(act.source);
- if (info.selector && isDeepStrictEqual(info.selector, target)) continue;
+ if (sameTarget(act.source, target)) continue;
pending.push({ label: `${act.kind} (${act.actId}) on ${info.label}`, version: info.version });
}
return pending;
diff --git a/src/job-close.ts b/src/job-close.ts
index 336635d..d244da2 100644
--- a/src/job-close.ts
+++ b/src/job-close.ts
@@ -12,7 +12,7 @@ import {
type JobSelector,
} from '@rig-c/review/job-host';
import { asArray, checkProject } from './check.ts';
-import { pendingJobActs, pendingJobAsksForTarget, readHostActs, readHostActsAndAsks } from './job-acts.ts';
+import { pendingJobActs, pendingJobAsksForTarget, readHostActs, readHostActsAndAsks, shellWord, type JobAskTarget } from './job-acts.ts';
import {
acquireJobLock,
JOB_BINDING_FILE,
@@ -188,7 +188,7 @@ export async function attachCreateJobForClose(
export async function assertNoPendingJobAsk(
root: string,
- target: JobSelector,
+ target: JobAskTarget,
startHost: (options: JobHostOptions) => Promise = startJobHost,
): Promise {
root = realpathSync(root);
@@ -204,26 +204,36 @@ export async function assertNoPendingJobAsk(
throw error;
}
try {
- const project = JSON.parse(readFileSync(join(root, 'project.json'), 'utf8')) as JsonObject;
- const { head, asks, acts } = await readHostActsAndAsks(host);
- const pending = pendingJobAsksForTarget(project, asks, acts, root, target);
- if (pending.length > 0) {
- const listed = pending.map(item => item.label).join('; ');
- const version = pending.find(item => item.version !== null)?.version ?? null;
- const ingest = version === null || pending.some(item => item.version === null)
- ? 'have the owner respond in Review, run rig-create job acts, and run the printed ingest commands'
- : `have the owner give the verdict in Review, run rig-create job acts, and ingest with rig-create review ${version} --from-review (review --from-review )`;
- refuse(
- 'JOB_ASK_PENDING',
- `project.json: bound job ${binding.jobId} holds pending owner ask(s) ${listed} with no ingested act; ${ingest}; re-run this command to publish into the existing job`,
- );
- }
- return head;
+ return await refusePendingJobAsks(root, binding.jobId, host, target);
} finally {
host.stop();
}
}
+/**
+ * Publishing supersedes every pending ask on the job, and an answer to a superseded ask
+ * never becomes an act. Refuse JOB_ASK_PENDING while an ask for another target is still
+ * open, or answered but not ingested. Returns the job's head publication.
+ */
+export async function refusePendingJobAsks(root: string, jobId: string, host: JobOwnerHost, target: JobAskTarget): Promise {
+ const project = JSON.parse(readFileSync(join(root, 'project.json'), 'utf8')) as JsonObject;
+ const { head, asks, acts } = await readHostActsAndAsks(host);
+ const pending = pendingJobAsksForTarget(project, asks, acts, root, target);
+ if (pending.length > 0) {
+ const listed = pending.map(item => item.label).join('; ');
+ const version = pending.find(item => item.version !== null)?.version ?? null;
+ const wait = `rig-create job acts ${shellWord(root)} --wait`;
+ const ingest = version === null || pending.some(item => item.version === null)
+ ? `have the owner respond in Review, run ${wait}, and run the printed ingest commands`
+ : `have the owner give the verdict in Review, run ${wait}, and ingest with rig-create review ${version} --from-review (review --from-review )`;
+ refuse(
+ 'JOB_ASK_PENDING',
+ `project.json: bound job ${jobId} holds pending owner ask(s) ${listed} with no ingested act; ${ingest}; re-run this command to publish into the existing job`,
+ );
+ }
+ return head;
+}
+
export async function closeCreateJob(
root: string,
startHost: (options: JobHostOptions) => Promise = startJobHost,
diff --git a/src/job-host.ts b/src/job-host.ts
index 80c05de..f0d7e54 100644
--- a/src/job-host.ts
+++ b/src/job-host.ts
@@ -9,7 +9,7 @@ import { Refusal, refuse } from './refusal.ts';
import { liveManifestPath, draftPackageIdentity, inspectDraftPublication, currentJobIdentity, partsEnumerator, prepareDraftManifest, prepareLiveManifest, publicationFile, publicationSelector, publishedDraft, readPublished, readRecordPublished, riggingDraftPartsChange } from './job-publication.ts';
import { acknowledgePublication, acquireJobLock, assertJobIdentity, enqueuePublication, ensureJobPrivateIgnores, failPublication, JOB_BINDING_FILE, jobHash, jobHostStateRoot, pendingPublications, privateDirectory, publicationVersionHash, readAcknowledgedPublication, readWriterBinding, reconcilePublication, refuseJobIdentityMismatch, writePrivateJson, isRecordResult, type PublicationResult, type JobIdentity, type PendingPublication, type WriterBinding, type PublicationSubject } from './job-outbox.ts';
import { draftPublicationResult } from './job-writer.ts';
-import { attachCreateJobForClose } from './job-close.ts';
+import { attachCreateJobForClose, refusePendingJobAsks } from './job-close.ts';
import { agentCall, ingestedJobActs, ingestedSummary, jobEvents, pendingJobActs, readHostActsAndAsks, shellWord, type AgentReply, type IngestedJobAct, type PendingJobAct } from './job-acts.ts';
import { checkReviewPackages } from './review-package.ts';
import { reviewVerdictSignable } from './signable.ts';
@@ -503,7 +503,7 @@ function selectorLabel(selector: JobSelector): string {
}
/** Resolve only an explicitly requested current record subject, before opening a host. */
-export function requestedRecordResult(root: string, question?: string, plan = false, now = Date.now()): PublicationResult | undefined {
+export function requestedRecordResult(root: string, question?: string, plan = false, now = Date.now()): RecordPublicationRequestResult | undefined {
return requestedRecordPublication(root, question, plan, now)?.result;
}
@@ -550,6 +550,8 @@ export async function openRecordPublication(root: string, host: JobOwnerHost, qu
} else {
const binding = readWriterBinding(root);
if (!binding || binding.jobId !== host.session.jobId) refuse('JOB_BINDING_INVALID', 'project.json: open the writer-owned job before publishing');
+ // A new publication supersedes the job's pending asks: one question at a time (#737).
+ await refusePendingJobAsks(root, binding.jobId, host, result);
enqueuePublication(root, binding, result);
({ outcomes } = await reconcileLocked(root, publishPending));
}
diff --git a/src/job-runtime.ts b/src/job-runtime.ts
index a9c9116..9cc0235 100644
--- a/src/job-runtime.ts
+++ b/src/job-runtime.ts
@@ -78,7 +78,9 @@ async function run(): Promise {
case 'close': await closeCreateJob(root, undefined, input.retireRefused, input.discardActs, input.now); console.log('job: closed'); break;
case 'open': {
if (!input.reviewer || !input.role) refuse('JOB_BINDING_INVALID', 'project.json: job open needs --reviewer and --role owner|delegate');
- requestedRecordResult(root, input.question, input.plan, input.now);
+ const record = requestedRecordResult(root, input.question, input.plan, input.now);
+ // Refuse before attaching or writing; openRecordPublication repeats it under the job lock (#737).
+ if (record) await assertNoPendingJobAsk(root, record);
const rig = assertRequestedRig(root, input.rig, input.draft);
const { bytes, draftId } = assertRequestedDraft(root, input.draft, input.now);
if (rig || draftId !== undefined) requireOwnerLanguage(JSON.parse(bytes.toString('utf8')) as JsonObject);
diff --git a/src/next.ts b/src/next.ts
index 2962c27..8f1eebf 100644
--- a/src/next.ts
+++ b/src/next.ts
@@ -454,8 +454,9 @@ function ownerChatSignoffCommand(dir: string, project: JsonObject, act: NextRevi
return `rig-create ${writer} ${shellWord(dir)}${version} ${OWNER_CHAT_COMMAND_FLAGS}`;
}
-/** The person acts in Review; the agent only hosts and ingests its exported act. */
-function reviewCommands(dir: string, project: JsonObject, move: NextMove): NextMove[] {
+/** The person acts in Review; the agent only hosts and ingests its exported act.
+ * A job holds one open interview question: `asked` names the earlier question in this report. */
+function reviewCommands(dir: string, project: JsonObject, move: NextMove, asked: { question?: string } = {}): NextMove[] {
const act = move.review_act;
if (move.role !== 'human' || move.unanswered_by_record || move.field === 'pauses' || !act) return [move];
let selector: string;
@@ -500,9 +501,17 @@ function reviewCommands(dir: string, project: JsonObject, move: NextMove): NextM
} catch { /* The check's named option-file refusal supplies the repair route. */ }
}
}
+ let publish = 'publish this Review page; run the first open in the background and share its URL once; later opens publish into the running host and exit';
+ if (act.kind === 'interview-picks' && act.question_id) {
+ const earlier = asked.question;
+ asked.question ??= act.question_id;
+ publish = earlier === undefined
+ ? `${publish}; one question at a time: publish it, wait with job acts --json --wait, ingest, then publish the next question`
+ : `only after the ${earlier} act is ingested: one question at a time, so publish this one next, wait with job acts --json --wait and ingest (an open earlier question refuses JOB_ASK_PENDING)`;
+ }
return [
...chatMoves,
- agent(`rig-create job open ${root} ${selector} --reviewer '' --role owner`, 'publish this Review page; run the first open in the background and share its URL once; later opens publish into the running host and exit'),
+ agent(`rig-create job open ${root} ${selector} --reviewer '' --role owner`, publish),
move,
agent(`rig-create job acts ${root} --json --wait`, `wait in the background for the person to submit in Review, then use the matching actId below${act.kind === 'parts-verdict' ? '; approval also records the prepared parts-review signature' : act.stage === 'parts-review' ? '; run its reported legacy signoff preconditions before ingestion' : ''}`),
agent(`rig-create ${writer} ${root} --from-review ''`, 'ingest the matching exported Review act; never supply the human answer or words'),
@@ -2231,11 +2240,12 @@ export function nextProject(projectDirArg: string, now: number = Date.now()): Ne
});
}
+ const asked: { question?: string } = {};
const runnableMoves = moves.flatMap(move => {
if (move.review_act && move.review_act.stage !== effectiveStage) return [move];
if (move.review_act?.stage === 'direction-review' && move.review_act.kind === 'signoff'
&& moves.some(other => other.review_act?.stage === 'direction-review' && other.review_act.kind === 'review-verdict')) return [move];
- return reviewCommands(dir, project, move);
+ return reviewCommands(dir, project, move, asked);
});
return {
diff --git a/tests/job-acts.test.ts b/tests/job-acts.test.ts
index 9c40107..68c0a8d 100644
--- a/tests/job-acts.test.ts
+++ b/tests/job-acts.test.ts
@@ -10,14 +10,14 @@ import { plantLegacyReopen, fixture, retainSignoffs, arr, obj } from './fixtures
import { stageIndex } from '../src/stages.ts';
import { recordPartsReceipt } from './parts-receipt-fixture.ts';
import { nextCommand, nextProject } from '../src/next.ts';
-import { pendingJobActs, jobActsText, type PendingJobAct } from '../src/job-acts.ts';
+import { pendingJobActs, jobActsText, shellWord, type PendingJobAct } from '../src/job-acts.ts';
import { JOB_BINDING_FILE, writePrivateJson, jobHash, jobHostStateRoot, jobPrivateRoot, pendingPublications, readWriterBinding, type AcknowledgedPublication } from '../src/job-outbox.ts';
import { jobRuntimeExecArgv, prepareVersionIntent } from '../src/job-writer.ts';
import { listCreateJobActs } from '../src/job-host.ts';
import { assertNoPendingJobAsk } from '../src/job-close.ts';
import { currentJobIdentity } from '../src/job-publication.ts';
import { startJobHost, type ActV3, type JobOwnerHost, type JobHostOptions } from '@rig-c/review/job-host';
-import type { JsonObject } from '../src/templates.ts';
+import type { Json, JsonObject } from '../src/templates.ts';
import { testClock } from './clock.ts';
import { EXAMPLE_NOW, EXAMPLE_REOPEN_AT } from '../scripts/example-time.ts';
import { clockedCli } from './helpers.ts';
@@ -360,7 +360,7 @@ test.each([false, true])('agent next pagination is shared and read failures rema
});
-async function openMotionQuestion() {
+function riggingInterviewRoot(): string {
testClock.set(Date.now());
const root = realpathSync(fixture(project => {
project.stage = 'rigging-interview'; project.versions = []; project.scenes = []; delete project.direction_contract;
@@ -370,17 +370,30 @@ async function openMotionQuestion() {
for (const step of arr(obj(project.plan).steps).map(obj)) if (!['seethrough', 'assemble'].includes(String(step.id))) step.status = 'pending';
}, 'example-project.json'));
roots.push(root);
- const project = read(root); const item = collectItems(project, { collection: null }).find(item => item.id === 'motion')!;
+ return root;
+}
+
+/** Register a fresh pending option set for one rigging question; returns the page value that answers it. */
+async function registerQuestion(root: string, question: string) {
+ const project = read(root); const item = collectItems(project, { collection: null }).find(item => item.id === question)!;
const retained = obj(obj(item.raw).choice).set as JsonObject;
const set = JSON.parse(readFileSync(join(root, String(retained.path)), 'utf8')) as JsonObject;
- set.id = 'pending-acts-motion'; set.drafted_at = new Date(testClock.now() - 1000).toISOString();
+ set.id = `pending-acts-${question}`; set.drafted_at = new Date(testClock.now() - 1000).toISOString();
set.context = optionContext(project, 'rigging-interview', testClock.now() - 1000, root);
- const path = 'evidence/interview/pending-acts-motion.json';
+ const path = `evidence/interview/pending-acts-${question}.json`;
writeFileSync(join(root, path), JSON.stringify(set, null, 2) + '\n');
- expectExit0(await cli(root, ['interview-options', 'motion', root, '--file', path]));
- const opening = await open(root, ['--question', 'motion']); const view = await page(root, opening.url, 1);
+ expectExit0(await cli(root, ['interview-options', question, root, '--file', path]));
const selections = (set.asks as JsonObject[]).map(ask => ({ itemId: ask.id, optionId: obj((ask.options as JsonObject[])[0]).id, otherText: null }));
- return { root, url: opening.url, view, value: { questionId: 'motion', selections, note: WORDS } };
+ return { questionId: question, selections, note: WORDS };
+}
+
+async function openMotionQuestion(also: string[] = []) {
+ const root = riggingInterviewRoot();
+ const value = await registerQuestion(root, 'motion');
+ const others = [];
+ for (const question of also) others.push(await registerQuestion(root, question));
+ const opening = await open(root, ['--question', 'motion']); const view = await page(root, opening.url, 1);
+ return { root, url: opening.url, view, value, others };
}
test('merged record-mode host lists finalized picks and its printed writer command ingests them', async () => {
@@ -413,6 +426,86 @@ test('merged record-mode host lists finalized picks and its printed writer comma
expectExit0(await cli(root, ['interview', '--check', root]));
}, 30_000);
+test('#737 a second --question refuses JOB_ASK_PENDING while the first ask is open, keeps its answer, and publishes after ingest', async () => {
+ const { root, url, view, value, others: [bones] } = await openMotionQuestion(['bones']);
+ // Re-opening the pending question itself is not a second ask.
+ const same = await cli(root, ['job', 'open', root, '--reviewer', 'synthetic-owner', '--role', 'owner', '--question', 'motion']);
+ expectExit0(same);
+ expect(same.stdout).toContain('job: option-set motion/pending-acts-motion already published');
+ const before = snapshot(root);
+ const second = await cli(root, ['job', 'open', root, '--reviewer', 'synthetic-owner', '--role', 'owner', '--question', 'bones']);
+ expect(second.exit).toBe(1);
+ expect(second.stderr).toMatch(/^JOB_ASK_PENDING: /);
+ expect(second.stderr).toContain('interview-picks motion/pending-acts-motion');
+ expect(second.stderr).toContain(`rig-create job acts ${shellWord(root)} --wait`);
+ expect(snapshot(root)).toEqual(before);
+
+ // The first page still holds its ask: the owner's answer arrives as an act.
+ const act = await view.act('interview-picks', 'interview-picks', value);
+ const unIngested = await cli(root, ['job', 'open', root, '--reviewer', 'synthetic-owner', '--role', 'owner', '--question', 'bones']);
+ expect(unIngested.exit).toBe(1);
+ expect(unIngested.stderr).toMatch(/^JOB_ASK_PENDING: /);
+ expect(snapshot(root)).toEqual(before);
+ const listed = await cli(root, ['job', 'acts', root, '--json', '--wait']); expectExit0(listed);
+ const row = JSON.parse(listed.stdout).acts[0] as PendingJobAct;
+ expect(row).toMatchObject({ actId: act.actId, kind: 'interview-picks' });
+ await executePrinted(root, row.command!);
+
+ const next = await cli(root, ['job', 'open', root, '--reviewer', 'synthetic-owner', '--role', 'owner', '--question', 'bones']);
+ expectExit0(next);
+ expect(next.stdout).toContain('job: option-set bones/pending-acts-bones published');
+ const bonesView = await page(root, url, 1);
+ const bonesAct = await bonesView.act('interview-picks', 'interview-picks', bones!);
+ const after = JSON.parse((await cli(root, ['job', 'acts', root, '--json'])).stdout).acts as PendingJobAct[];
+ expect(after.map(row => row.actId)).toEqual([String(bonesAct.actId)]);
+}, 60_000);
+
+/** Record the owner's chat answer for the question's registered pending set, as AGENTS.md goal 3 allows. */
+async function ownerChatAnswer(root: string, value: { questionId: string; selections: { itemId: Json; optionId: Json }[] }) {
+ const binding = obj(collectItems(read(root), { collection: null }).find(item => item.id === value.questionId)!.record.pending_options);
+ const words = join(root, `owner-words-${value.questionId}.txt`);
+ writeFileSync(words, 'Synthetic owner chat words.\n');
+ expectExit0(await cli(root, ['interview-answer', value.questionId, root, '--set', String(binding.path), '--sha256', String(binding.sha256),
+ '--by', 'user', '--owner-chat', words, '--said-at', new Date(testClock.now() - 500).toISOString(), '--relayed-by', 'synthetic-operator',
+ ...value.selections.flatMap(row => ['--pick', `${String(row.itemId)}=${String(row.optionId)}`])]));
+}
+
+test('#737 an owner-chat answer for the published set settles its ask, so the next --question publishes', async () => {
+ const { root, value } = await openMotionQuestion(['bones']);
+ await ownerChatAnswer(root, value);
+ const next = await cli(root, ['job', 'open', root, '--reviewer', 'synthetic-owner', '--role', 'owner', '--question', 'bones']);
+ expectExit0(next);
+ expect(next.stdout).toContain('job: option-set bones/pending-acts-bones published');
+}, 60_000);
+
+test('#737 an owner-chat answer bound to a different set leaves the published ask open', async () => {
+ const { root } = await openMotionQuestion(['bones']);
+ // Register a second motion set after the first was published, then answer that one in chat.
+ const project = read(root); const item = collectItems(project, { collection: null }).find(item => item.id === 'motion')!;
+ const shown = JSON.parse(readFileSync(join(root, String(obj(item.record.pending_options).path)), 'utf8')) as JsonObject;
+ shown.id = 'pending-acts-motion-chat'; shown.drafted_at = new Date(testClock.now() - 900).toISOString();
+ const path = 'evidence/interview/pending-acts-motion-chat.json';
+ writeFileSync(join(root, path), JSON.stringify(shown, null, 2) + '\n');
+ expectExit0(await cli(root, ['interview-options', 'motion', root, '--file', path]));
+ const selections = (shown.asks as JsonObject[]).map(ask => ({ itemId: ask.id, optionId: obj((ask.options as JsonObject[])[0]).id }));
+ await ownerChatAnswer(root, { questionId: 'motion', selections });
+ const before = snapshot(root);
+ const refused = await cli(root, ['job', 'open', root, '--reviewer', 'synthetic-owner', '--role', 'owner', '--question', 'bones']);
+ expect(refused.exit).toBe(1);
+ expect(refused.stderr).toMatch(/^JOB_ASK_PENDING: .*interview-picks motion\/pending-acts-motion on /);
+ expect(snapshot(root)).toEqual(before);
+}, 60_000);
+
+test('#737 next at the rigging interview names the one-question-at-a-time loop with job acts --wait', async () => {
+ const root = riggingInterviewRoot();
+ for (const question of ['motion', 'bones']) await registerQuestion(root, question);
+ const opens = nextProject(root).moves.filter(move => move.role === 'agent' && (move.command ?? '').includes('job open') && (move.command ?? '').includes('--question'));
+ expect(opens.map(move => /--question (\S+)/.exec(move.command ?? '')![1])).toEqual(['bones', 'motion']);
+ expect(opens[0]!.act).toContain('one question at a time: publish it, wait with job acts --json --wait, ingest, then publish the next question');
+ expect(opens[1]!.act).toMatch(/^only after the bones act is ingested: one question at a time/);
+ expect(opens[1]!.act).toContain('JOB_ASK_PENDING');
+});
+
test('#698 wait wakes on a finalized pick and reuses the strict attach without timer re-listing', async () => {
const { root, url, view, value } = await openMotionQuestion();
const before = readFileSync(join(root, 'project.json'));