Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion benchmark/runtime/RUNTIME.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ require separate run evidence.
For an empty planning frontier, the model can save the same requirement
declaration and ordered advancement Todos in one JSON proposal and invoke
`python -m benchmark.runtime.planning_batch PROPOSAL.json` during the planning
wake. Use the checkpoint's exact input digest and acceptance provider revision.
wake (`--schema` prints the full JSON proposal schema and UTF-16 code unit field limits). Use the
checkpoint's exact input digest and acceptance provider revision.
The command declares requirements, writes Todos and binds their actual IDs
through public LoopX operations. Each write has its own receipt. If the command
is interrupted, reuse the unchanged proposal so the original effects can be
Expand Down
354 changes: 313 additions & 41 deletions benchmark/runtime/planning_batch.py

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions loopx/cli_commands/goal_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def register_goal_acceptance_command(subparsers: Any, add_format: Any) -> None:
owner input nor adoption; only an applied objective revision needs adoption.
Authority, budgets, stops and existing gated actions remain binding.

Outcome declaration (refine):
--document schema: {"outcome_id":"<opaque-id>", "owner_agent_id":"AGENT", "objective":"...", "requirements":[{"id":"<opaque-id>", "description":"..."}], "source":{"ref":"<opaque-id>", "summary":"..."}}
Optional refine fields: "todo_ids":["todo_..."], "review":[...], "review_patch":[...], "storage_format":"records".
Opaque IDs (outcome_id, requirements[*].id, source.ref): <=128 UTF-16 code units matching ^[A-Za-z0-9][A-Za-z0-9_.:@-]*$ (no '/' paths or spaces).
Limits (UTF-16 code units): objective <=1024, requirements <=32 items (description <=2000 each), source.summary <=512.

Long-horizon requirements (refine):
Keep the same outcome_id. Add "storage_format":"records" to the document to
preview/commit lossless record storage with the next authorized refinement.
Expand Down
50 changes: 41 additions & 9 deletions loopx/control_plane/goals/outcome_requirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,58 @@ interface OutcomeState extends JsonObject {
* Caller values and arbitrary provider/IO errors must never use this marker. */
export class GoalOutcomeValidationError extends AuthorityStoreProtocolError {}

const OPAQUE_ID_MAX = 128;
const OPAQUE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_.:@-]*$/;
const OPAQUE_ID_HINT = "ASCII letters/digits and . _ : @ -, no '/' paths or spaces";

function requireValue(condition: unknown, reason: string): asserts condition {
if (!condition) throw new GoalOutcomeValidationError(reason);
}
function describeTextFailure(value: unknown, max: number): string {
if (typeof value !== "string") {
const kind = Array.isArray(value) ? "array" : value === null ? "null" : typeof value;
return `expected string, got ${kind}; max ${max} UTF-16 code units`;
}
if (value.length === 0) return `must not be empty; max ${max} UTF-16 code units`;
if (value.includes("\0")) return `NUL characters are not allowed; max ${max} UTF-16 code units`;
if (value !== value.trim()) return `no leading/trailing whitespace; max ${max} UTF-16 code units`;
return `got ${value.length} UTF-16 code units, max ${max}`;
}
function text(value: unknown, label: string, max = 512): string {
requireValue(typeof value === "string" && value === value.trim() && !!value && value.length <= max && !value.includes("\0"), `${label} must be bounded nonempty text`);
if (typeof value !== "string" || value !== value.trim() || !value || value.length > max || value.includes("\0")) {
throw new GoalOutcomeValidationError(`${label} must be bounded nonempty text (${describeTextFailure(value, max)})`);
}
return value;
}
function id(value: unknown, label: string): string {
const result = text(value, label, 128);
requireValue(
/^[A-Za-z0-9][A-Za-z0-9_.:@-]*$/.test(result),
`${label} must be an opaque identifier (ASCII letters/digits and . _ : @ -, no '/' paths or spaces)`,
);
return result;
if (typeof value !== "string" || value !== value.trim() || !value || value.length > OPAQUE_ID_MAX || value.includes("\0")) {
const textDetail = describeTextFailure(value, OPAQUE_ID_MAX);
const idNote = typeof value === "string" && value.length > OPAQUE_ID_MAX
? `; must also be an opaque identifier (${OPAQUE_ID_HINT})`
: "";
throw new GoalOutcomeValidationError(`${label} must be bounded nonempty text (${textDetail})${idNote}`);
}
requireValue(OPAQUE_ID_PATTERN.test(value), `${label} must be an opaque identifier (${OPAQUE_ID_HINT})`);
return value;
}
function keys(row: JsonObject, required: string[], optional: string[] = []): void {
requireValue(required.every(key => Object.hasOwn(row, key)) && Object.keys(row).every(key => [...required, ...optional].includes(key)), "outcome fields are missing or unsupported");
const allowed = [...required, ...optional];
const missing = required.filter(key => !Object.hasOwn(row, key));
const unsupportedCount = Object.keys(row).filter(key => !allowed.includes(key)).length;
if (missing.length > 0 || unsupportedCount > 0) {
const details = [
...(missing.length > 0 ? [`missing: ${missing.join(", ")}`] : []),
...(unsupportedCount > 0 ? [`unsupported field count: ${unsupportedCount}`] : []),
`allowed: ${allowed.join(", ")}`,
];
throw new GoalOutcomeValidationError(`outcome fields are missing or unsupported (${details.join("; ")})`);
}
}
function list(value: unknown, label: string, max: number): unknown[] {
requireValue(Array.isArray(value) && value.length <= max, `${label} exceeds its supported capacity`);
if (!Array.isArray(value)) {
throw new GoalOutcomeValidationError(`${label} must be an array (max ${max} items)`);
}
requireValue(value.length <= max, `${label} exceeds its supported capacity (got ${value.length} items, max ${max})`);
return value;
}
function unique(values: string[], label: string): void {requireValue(new Set(values).size === values.length, `${label} contains duplicate ids`);}
Expand Down
Loading