Skip to content
Merged
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
46 changes: 38 additions & 8 deletions examples/adversarial-implementation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The workflow enters the prepared checkout and artifact directory through absolut
`Dir` paths. Enable `--allow-absolute` for these runs; the flag retains existing
read/write restrictions.

For an ordinary ticket, pass `--props-max-steps 1` to finish one role call and inspect its next gate. Each step joins the role, its settlement and continuation publication before returning. Omitting the limit preserves the normal run. An explicit `maxSteps` on a foundation/migration launch holds before the foundation; that route does not expose this Ticket step boundary.

## Select role providers and budgets

The launch task requires `providers` for all three original roles and explicit
Expand All @@ -53,11 +55,19 @@ work, select:
}
```

Planner and Implementor can independently select `claude` instead. The fixed
profiles below determine model and effort; provider selection never substitutes
another provider when one refuses. Architect uses `codex`. Missing or invalid
allocation or budget fields hold before paid work. The resolved Ticket manifest
retains the selected providers and all three budgets through continuation.
Planner and Implementor can independently select `claude` instead. Architect uses `codex`. Omit `implementationModel` to keep the default profile in Responsibilities and models. To select a different Implementor model, set `implementationModel` to an exact model ID advertised by the selected provider. For example:

```json
{
"providers": {"architect":"codex","planner":"codex","implementor":"claude"},
"implementationModel": "sonnet",
"maxCorrections": 3,
"maxApiRepairs": 3,
"maxResponseCorrections": 0
}
```

The explicit model applies only to the Implementor. It preserves that provider's existing effort policy and all other role profiles. Missing or invalid allocation or budget fields hold before paid work. Session verifies the provider's advertised model and effort before prompting. A refused or unavailable selection never substitutes another model, provider or conversation. The resolved Ticket manifest retains the model selection, role providers and all three budgets through continuation and correction.

`maxCorrections` bounds source corrections and `maxApiRepairs` bounds
consumer-driven API repairs, each from zero through ten. `maxResponseCorrections`
Expand Down Expand Up @@ -197,7 +207,7 @@ Session resolution retains its existing provider setup behavior.

This candidate writes `phase-session.v2` receipts. Older receipts refuse without
changes; they are not migrated. Existing tickets keep their pinned workflow and
original receipts.
original receipts. An explicitly prepared model amendment uses a new pinned workflow source only after the prior host entry has joined. It preserves the saved Ticket source and identity receipts. It changes no active entry's includes or running role.

Ordinary Tickets and API foundation/migration work share their original identity
directory across attempts. For standalone `phase.md` requests, retain
Expand Down Expand Up @@ -513,6 +523,8 @@ raw reply, result, status and acceptance receipt beneath the request's attempt.
Source and role checks run before a prompt. Reusing an occupied attempt refuses;
inspect its saved effects before selecting another attempt.

A standalone role request can likewise supply `implementationModel`; it applies only when that request runs the Implementor. Omission keeps the default. Response-format corrections reuse the same selected model and original conversation.

Set `maxResponseCorrections` to zero to validate the reply without another model
prompt. A valid reply saves its canonical result. A rejected reply saves
the raw text, rejection and `response-disposition.json`, then fails without a
Expand Down Expand Up @@ -545,6 +557,24 @@ deno task xmd run --allow-absolute examples/adversarial-implementation/continue.
--include examples/adversarial-implementation/components --raw
```

To select Sonnet for an original Claude Implementor that has never been dispatched, first join the prior host entry and inspect the confirmed paused `implementation` handoff. Supply the user's authorization as readable text under a fresh reference, then continue with both options:

```bash
xmd run --allow-absolute /absolute/path/to/pinned-workflow/examples/adversarial-implementation/continue.md \
--props-record /absolute/path/to/ticket-record.json --props-steps 1 \
--props-implementation-model sonnet \
--props-implementation-model-evidence /absolute/path/to/sonnet-approval.md \
--include /absolute/path/to/pinned-workflow/examples/adversarial-implementation/components --raw
```

In a native REPL, keep the lexical Repository and Worktree around the entry. Select the pinned workflow components for that new entry; do not change the includes of work still running.

The amendment requires both original Implementor initialization flags to be false, no prior Implementor call or identity receipt and an unused next call reservation. Other gates, held or completed records, uncertain attempts and previously dispatched Implementors refuse before a role starts. Both options are required together. The selected provider stays the original provider; this operation does not change it.

