Skip to content

Commit 4f03143

Browse files
authored
Merge pull request #10201 from loopx-project/codex/stable-settlement-detail-20261205
Keep native settlement details reachable on a stable cadence
2 parents a160049 + 115a802 commit 4f03143

6 files changed

Lines changed: 80 additions & 47 deletions

File tree

‎loopx/cli_commands/quota_capture.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,10 @@ def _present_work_opening(view: dict[str, Any], *, reader_argv: list[str] | None
299299
reference = model_context_reference(view, reader_argv=reader_argv)
300300
if detail and reference.get("schema_version") == "context_capture_navigation_v1":
301301
candidate = {**reference, "settlement_detail_command": detail, "instruction": reference["instruction"] + (
302-
" After the required work reads, use settlement_detail_command for Vision authoring, optional attachment "
303-
"details and the matching scheduler hint. Keep the ordered settlement steps from the initial read.")}
302+
" After the required work reads, use settlement_detail_command for Vision authoring and "
303+
"the current scheduler action with any required acknowledgement. Keep the initial ordered settlement steps. "
304+
"Before using a deferred attachment, read its complete details from its supporting_material_pointer "
305+
"through context_details, or from its original plan field when no pointer is given.")}
304306
_, budget = native_context_page_budget()
305307
if len(_native_output_bytes(candidate)) <= min(budget, output_limit if output_limit is not None else budget):
306308
return candidate

‎loopx/control_plane/quota/progressive_context.ts‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,16 +372,28 @@ export function pendingInboxSettlementSelectors(context: JsonObject): string[] |
372372
const appPath = ["scheduler_hint", "app_automation"];
373373
const app = jsonObject(at(context, appPath)), ack = jsonObject(app?.ack_hint), args = jsonObject(ack?.args);
374374
const binding = jsonObject(ack?.route_binding), identity = jsonObject(plan.identity)!;
375-
if (app?.host_action !== "ack_observed_rrule_without_update"
376-
|| app.host_action_contract !== "quota_scheduler_ack_from_matching_host_observation"
377-
|| ack?.schema_version !== "app_automation_scheduler_ack_hint_v0" || ack.after !== "matching_host_rrule_observed"
378-
|| binding?.registry_bound !== true || binding.runtime_root_bound !== true || binding.turn_instance_bound !== true
379-
|| ack.execute !== true || ack.no_spend !== true || args?.host_match_observed !== true
380-
|| args.goal_id !== identity.goal_id || args.agent_id !== identity.agent_id
381-
|| args.turn_instance_id !== identity.turn_instance_id) return undefined;
382-
const attachments = [...vision.path.slice(0, -1), "optional_attachments"];
383-
return [pointer(vision.path), ...(at(context, attachments) !== undefined ? [pointer(attachments)] : []),
384-
pointer([...appPath, "host_action"]), pointer([...appPath, "ack_hint"])];
375+
const backoff = jsonObject(app?.stateful_backoff);
376+
const settledSchedule = app?.host_surface === "codex_app" && app.host_action === "none"
377+
&& app.host_action_contract === "skip_automation_update_when_apply_needed_false"
378+
&& backoff?.schema_version === "app_automation_stateful_backoff_v0"
379+
&& backoff.apply_needed === false && backoff.ack_needed === false
380+
&& app.ack_hint == null && app.failure_hint == null && app.fallback_hint == null;
381+
const boundAck = app?.host_action === "ack_observed_rrule_without_update"
382+
&& app.host_action_contract === "quota_scheduler_ack_from_matching_host_observation"
383+
&& ack?.schema_version === "app_automation_scheduler_ack_hint_v0" && ack.after === "matching_host_rrule_observed"
384+
&& binding?.registry_bound === true && binding.runtime_root_bound === true && binding.turn_instance_bound === true
385+
&& ack.execute === true && ack.no_spend === true && args?.host_match_observed === true
386+
&& args.goal_id === identity.goal_id && args.agent_id === identity.agent_id
387+
&& args.turn_instance_id === identity.turn_instance_id;
388+
if (!settledSchedule && !boundAck) return undefined;
389+
const attachmentsPath = [...vision.path.slice(0, -1), "optional_attachments"];
390+
const attachments = at(context, attachmentsPath);
391+
// The exact built-in optional attachment has its own supporting route.
392+
// Unknown or required attachments keep their existing disclosure.
393+
const includeAttachments = attachments !== undefined
394+
&& !isDeepStrictEqual(attachments, [exploreResultWritebackAffordance()]);
395+
return [pointer(vision.path), ...(includeAttachments ? [pointer(attachmentsPath)] : []),
396+
pointer([...appPath, "host_action"]), ...(boundAck ? [pointer([...appPath, "ack_hint"])] : [])];
385397
}
386398

387399
function deferReadySettlementAuthoring(payload: JsonObject, deferred: JsonObject[],

‎loopx/control_plane/quota/settlement_plan.ts‎

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,21 @@ export function turnScopedCliSettlementPlan(params: JsonObject): SettlementPlan
120120
const scales = requireStringArray(params.delivery_batch_scale_choices, "delivery_batch_scale_choices");
121121
requireNonEmptyString(scales.map(scale => requireNonEmptyString(scale, "delivery batch scale")).join("|"),
122122
"delivery batch scale choices");
123-
const inputHint = " Fill placeholders from the actual result: classification is a descriptive label; " +
123+
const inputHint = " Fill placeholders from this Turn's result: descriptive classification; " +
124124
"scale=" + scales.join("|") + "; outcome=" + MATERIAL_DELIVERY_OUTCOMES.join("|") + ". " +
125-
"surface_only cannot settle this Turn. Do not relabel preparation-only work as progress; " +
126-
"continue authorized work within existing limits or report a genuine typed blocker. " +
127-
"Set --delivery-boundary " + DELIVERY_BOUNDARIES.join("|") + " for the applicable case above. " +
128-
"Add typed progress flags only when this Turn's evidence supports the observation. " +
129-
"Use --progress-result-class " + PROGRESS_RESULT_CLASSES.join("|") +
130-
". For no_followup or exploration_exhausted, pass --progress-coverage-scope-id from verified scope coverage; " +
131-
"exploration_exhausted also needs --progress-coverage-complete. For a final Todo, terminal closeout follows spend " +
132-
"under its own plan step. A typed no_followup requires scope coverage beyond Todo completion. " +
133-
"For blocked outcome_gap, --progress-work-item-id must match this plan's Todo/obligation id " +
134-
"and --progress-blocker-id names the blocker. Repeat --progress-evidence-id for observed evidence identifiers. " +
135-
"Use opaque public-safe IDs of 1-128 characters, starting with an ASCII letter/digit, then letters/digits or ._:/- " +
136-
"(e.g. evidence:validation-1); an ID does not upload a file. " +
137-
"Use --agent-vision-json <file> for the material vision packet; " +
138-
"--vision-unchanged-reason <reason> only reuses an already evidence-linked vision. " +
139-
"These are authoring choices, not defaults, proof of progress or new requirements.";
125+
"surface_only cannot settle. Do not relabel preparation-only work as progress. " +
126+
"Continue authorized work within its limits or report the actual typed blocker. " +
127+
"Set --delivery-boundary " + DELIVERY_BOUNDARIES.join("|") + " for the applicable path. " +
128+
"Use typed progress flags only when this Turn's evidence supports them. " +
129+
"--progress-result-class " + PROGRESS_RESULT_CLASSES.join("|") + ". " +
130+
"For no_followup or exploration_exhausted, pass --progress-coverage-scope-id from verified scope coverage. " +
131+
"no_followup requires coverage beyond Todo completion; exploration_exhausted also needs --progress-coverage-complete. " +
132+
"For a final Todo, terminal closeout follows spend under its own step. " +
133+
"For blocked outcome_gap, match --progress-work-item-id to this plan's Todo/obligation and name the blocker with --progress-blocker-id. " +
134+
"Repeat --progress-evidence-id for observed public-safe opaque IDs, 1-128 ASCII characters: start with a letter/digit, " +
135+
"then use letters/digits or ._:/- (e.g. evidence:validation-1). IDs do not upload files. " +
136+
"Use --agent-vision-json <file> for material Vision. --vision-unchanged-reason <reason> only reuses an evidence-linked Vision. " +
137+
"Flags supply no defaults, proof of progress or new requirements.";
140138
const parsedGoalRef = params.goal_ref === undefined
141139
? null
142140
: parseExactGoalRef(params.goal_ref);
@@ -185,16 +183,14 @@ export function turnScopedCliSettlementPlan(params: JsonObject): SettlementPlan
185183
validation.command_condition = "todo_deliverable_complete";
186184
const claimHint = managedClaim ? "Before task execution, prepare it with ordinary Todo claim: `" +
187185
requireNonEmptyString(commands.todo_claim, "todo_claim") +
188-
"`. Reuse an already accepted current claim or explicit lease proof; keep the original " +
189-
"claim_operation_id for managed progress/completion retries. claimed_by alone is not an execution lease. " +
190-
"An expired, released or replaced execution requires normal ownership recovery; " +
191-
"this plan neither acquires nor renews execution. " : "";
186+
"`. Reuse an accepted current claim or explicit lease proof. Keep the original claim_operation_id for managed progress/completion retries. " +
187+
"claimed_by alone does not confer a lease. Recover an expired, released or replaced lease through normal ownership recovery. " +
188+
"This plan cannot acquire or renew execution. " : "";
192189
validation.precondition = claimHint + "validate the original Todo deliverable; when complete, run ordinary Todo completion " +
193190
"with its original declaration and current lease before writeback/spend. Use --evidence for " +
194191
"an artifact pointer; --result-file requires approved Goal acceptance criteria bound to this Todo, " +
195-
"not merely a Todo validator. Link known follow-up work with --successor-todo-id <existing-id>. No invented successor " +
196-
"or --no-follow-up is required. Todo done does not settle the Turn. " +
197-
"Keep an unfinished Todo open with its original declaration.";
192+
"not merely a Todo validator. Link a known successor with --successor-todo-id <existing-id>. No invented successor or --no-follow-up is required. " +
193+
"Todo done does not settle the Turn. Keep an unfinished Todo open with its original declaration.";
198194
}
199195
const steps: SettlementStep[] = [
200196
validation,
@@ -209,11 +205,10 @@ export function turnScopedCliSettlementPlan(params: JsonObject): SettlementPlan
209205
? "semantic_closeout_command_template with --agent-vision-json"
210206
: "--delivery-boundary semantic_closeout") +
211207
" for new decision evidence, route change or Todo completion. " +
212-
"Bind new evidence produced or obtained by this admitted work to its artifact/input in fresh Vision/path_delta " +
213-
"with --agent-vision-json, including continue/no_change when retaining the route. " +
208+
"Bind new evidence from this admitted work to its artifact/input in fresh Vision/path_delta with --agent-vision-json, " +
209+
"including continue/no_change when retaining the route. " +
214210
"Use this same Turn; no new guard or binding. Follow the remaining plan, then yield for freshly guarded continuation. ") +
215-
"Prior-feedback readback, bookkeeping and deterministic repetition without new information are context, " +
216-
"not this Turn's progress; use them to advance the task first. " +
211+
"Use prior-feedback readback, bookkeeping and deterministic repetition without new information to advance work before claiming progress. " +
217212
(!inFlight && identity.binding_kind === "todo" ? VISION_MATERIAL_CLOSEOUT_HINT + " " : "") +
218213
"Route elimination needs evidence; failure alone is not progress. outcome_gap requires " +
219214
"semantic_closeout plus blocked + blocker/evidence IDs and continuation checks." + monitorGuidance + inputHint,