The authorization text is retained through the existing document snapshots. The workflow publishes a new continuation with the selected model and an `implementationModelSelection` receipt linking its prior continuation, previous model, selected model and authorization snapshot. It preserves prior bytes, sessions, captured inputs, call ordinals and consumed allowances. Only a confirmed publication can advance through the same requested step limit. Omit both options for an ordinary continuation.

A model field or session name is selection evidence. Actual model use requires the production Session confirmation and canonical Prompt configuration for that attempt. The normal `delivery.json` profile and saved call profile retain the selected model after a successful raw reply; they do not turn a refused model request into a provider acknowledgement.

The envelope names a confirmed continuation by path, UTF-8 byte length and SHA-256.
The protected continuation retains the original manifest, sessions, call ordinals,
delivered-input accounting and correction counts. Each explicit step runs at most
Expand Down Expand Up @@ -687,12 +717,12 @@ determine the work's outcome.
| Owner | Work | Model and effort |
| --- | --- | --- |
| Planner | Ordinary plan/evidence; on migration, implement the API, validate representative consumers and repair API conflicts | Selected Codex `gpt-6.1-sol` or Claude `opus`; ordinary planning uses medium, high for a concrete recorded risk; migration foundation design uses high |
| Implementor | Implement accepted work; on migration, challenge the API, convert consumers and delete obsolete machinery | Selected Codex `gpt-6.1-sol`, medium (high for a concrete recorded risk), or Claude `opus`, high |
| Implementor | Implement accepted work; on migration, challenge the API, convert consumers and delete obsolete machinery | Default: selected Codex `gpt-6.1-sol`, medium (high for a concrete recorded risk), or Claude `opus`, high. Explicit `implementationModel` selects the advertised model of that same provider and preserves its effort policy. |
| Planner reviewer | Inspect the migration against the accepted outcome and evidence | Same selected provider and original Planner session, medium; high for a concrete recorded risk |
| Architect | Answer a concrete structural question or review structural impact | Codex `gpt-6.1-sol`, medium; high for a concrete recorded risk |
| Sidekick running Codex | Author and apply issue/PR titles and descriptions; own publication and delivery | Existing coordinating Sidekick |