‎tests/control_plane/test_codex_context_resume.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,23 @@ def command(args, event=None):
294294
context_directory=str(tmp_path), initial_read_plan=prepared.initial_read_plan))
295295
first_command = shlex.split(view["first_read_command"])
296296
opening = command(first_command[first_command.index("context-read"):])
297+
assert opening["ok"]
297298
delivered_chunks = bytearray(opening["content"].encode("utf-8"))
298299
current_page = opening
299300
while not current_page["eof"]:
300301
next_argv = shlex.split(current_page["next_command"])
301302
current_page = command(next_argv[next_argv.index("context-read"):])
302-
assert current_page["ok"] and current_page["offset"] == len(delivered_chunks)
303+
assert current_page["ok"] and current_page["reference_file"] == opening["reference_file"]
304+
assert current_page["total_bytes"] == opening["total_bytes"]
305+
assert current_page["offset"] == len(delivered_chunks)
303306
delivered_chunks.extend(current_page["content"].encode("utf-8"))
304307
assert len(delivered_chunks) == opening["total_bytes"]
305308
delivered_text = delivered_chunks.decode("utf-8")
306-
assert (opening["eof"] or not retained) and payload["goal_boundary"]["stop_condition"] in delivered_text
309+
assert payload["goal_boundary"]["stop_condition"] in opening["content"]
307310
assert (address in opening.get("previously_delivered_fields", [])) is retained
308311
assert (narrative in delivered_text) is not retained
309312
if retained:
310-
assert opening["total_bytes"] < len(narrative.encode("utf-8"))
313+
assert opening["eof"] and opening["total_bytes"] < len(narrative.encode("utf-8"))
311314
else:
312315
assert opening["total_bytes"] > len(narrative.encode("utf-8"))
313316

‎tests/control_plane_ts/progressive_context.test.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,29 @@ test("ready work defers exact settlement authoring to the original capture", ()
276276
{kind: "operator_inbox", capability_id: "manager-context", ordering: "before_work",
277277
source: "turn_start_capability_hook", hook_id: "manager.context_inbox", command: "read inbox"}]}}};
278278
const detailRoot = "/interaction_contract/cli_channel/settlement_plan/ordered_steps/0";
279-
assert.deepEqual(pendingInboxSettlementSelectors(pending), [detailRoot + "/vision_authoring",
280-
detailRoot + "/optional_attachments", "/scheduler_hint/app_automation/host_action", "/scheduler_hint/app_automation/ack_hint"]);
279+
const steady = {host_surface: "codex_app", host_action: "none",
280+
host_action_contract: "skip_automation_update_when_apply_needed_false",
281+
stateful_backoff: {schema_version: "app_automation_stateful_backoff_v0", apply_needed: false, ack_needed: false}};
282+
const hostAction = "/scheduler_hint/app_automation/host_action";
283+
const ackFields = [hostAction, "/scheduler_hint/app_automation/ack_hint"];
284+
const visionField = detailRoot + "/vision_authoring";
285+
const attachmentField = detailRoot + "/optional_attachments";
286+
const pendingCli = pending.interaction_contract.cli_channel;
287+
for (const [app, schedulerFields] of [[observed, ackFields], [steady, [hostAction]]] as const) {
288+
const current = {...pending, scheduler_hint: {app_automation: app}};
289+
assert.deepEqual(pendingInboxSettlementSelectors(current), [visionField, ...schedulerFields]);
290+
for (const optional_attachments of [[{...explore, required: true}], [{...explore, future_obligation: "Read before use."}]]) {
291+
const otherStep = {...step, optional_attachments};
292+
const other = {...current, interaction_contract: {...current.interaction_contract, cli_channel: {
293+
...pendingCli, settlement_plan: {...pendingCli.settlement_plan, ordered_steps: [otherStep]},
294+
}}};
295+
assert.deepEqual(pendingInboxSettlementSelectors(other), [visionField, attachmentField, ...schedulerFields]);
296+
}
297+
}
298+
for (const app of [{...steady, host_surface: "other"}, {...steady, ack_hint: observed.ack_hint},
299+
{...steady, stateful_backoff: {...steady.stateful_backoff, apply_needed: true}},
300+
{...steady, stateful_backoff: {...steady.stateful_backoff, ack_needed: true}}])
301+
assert.equal(pendingInboxSettlementSelectors({...pending, scheduler_hint: {app_automation: app}}), undefined);
281302
for (const changed of [payload, {...pending, autonomous_replan_obligation: {}},
282303
{...pending, interaction_contract: payload.interaction_contract},
283304
{...pending, selected_todo: {todo_id: "different"}},

‎tests/control_plane_ts/quota_settlement_plan.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ test("ordinary completion is conditional on deliverable acceptance, not Turn acc
144144
assert.match(plan.steps[0].precondition, /Todo done does not settle the Turn/);
145145
assert.match(plan.steps[0].precondition, /unfinished Todo open with its original declaration/);
146146
assert.doesNotMatch(plan.steps[0].precondition, /Prior-feedback|semantic_closeout/);
147-
assert.match(plan.steps[1].precondition, /new evidence produced or obtained by this admitted work.*artifact\/input/);
148-
assert.match(plan.steps[1].precondition, /Prior-feedback readback.*deterministic repetition without new information are context/);
149-
assert.match(plan.steps[1].precondition, /not this Turn's progress; use them to advance the task first/);
147+
assert.match(plan.steps[1].precondition, /new evidence from this admitted work.*artifact\/input/);
148+
assert.match(plan.steps[1].precondition,
149+
/prior-feedback readback, bookkeeping and deterministic repetition without new information to advance work before claiming progress/);
150150
assert.match(plan.steps[1].precondition, /Follow the remaining plan.*yield for freshly guarded continuation/);
151151
assert.doesNotMatch(plan.steps[0].precondition, /spend before the next decision/);
152152
assert.match(plan.steps[1].precondition, /--agent-vision-json/);

0 commit comments

Comments
 (0)