Aliases select the provider's available Opus model. Coding roles
Default aliases select the provider's available Opus model. An explicit model uses the provider's exact advertised ID. Coding roles
do not draft or edit issue/PR titles or descriptions. The phase runner
refuses editorial assignments; technical handoffs and API documentation remain
part of the roles' work.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mkdir -- {quoted}
</If>
<Let as="currentReferences" value={[...acceptedInputs.map(input => input.path),props.plannerGuide.path,props.implementorGuide.path]} />
<Let as="deliveredInputs" value={Object.fromEntries(Object.entries(deliveredInputs).map(([session,paths]) => [session,paths.filter(path => currentReferences.includes(path))]))} />
<Let as="migration" value={{schema:"ticket-workflow.v2",work:task.work,directory:task.directory + "/migration-" + round,identityDirectory:task.directory + "/sessions",api,maxCorrections:task.maxCorrections,maxApiRepairs:task.maxApiRepairs,maxResponseCorrections:task.maxResponseCorrections,deliveredInputs,roles:{architect:{session:task.sessions.architect,provider:"codex",initialized:initialized.architect},planner:{session:task.sessions.planner,provider:task.providers.planner,initialized:true},implementor:{session:task.sessions.implementor,provider:task.providers.implementor,initialized:initialized.implementor}},acceptedInputs,roleInputs:{planner:[props.plannerGuide],implementor:[props.implementorGuide]},assignment:{phase:"implementation",work:task.work,repository:task.repository,revision:foundation.validated.revision,priorRevision:assignment.revision,request:api.migration.request,assessment,contract,artifacts:[foundation.path,apiPath],evidence:foundation.validated.checks,findings:[],changedPaths:[]}}} />
<Let as="migration" value={{schema:"ticket-workflow.v2",work:task.work,directory:task.directory + "/migration-" + round,identityDirectory:task.directory + "/sessions",api,maxCorrections:task.maxCorrections,maxApiRepairs:task.maxApiRepairs,maxResponseCorrections:task.maxResponseCorrections,deliveredInputs,roles:{architect:{session:task.sessions.architect,provider:"codex",initialized:initialized.architect},planner:{session:task.sessions.planner,provider:task.providers.planner,initialized:true},implementor:{session:task.sessions.implementor,provider:task.providers.implementor,...(task.implementationModel === undefined ? {} : {model:task.implementationModel}),initialized:initialized.implementor}},acceptedInputs,roleInputs:{planner:[props.plannerGuide],implementor:[props.implementorGuide]},assignment:{phase:"implementation",work:task.work,repository:task.repository,revision:foundation.validated.revision,priorRevision:assignment.revision,request:api.migration.request,assessment,contract,artifacts:[foundation.path,apiPath],evidence:foundation.validated.checks,findings:[],changedPaths:[]}}} />
<Let as="manifest" value={attempt + "/migration.json"} />
<Dir path={attempt}><File path="migration.json"><Json value={migration} /></File></Dir>
<Ticket.Run manifest={manifest} plannerCall={attempt + "/preparation-owner.json"} as="ticket" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ returns: {type: object}
},
providers:{type:"object",properties:{architect:{const:"codex"},planner:{enum:["claude","codex"]},implementor:{enum:["claude","codex"]}},required:["architect","planner","implementor"],additionalProperties:false},
maxResponseCorrections:{type:"integer",minimum:0,maximum:3},
implementationModel:{type:"string",minLength:1},
"maxCorrections": {
"type": "integer",
"minimum": 0,
Expand Down Expand Up @@ -244,6 +245,7 @@ returns: {type: object}
sessions:{type:"object",properties:{planner:text,implementor:text,architect:text},required:["planner","implementor","architect"],additionalProperties:false},
providers:{type:"object",properties:{architect:{const:"codex"},planner:{enum:["claude","codex"]},implementor:{enum:["claude","codex"]}},required:["architect","planner","implementor"],additionalProperties:false},
maxResponseCorrections:{type:"integer",minimum:0,maximum:3},
implementationModel:{type:"string",minLength:1},
maxCorrections:{type:"integer",minimum:0,maximum:10},
maxApiRepairs:{type:"integer",minimum:0,maximum:10}
},required:["work","repository","directory","request","sessions","providers","maxCorrections","maxApiRepairs","maxResponseCorrections"],additionalProperties:false},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ props:
properties:
record: {type: string}
steps: {type: integer, minimum: 1, default: 1}
implementationModel: {type: string, minLength: 1}
implementationModelEvidence: {type: string, pattern: '^/'}
required: [record]
additionalProperties: false
returns: {type: object}
Expand All @@ -12,11 +14,11 @@ returns: {type: object}
<Parse schema={{type:"object"}} as="envelope">{text}</Parse>
<Ticket.Envelope value={envelope} as="envelope" />
<If condition={envelope.publication === "held"}><Ticket.Outward value={envelope} as="bounded" /><Return value={bounded} /><Else>
<Ticket.Capture as="continued"><Ticket.Continue record={envelope} maxSteps={props.steps} as="work" /><Json value={work} /></Ticket.Capture>
<Ticket.Capture as="continued"><Ticket.Continue record={envelope} maxSteps={props.steps} implementationModel={props.implementationModel} implementationModelEvidence={props.implementationModelEvidence} as="work" /><Json value={work} /></Ticket.Capture>
<If condition={continued.status === "completed"}>
<Parse schema={{type:"object"}} as="work">{continued.output}</Parse>
<Ticket.Outward value={work} as="bounded" /><Return value={bounded} />
<Else><Ticket.Outward value={{...envelope,status:"hold",publication:"held",hold:"Continuation was refused. Preserve original evidence and resolve the existing hold before dispatch."}} as="bounded" /><Return value={bounded} /></Else>
<Else><Ticket.Outward value={{...envelope,status:"hold",publication:"held",hold:"Continuation was refused. Preserve original evidence and resolve the existing hold before dispatch.",...(props.implementationModel === undefined && props.implementationModelEvidence === undefined ? {} : {failure:{name:"ContinuationRefused",message:continued.failure.split("\n").filter(line => !/^\s+at /.test(line)).join("\n").slice(0,1024),data:null}})}} as="bounded" /><Return value={bounded} /></Else>
</If>

</Else></If>
4 changes: 2 additions & 2 deletions examples/adversarial-implementation/components/Entry/Phase.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ returns: {type: object}
<Diagnosis.Run request={selected} solvers={solvers} as="diagnosis" />
<Return value={diagnosis} />
<Else>
<Parse schema={{type:"object",properties:{role:{enum:["architect","planner","implementor"]},session:{type:"string",minLength:1},assignment:{type:"object"},attempt:{type:"string",pattern:"^/"},initialize:{type:"boolean",default:false},inputPaths:{type:"array",items:{type:"string"},default:[]},plannerProvider:{enum:["claude","codex"],default:"claude"},implementationProvider:{enum:["claude","codex"],default:"claude"},maxResponseCorrections:{type:"integer",minimum:0,maximum:3,default:3}},required:["role","session","assignment","attempt"],additionalProperties:false}} as="request">{text}</Parse>
<Parse schema={{type:"object",properties:{role:{enum:["architect","planner","implementor"]},session:{type:"string",minLength:1},assignment:{type:"object"},attempt:{type:"string",pattern:"^/"},initialize:{type:"boolean",default:false},inputPaths:{type:"array",items:{type:"string"},default:[]},plannerProvider:{enum:["claude","codex"],default:"claude"},implementationProvider:{enum:["claude","codex"],default:"claude"},implementationModel:{type:"string",minLength:1},maxResponseCorrections:{type:"integer",minimum:0,maximum:3,default:3}},required:["role","session","assignment","attempt"],additionalProperties:false}} as="request">{text}</Parse>
<Ticket.Documents directory={request.attempt + ".inputs"} repository={request.assignment.repository} paths={[...new Set([...(request.inputPaths ?? []),...(request.assignment.handoffInputs ?? [])])]} as="documents" />
<Let as="record" value={{manifest:{directory:request.attempt + "-handoff",identityDirectory:request.assignment.identityDirectory ?? (request.attempt.slice(0,request.attempt.lastIndexOf("/")) + "/sessions"),acceptedInputs:(request.inputPaths ?? []).map(path => documents[path]),roleInputs:{},roles:{}},documents,calls:[]}} />
<Let as="call" value={{id:"standalone",producer:props.request,attempt:request.attempt,initialize:request.initialize,role:request.role,session:request.session,provider:request.role === "architect" ? "codex" : request.role === "planner" ? request.plannerProvider : request.implementationProvider,assignment:request.assignment}} />
<Ticket.Prepare record={record} call={call} as="prepared" />
<If condition={prepared.status !== "ready"}><Fail message={prepared.reason + " Receipt: " + prepared.receipt} /></If>
<Ticket.Capture as="execution"><Phase.Run phase={request.assignment.phase} role={request.role} session={request.session} assignment={prepared.call.assignment} attempt={request.attempt} initialize={request.initialize ?? false} inputs={prepared.inputs} plannerProvider={request.plannerProvider ?? "claude"} implementationProvider={request.implementationProvider ?? "claude"} maxResponseCorrections={request.maxResponseCorrections ?? 3} successor={request.assignment.continuation?.phase ?? null} nextRole={request.assignment.continuation?.role ?? null} as="result" /><Json value={result} /></Ticket.Capture>
<Ticket.Capture as="execution"><Phase.Run phase={request.assignment.phase} role={request.role} session={request.session} assignment={prepared.call.assignment} attempt={request.attempt} initialize={request.initialize ?? false} inputs={prepared.inputs} plannerProvider={request.plannerProvider ?? "claude"} implementationProvider={request.implementationProvider ?? "claude"} implementationModel={request.implementationModel} maxResponseCorrections={request.maxResponseCorrections ?? 3} successor={request.assignment.continuation?.phase ?? null} nextRole={request.assignment.continuation?.role ?? null} as="result" /><Json value={result} /></Ticket.Capture>
<Ticket.Capture as="delivery"><Ticket.Read path={request.attempt+"/delivery.json"} limit={1048576} as="text" /><Json value={text} /></Ticket.Capture>
<Dir path={prepared.receipt.slice(0,prepared.receipt.lastIndexOf("/"))}><File path="dispatch.json"><Json value={{recipient:{role:call.role,session:call.session,provider:call.provider},attempt:request.attempt,execution,result:execution.status === "completed" ? request.attempt+"/result.json" : null,delivery:delivery.status === "completed" ? request.attempt+"/delivery.json" : null}} /></File></Dir>
<If condition={execution.status !== "completed"}><Fail message={execution.failure} /></If>
Expand Down
Loading
Loading