software-defence-factory 0.13.1 → 0.15.0

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/README.md CHANGED
@@ -48,7 +48,7 @@ The runtime supplies policy and six focused skills to its isolated jobs. `init`
48
48
 
49
49
  Each result belongs to a specific candidate commit and policy. A failed check blocks delivery. Changing the candidate or check policy invalidates earlier evidence. Approval records a handoff; publishing, merging and deployment follow the application's separate authority.
50
50
 
51
- The project dashboard has an **Inbox**, measured **Analytics**, **Agents**, **Skills**, **Automations**, **Definition** and **Infrastructure**. Inbox opens on a shared list/board of loaded repository issues and local work, with status, search and checkbox filters, readiness and linked execution attempts. New issue offers repository templates or a blank creation form. Create an issue on the supported repository provider, then choose Start work separately; local brief execution remains available. CLI `issue` exposes the same intake. Definition lives with settings above the theme control. The CLI reads the same definition and controller state. Agent roles use a selected harness such as Codex or Pi; a worker executes their isolated jobs on a host. See [concepts](docs/concepts.md) and [supported interfaces](docs/interfaces.md). Optional automations belong to the selected harness, which calls Factory CLI/API. Factory runs no cron scheduler. See [provider boundaries](docs/integrations.md).
51
+ The project dashboard has an **Inbox**, measured **Analytics**, **Agents**, **Skills**, **Automations**, **Definition** and **Infrastructure**. Inbox opens on a shared list/board of loaded repository issues and local work, with status, search and checkbox filters, readiness and linked execution attempts. New issue offers repository templates or a blank creation form. Create an issue on the supported repository provider, then choose Start work separately; local brief execution remains available. CLI `issue` exposes the same intake. Definition lives with settings above the theme control. The CLI reads the same definition and controller state. Agent roles use a selected harness such as Codex or Pi, with opt-in private keyless local bindings for local/hybrid setups; a worker executes their isolated jobs on a host. See [concepts](docs/concepts.md) and [supported interfaces](docs/interfaces.md). Optional automations belong to the selected harness, which calls Factory CLI/API. Factory runs no cron scheduler. See [provider boundaries](docs/integrations.md).
52
52
 
53
53
  The optional **defence** workflow accepts scoped incident evidence and produces a private, read-only draft. It does not monitor production or claim verified recovery. See [defence integration](docs/defence-integration.md).
54
54
 
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { harnessPreset, parseRoleDefinition, ROLE_CAPABILITIES } from '../factory/role-definition.mjs';
3
+ import { inspectDefinition, previewDefinition, previewRollback } from '../factory/definition-store.mjs';
2
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, openSync, closeSync, rmSync, renameSync, realpathSync } from 'node:fs';
3
5
  import { resolve, join } from 'node:path';
4
6
  import { randomBytes } from 'node:crypto';
@@ -41,8 +43,7 @@ function init(repo, harness='codex', check='', port=7331, sourceRef='HEAD', deli
41
43
  if ([repo,state,ROOT].some(p=>/[,\n\r]/.test(p))) throw new Error('Paths cannot contain commas or line breaks');
42
44
  if (runCandidateGit(repo,'rev-parse','--show-toplevel') !== repo) throw new Error('--repo must be the Git root');
43
45
  runCandidateGit(repo,'rev-parse','HEAD');
44
- const presets={codex:['codex','exec','--json','--ephemeral','--sandbox','danger-full-access','-'],pi:['pi','--mode','json','--print','--no-session','--no-extensions','--skill','/factory-skills'],mock:['node','/opt/factory/mock.mjs']};
45
- const argv=harness==='custom'?JSON.parse(flags['command-json'] || 'null'):presets[harness];
46
+ const argv=harness==='custom'?JSON.parse(flags['command-json'] || 'null'):harnessPreset(harness);
46
47
  if (!argv) throw new Error('Select codex, pi, mock or custom with --command-json');
47
48
  if (flags.model && ['codex','pi'].includes(harness)) argv.splice(harness==='codex'?argv.length-1:argv.length,0,'--model',flags.model);
48
49
  mkdirSync(state,{recursive:true,mode:0o700});state=realpathSync(state);chmodSync(state,0o700);
@@ -198,7 +199,30 @@ try {
198
199
  else if(command==='tunnel')await manageService('tunnel',positional[0],state,flags);
199
200
  else if(command==='foundation')console.log(foundationSkill().content);
200
201
  else if(['definition','workflows','agents','skills'].includes(command)) {
202
+ if (command === 'definition' && positional.length) {
203
+ const action = positional[0];
204
+ if (!['export', 'validate', 'diff', 'apply', 'rollback'].includes(action) || positional.length !== 1) throw new Error('Choose definition export|validate|diff|apply|rollback');
205
+ let value, bindings;
206
+ if (['validate', 'diff', 'apply'].includes(action)) {
207
+ if (!flags.file) throw new Error('--file is required');
208
+ value = JSON.parse(readFileSync(resolve(flags.file), 'utf8'));
209
+ if (flags['bindings-file']) bindings = JSON.parse(readFileSync(resolve(flags['bindings-file']), 'utf8'));
210
+ }
211
+ let result;
212
+ if (action === 'export') result = inspectDefinition(state).definition;
213
+ else if (action === 'rollback' && !flags['expected-revision']) result = previewRollback(state);
214
+ else if (action === 'validate' && bindings !== undefined && !existsSync(join(state, 'factory.json'))) throw new Error('Local binding validation requires an installation');
215
+ else if (action === 'validate' && !existsSync(join(state, 'factory.json'))) result = { valid: true, definition: parseRoleDefinition(value), capabilities: ROLE_CAPABILITIES, resolution: 'Requires an installation for inherited settings' };
216
+ else if (['validate', 'diff'].includes(action)) result = previewDefinition(state, value, bindings);
217
+ else {
218
+ if (!flags['expected-revision']) throw new Error('--expected-revision from the current preview is required');
219
+ result = await api(state, `/api/v1/definition/${action}`, { expected_revision: flags['expected-revision'], ...(action === 'apply' ? { definition: value, ...(bindings === undefined ? {} : { local_bindings: bindings }) } : {}) });
220
+ }
221
+ console.log(JSON.stringify(result, null, 2));
222
+ process.exit(0);
223
+ }
201
224
  const definition=factoryDefinition(configAt(state));
225
+ definition.role_definition = inspectDefinition(state);
202
226
  const value=command==='agents'?definition.agents:command==='skills'?{agents:definition.skills,operators:definition.operator_skills}:definition;
203
227
  console.log(JSON.stringify(value,null,2));
204
228
  }
@@ -321,6 +345,9 @@ Compatibility executable: software-defence-factory (same runtime and state)
321
345
  web probe --state PATH Execute the pinned local Chromium readiness probe
322
346
  foundation Read the operator setup skill; no installation required
323
347
  definition | agents | skills Inspect roles, instructions and installation settings
348
+ definition export|validate|diff Portable roles; validate/diff require --file PATH; optional --bindings-file PRIVATE_PATH
349
+ definition apply --file PATH --expected-revision HASH
350
+ definition rollback --expected-revision HASH Idle controller only
324
351
  inbox [--page N] [--issue-state open|closed|all] [--source inbox|factory]
325
352
  Repository backlog (default); factory: execution-only array
326
353
  infrastructure | automations Inspect host/worker and automation state
package/docs/concepts.md CHANGED
@@ -9,14 +9,14 @@ The CLI `definition` command and dashboard Definition page read that same catalo
9
9
  | Controller | One project's queue, policy, HTTP API and dashboard | One Node/SQLite service |
10
10
  | Worker | Executes jobs on a host | One local execution process; bounded Docker containers |
11
11
  | Harness | Runs an agent | Codex, Pi, a custom command, or synthetic mock |
12
- | Agent | Responsibility and instructions | Implement, Review, Investigate; one shared harness/model profile |
12
+ | Agent | Responsibility and instructions | Implement, Review, Investigate; inherited or explicit harness/model per role |
13
13
  | Skill | Reusable instructions | Six job skills; separate operator Factory Foundation |
14
14
  | Workflow | Ordered steps and gates | Software: Implement → Check → Review → Accept; Defence: Investigate |
15
15
  | Issue | Bounded work request | Remote issue lives in its provider; a local brief needs no remote issue |
16
16
  | Execution | Admitted work and its attempts | Stored in the private SQLite queue with source link and evidence |
17
17
  | Provider | Repository issue integration | GitHub adapter first; unknown remotes retain local execution |
18
18
  | Automation | External schedule and agent context | Owned by the selected harness; calls Factory CLI/API, no Factory cron |
19
- | Definition | Effective roles, workflows, skills and settings | Installed method plus private factory.json; read-only catalog |
19
+ | Definition | Effective roles, workflows, skills and settings | Installed method, private settings and explicitly adopted portable role definition |
20
20
 
21
21
  Inbox combines an explicitly loaded provider page with retained execution
22
22
  history in one list/board, grouped by canonical issue identity. Off-page sources
@@ -29,7 +29,8 @@ Accept is an operator gate. Triage/specification precede admission; evaluation
29
29
  is separately scoped work, not an automatic hidden agent phase.
30
30
 
31
31
  All job skills are available read-only. Role instructions identify relevant
32
- skills; per-role skill/access/harness profiles are not yet supported. Inference
32
+ skills; per-role skill/access controls remain deferred. Harness/model selection
33
+ uses the [role definition contract](definition.md). Inference
33
34
  authentication, GitHub identity and SSH access are separate boundaries. Browser
34
35
  GitHub sign-in does not configure `gh` on the controller host, and host `gh` auth
35
36
  does not sign a browser in. Writing a blank local issue needs neither a GitHub issue nor
@@ -0,0 +1,310 @@
1
+ # Role definitions (0.15.0)
2
+
3
+ The portable definition selects harness/model profiles for **Implement**, **Review**
4
+ and **Investigate**. CLI, local API and the existing Agents/Definition pages use
5
+ one parser, resolver, capability matrix and application path. This first #53 slice
6
+ does not make skills, resources, access, workflow gates or schedules editable.
7
+
8
+ ```json
9
+ {
10
+ "version": 1,
11
+ "roles": {
12
+ "implement": { "harness": "inherit" },
13
+ "review": { "harness": "pi", "model": "anthropic/operator-selected-model" },
14
+ "investigate": { "harness": "codex", "model": "operator-selected-model", "reasoningEffort": "high" }
15
+ }
16
+ }
17
+ ```
18
+
19
+ The root accepts exactly `version` and `roles`. Version must be numeric `1`;
20
+ role names are exactly `implement`, `review`, `investigate`. Missing roles and
21
+ missing `harness` mean `inherit`. Each role accepts only `harness`, `model`, `reasoningEffort` and
22
+ `localBinding`; unknown fields, roles, versions and incompatible combinations
23
+ fail explicitly. The authoritative implementation and capability matrix are in
24
+ [role-definition.mjs](../factory/role-definition.mjs), not a second schema copy.
25
+
26
+ - `inherit` preserves the installed private command, including a custom wrapper.
27
+ An omitted model inherits the installed model. Model/reasoning overrides require
28
+ an inherited Codex/Pi adapter; custom and mock commands have no such controls.
29
+ For an inherited Codex model or effort override, one bounded option parser
30
+ supports direct `codex exec` argv (also `e`). Model selection replaces
31
+ separate/attached `-m` and `--model` forms and direct
32
+ `-c`/`--config model=...` settings. An explicit model emits one `--model VALUE`;
33
+ `null` removes those inherited selections. Unrelated supported options, their
34
+ values and the prompt remain intact; new options precede the prompt or `--`.
35
+ Effort selection replaces direct `model_reasoning_effort` settings in supported
36
+ separate/attached `-c`/`--config` forms with one setting. Effort-only changes
37
+ preserve inherited model arguments exactly, without substituting installed
38
+ model metadata. Model-only changes preserve inherited effort settings.
39
+ Opaque wrappers, unknown switches/arity, profile selectors (`-p`/`--profile` or
40
+ config profile layers), nested commands, multiple prompts, options after a
41
+ positional prompt and duplicate model flags left by an effort-only selection
42
+ are refused before adoption. Use the Codex preset or correct the private
43
+ command while stopped. All-inherit commands remain byte-for-byte unchanged.
44
+ - Explicit `codex` or hosted `pi` uses the same maintained preset as `init`, even when
45
+ the installed harness has the same name. No command, path, privilege, network,
46
+ credential or provider-authorization argument can enter the portable payload.
47
+ - `model` is a user-selected identifier (1–128 identifier characters, no paths,
48
+ URLs, whitespace or command switches). Omit it for the explicit harness default;
49
+ `null` also requests that default. Explicit hosted Pi requires a supported
50
+ `provider/model` prefix so credential selection is unambiguous. For inherited Pi,
51
+ a model must agree with any installed private `inferenceProvider`.
52
+ - `localBinding` selects an explicitly adopted private keyless Pi binding instead
53
+ of a hosted model; see the opt-in contract below.
54
+ - This slice exposes Codex `reasoningEffort` values `low`, `medium`, `high`, passed
55
+ as `-c model_reasoning_effort="VALUE"`. Omission preserves private/default
56
+ behavior; it does not attest a detected effort. Pi effort control is unavailable.
57
+ The [Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
58
+ documents the setting; actual supported levels depend on the selected model.
59
+ Validation does not call a model or prove availability, quality or readiness.
60
+
61
+ ## Inspect, review and adopt
62
+
63
+ ```sh
64
+ factory definition --state PATH
65
+ factory agents --state PATH
66
+ factory skills --state PATH
67
+ factory definition export --state PATH > factory-roles.json
68
+ factory definition validate --state PATH --file factory-roles.json
69
+ factory definition diff --state PATH --file factory-roles.json
70
+ factory definition apply --state PATH --file factory-roles.json --expected-revision REVISION
71
+ factory definition rollback --state PATH
72
+ factory definition rollback --state PATH --expected-revision REVISION
73
+ ```
74
+
75
+ `definition`, `agents`, `skills`, and compatibility `workflows` remain readable
76
+ while stopped. Export prints only portable JSON. Validate and diff resolve against
77
+ the installation and return the normalized definition, effective selections,
78
+ changes and **current** revision. With no installation, validate performs portable
79
+ syntax/explicit-combination validation and reports that inheritance still needs
80
+ an installation. No account or provider connection is needed for validation.
81
+ Rollback without `--expected-revision` previews the previous definition. Supply
82
+ that revision to perform rollback; it restores the previous selection, not the
83
+ old revision number. Keep `factory-roles.json` in a repository for ordinary code
84
+ review or in a private local file. No filename is automatically discovered or
85
+ adopted from source, issues, labels or a candidate checkout.
86
+
87
+ Apply and rollback require the running single controller. The browser uses the
88
+ same endpoints, with labelled role inputs and a diff before explicit Apply.
89
+ A matching revision and an idle controller are required: queued, running,
90
+ cancelling, awaiting-approval work, pending actions, maintenance and unreconciled
91
+ executor fences block application. Stale or invalid requests fail without
92
+ changing installed settings. Reload and preview again after a conflict.
93
+ Configuration adoption never admits work or installs/discovers a schedule.
94
+
95
+ Authenticated API requests (bearer operator token or local session):
96
+
97
+ | Request | JSON body / result |
98
+ | --- | --- |
99
+ | `GET /api/v1/definition` | Current `revision`, portable `definition`, `effective`, `inherited_harness`, `capabilities`, `rollback_available` |
100
+ | `POST /api/v1/definition/validate` | `{"definition": {...}}` → validation and effective diff |
101
+ | `POST /api/v1/definition/diff` | `{"definition": {...}}`, or `{"rollback": true}` → current revision, proposed definition, effective changes |
102
+ | `POST /api/v1/definition/apply` | `{"definition": {...}, "expected_revision": "HASH"}` → installed readback |
103
+ | `POST /api/v1/definition/rollback` | `{"expected_revision": "HASH"}` → installed readback |
104
+
105
+ `GET /api/v1/definitions` remains the safe catalog and includes `role_definition`.
106
+ HTTP 400 means invalid schema/combination; 403 means missing session or rejected
107
+ Host/Origin; 409 means stale/busy/recovery-required or no rollback available.
108
+ Storage errors return 500 with details in private controller logs. CLI errors
109
+ exit nonzero. Neither catalog nor role responses expose private command argv,
110
+ credential values or machine bindings. Unresolved provider defaults remain null;
111
+ execution resolves them from the private installation before launch.
112
+
113
+ ## Private state, policy and evidence
114
+
115
+ Existing `factory.json` is not rewritten or migrated. With no overrides, the
116
+ legacy effective configuration and policy hash are byte-compatible, including
117
+ private custom commands and legacy `agent` naming. All-inherit adoption is a
118
+ no-op. Shared resources, image, checks, repository identity and credentials stay
119
+ private and are changed while stopped through their existing operator workflow.
120
+ Foundation supplies setup guidance, not another configuration source.
121
+
122
+ The controller stores the adopted definition and up to ten prior definitions in
123
+ one private `role-definition.json`, using a flushed temporary file and atomic
124
+ rename. Process interruption before rename leaves the old record; after rename,
125
+ the complete new record and history are present. Incomplete temporary files are
126
+ not loaded. The adopted record must be a regular private file; repository symlinks
127
+ are refused. Revisions include a monotonic sequence and the private base settings,
128
+ so an old revision is stale even after rollback. Back up the entire private state
129
+ while stopped; rollback restores roles and adopted local bindings, not separately edited base
130
+ settings, credentials or historical attempts. New reads do not use a startup cache.
131
+
132
+ Before each attempt, trusted configuration resolves and freezes **all roles** in
133
+ private `execution-config.json`. The executor selects its phase from that frozen
134
+ configuration. One policy hash covers the common configuration across Build,
135
+ deterministic Verify, Review and Handoff; it is not a hash of separately merged
136
+ phase settings. Protected v2 execution evidence records role, requested model,
137
+ provider, explicit effort and a digest binding the exact private command selection.
138
+ The executor checks that binding before launching. Role overrides require v2;
139
+ old v1 evidence cannot attest them. Unchanged legacy configurations still emit
140
+ v1 with the actual installed runtime version. See [compatibility](npm.md#protected-evidence-compatibility).
141
+
142
+ Changing a role invalidates prior acceptance/checkpoint evidence under that
143
+ policy. Rollback can restore the exact prior policy; it never edits evidence or
144
+ automatically retries work. Recovery, reviewed-candidate continuation and new
145
+ publication use the same current-policy guards. Existing published receipt
146
+ reconciliation retains its read-only semantics. With any role override, task-wide
147
+ `--model`/API `model` is refused, including a value equal to the old shared model.
148
+ Clear it and use the role definition; unchanged legacy installations keep their
149
+ existing task-model behavior.
150
+
151
+ Only the selected provider's inference settings reach each agent phase. Codex
152
+ account-auth data never reaches Pi, including Pi using OpenAI. Check and Handoff
153
+ receive no inference credentials. Git/issue-provider identity remains on the
154
+ controller. Portable roles create no credentials or model downloads. The opt-in local binding
155
+ contract below explicitly adopts private endpoint details separately.
156
+
157
+ ## Role and output boundaries
158
+
159
+ Build implements, runs appropriate checks, writes its report and returns. Factory
160
+ owns separate Review; this slice grants no nested reviewer capability or budget.
161
+ Review receives the original source baseline and protected exact-candidate,
162
+ current-policy checks. Its candidate mount is read-only, without installed
163
+ project dependencies; `/tmp` is bounded/noexec. Reuse passing protected checks.
164
+ Additional reproduction requires suitable available capabilities; do not repeat
165
+ impossible installs or treat an unavailable rerun as a code finding or a pass.
166
+
167
+ Factory owns `/output/agent-report.md`, `/output/review.json` and
168
+ `/output/incident-report.json` as appropriate to the phase. Harness-only final
169
+ output belongs in ephemeral `/tmp/factory-final-message.md`, never those reports.
170
+ The maintained presets do not capture a final-message file over a Factory report.
171
+ Role adoption rejects recognized inherited Codex final-message flags targeting
172
+ non-ephemeral destinations; it never rewrites the private command. Opaque custom
173
+ wrappers remain operator-owned. Redaction covers owned reports/logs, not every
174
+ arbitrary file a custom harness might write. A missing required report remains
175
+ a failure, never a final-message substitution.
176
+
177
+ All six installed runtime skills remain available read-only, with content/source
178
+ hashes in the catalog. Per-role recommendations are guidance, not access controls.
179
+ Triage/spec are pre-admission method skills, not executable roles. Check remains
180
+ deterministic; acceptance is human-owned. No foreman, scheduler, application
181
+ publishing or production recovery authority is added.
182
+
183
+ Host, image/toolchain and provider readiness require actual probes on each target
184
+ platform. `doctor` and existing image/browser probes keep their bounded meanings;
185
+ configuration alone is not readiness attestation. Lead qualification of the exact
186
+ package, isolated mixed-role Docker execution and desktop/390/320px browser
187
+ inspection in both themes remain separate gates. #53 stays open for per-role
188
+ skills/resources/access, broader project/flow/automation definitions and readiness
189
+ attestation. #69 owns local/hybrid model benchmarks, #51 measurement and #70
190
+ improvement proposals.
191
+
192
+ ## Opt-in local bindings (0.15.0, #69)
193
+
194
+ A portable role can select `{"harness":"pi","localBinding":"local-worker"}`
195
+ instead of a hosted `model`. The same reference can serve Implement, Review and
196
+ Investigate, or any role can retain Codex/a hosted Pi model for a hybrid setup.
197
+ Binding references cannot be combined with a role model or reasoning effort.
198
+ They require the maintained Pi preset; private wrappers are not binding adapters.
199
+
200
+ Connection details belong to explicitly adopted **private installation state**,
201
+ not the portable definition. No repository filename, issue or model response is
202
+ an active configuration source. Save a private JSON binding map, for example:
203
+
204
+ ```json
205
+ {
206
+ "local-worker": {
207
+ "endpoint": "http://operator-selected-host:8080/v1",
208
+ "model": "exact-installed-model-id",
209
+ "contextWindow": 32768,
210
+ "maxTokens": 4096,
211
+ "reasoningEffort": "default",
212
+ "compat": {
213
+ "maxTokensField": "max_tokens",
214
+ "supportsUsageInStreaming": true,
215
+ "requiresToolResultName": false
216
+ }
217
+ }
218
+ }
219
+ ```
220
+
221
+ These illustrative values are not defaults or measured recommendations. Select
222
+ the endpoint, exact model and limits for your installation. `endpoint` is a base
223
+ URL for OpenAI **chat completions**, not a full `/chat/completions` URL. The job's
224
+ isolated network must reach it; its loopback address is not the host's loopback.
225
+ Factory neither opens ports nor adjusts networking or inference services.
226
+
227
+ ```sh
228
+ factory definition diff --state PRIVATE_STATE --file roles.json --bindings-file PRIVATE_BINDINGS.json
229
+ factory definition apply --state PRIVATE_STATE --file roles.json --bindings-file PRIVATE_BINDINGS.json --expected-revision HASH_FROM_DIFF
230
+ factory definition rollback --state PRIVATE_STATE --expected-revision CURRENT_HASH
231
+ ```
232
+
233
+ `validate`, `diff` and `apply` accept `--bindings-file`. Without it they retain the
234
+ installed binding map. Providing a map replaces it in full, so removing a referenced
235
+ binding fails until its roles are changed in the same request. `export` includes
236
+ only portable roles/references. CLI `definition` inspects private bindings locally.
237
+ The authenticated API adds optional `local_bindings` beside `definition` to
238
+ validate/diff/apply; `GET /api/v1/definition` returns both. Diff returns
239
+ `binding_changes`. Unauthenticated `/api/v1/definitions` omits endpoint maps;
240
+ authenticated readback includes them. The existing Agents/Definition editor uses
241
+ this same contract and shows a binding diff before Apply, including connection-only
242
+ changes. Configuration makes no inference/model-list requests and never starts work.
243
+
244
+ Bindings and roles share one revision, idle check, atomic record and at most ten
245
+ rollback snapshots. Rollback restores both together; stale/busy/invalid writes
246
+ preserve the prior state. Endpoint normalization is idempotent; URLs whose normalized
247
+ form contains forbidden escapes (including Unicode path characters) are rejected.
248
+ The complete serialized record and history are validated before replacement.
249
+ The version-2 private record reads old version-1 role
250
+ records without rewriting them. An old runtime cannot read a newly adopted v2
251
+ record: roll back profiles first and restore a stopped pre-upgrade private-state
252
+ backup before downgrading binaries. Do not hand-edit histories or frozen attempts.
253
+
254
+ The binding contract supports at most 16 named, keyless HTTP(S) endpoints. URLs
255
+ with user information, queries, fragments, escapes or malformed syntax are refused.
256
+ Model identifiers cannot contain shell syntax, whitespace or traversal. Context
257
+ must be 1,024–1,048,576 tokens; output must be 1–32,000 and smaller than context.
258
+ The output ceiling follows pinned Pi 0.73.1's simple chat adapter. Range acceptance
259
+ is **not** evidence of server allocation or useful task capacity. Only the three
260
+ shown compatibility fields are supported. Authentication, custom headers, shell
261
+ credential commands, arbitrary request fields, sampling overrides, custom thinking
262
+ maps and provider plugins are unsupported. Factory does not spoof local inference
263
+ as the hosted OpenAI provider.
264
+
265
+ The optional binding `reasoningEffort` accepts only these OpenAI-style requests:
266
+
267
+ | Binding choice | Chat-completions request |
268
+ | --- | --- |
269
+ | Omitted or `default` | No `reasoning_effort` override; server default applies |
270
+ | `none` | `reasoning_effort: "none"` |
271
+ | `low`, `medium`, `high` | `reasoning_effort` set to that exact value |
272
+
273
+ This is a request choice, not a measured thinking budget or quality claim. The
274
+ pinned Pi 0.73.1 adapter uses a fixed internal `thinkingLevelMap.off="none"` for
275
+ `none`; `--thinking off` alone does **not** disable a server's default thinking.
276
+ Low/medium/high use the corresponding explicit Pi thinking level. Existing
277
+ bindings with no choice retain their omitted request and private policy shape;
278
+ no default is inserted into their saved configuration. The binding editor,
279
+ CLI/API diff, private readback, frozen selection and rollback share this choice.
280
+ Separate role bindings can request different efforts. Endpoint support and actual
281
+ behavior remain unqualified until tested on that installation. A server rejection
282
+ fails the job without fallback or retrying with a different choice; a server that
283
+ silently ignores the field cannot be detected from successful transport alone.
284
+
285
+ Before admission, all selected references must resolve. Each attempt freezes the
286
+ chosen endpoint, exact model, declared limits, reasoning request, compatibility settings and maintained
287
+ command along with the common resource/timeout/skill policy. Unselected bindings
288
+ are not included. Local/hybrid attempts emit protected **v3** evidence across all
289
+ phases, binding the selection digest and common policy. Public facts show configured
290
+ context/output, unknown actual allocation and unqualified quality. Old v1/v2 writers
291
+ cannot attest local bindings; unchanged legacy profiles keep their policy bytes and
292
+ compatible evidence. See [the compatibility audit](npm.md#protected-evidence-compatibility).
293
+
294
+ For the selected local role only, the executor creates a private single-model
295
+ `models.json` and deterministic launcher, mounted read-only at `/factory-local`.
296
+ `PI_CODING_AGENT_DIR` selects that directory; HOME is still ephemeral. The launcher
297
+ checks explicit provider/model argv, removes inherited credential/override inputs
298
+ and propagates Pi JSON provider failures even if Pi exits zero. The registry uses
299
+ Pi's required fixed non-secret key placeholder (`factory-local-keyless`), which may
300
+ be sent as a bearer value; this is not endpoint authentication. No host home, provider
301
+ catalog or credential store is mounted. Repository files cannot replace this mount.
302
+ Files are removed after confirmed container shutdown; uncertain shutdown retains
303
+ them behind the existing recovery fence until normal recovery confirms absence.
304
+
305
+ Local roles receive no cloud model environment; cloud roles receive no local
306
+ registry/override. Verify and Handoff receive neither. The local preset disables
307
+ automatic skills/extensions/templates but explicitly adds `--skill /factory-skills`,
308
+ preserving the six packaged skills. Recommendations remain guidance, not per-role
309
+ access controls. Build still returns to Factory's independent Review and operator
310
+ handoff; no duplicate review workflow is launched.
@@ -20,7 +20,8 @@ shell endpoint or a second scheduler.
20
20
  | Request changes | `revise --file`, optional `--from admitted-source\|reviewed-candidate` or `--source-ref REF` | `request_changes` with `revision_mode`; continuation binds current run/head/tree from shared status | Explicit starting point, baseline and reviewed checkpoint; inline errors | JSON action result; unfinished Build checkpoints remain #42 |
21
21
  | Remove a stopped task | No command | `DELETE /api/v1/jobs/:id` | Remove action | Add CLI; keep existing recoverability/history semantics |
22
22
  | Evidence list/read/download | No command | Authenticated artifact routes | Files/preview/download | Add CLI with matching access and size/path rules |
23
- | Roles, workflows and packaged skills | `definition`, `agents`, `skills` JSON (also while stopped) | `GET /api/v1/definitions` | Agents, Skills and Definition | Shared read-only catalog; future editing must preserve common policy/gates |
23
+ | Roles, workflows and packaged skills | `definition`, `agents`, `skills` JSON (also while stopped) | `GET /api/v1/definitions` | Agents, Skills and Definition | Shared catalog plus bounded role harness/model editing; deterministic checks, gates, skills and resources stay shared |
24
+ | Portable roles and private local bindings | `definition export/validate/diff/apply/rollback`, optional `--bindings-file` for validate/diff/apply | Authenticated `/api/v1/definition` and typed operations | Agents/Definition role editor, diff, explicit idle Apply and rollback | One schema/capability matrix; revision CAS and bounded atomic role/binding history; configured context distinct from unknown allocation and unqualified quality; [request shapes](definition.md) |
24
25
  | Project repository links | Validated links in `status` | `project_links` from configured Git origin | View repo / optional GitHub issue link | Provider creates/issues reads are separate from Git source links |
25
26
  | Recorded token usage | Per-attempt `usage` and `token_usage` in `status` | Same status records | Analytics, task rows, metadata/history | No billing estimate; partial/unknown coverage stays explicit |
26
27
  | Analytics/filtering | Raw status available | Source queue records | Derived views | Expose equivalent queries/summaries without inventing usage data |
@@ -35,7 +36,7 @@ shell endpoint or a second scheduler.
35
36
  | Synthetic qualification | `demo`, `qualify` | No qualification endpoint | Synthetic disclosure only | Explicit separate state; never target an application accidentally |
36
37
  | Immutable source admission | `init --source-ref`, `run --source-ref`, `issue start --source-ref`; status and build evidence carry the resolved SHA | `POST /api/v1/jobs` resolves/retains before acknowledgement; shared source metadata in status | Issue Start work, local request and revision forms accept a ref; task detail shows requested ref, resolved SHA and prior source commits | Build/retry use retained objects; revisions start fresh by default; explicit continuation keeps the reviewed tree and recorded source; a new ref replaces the base; legacy source remains unknown |
37
38
  | Trusted PR handoff | `publish JOB_ID` publishes/reconciles; `abandon-delivery JOB_ID --branch-sha SHA` records a checked local resolution for a pre-write branch collision | Authenticated `POST /api/v1/jobs/:id/publish` and `/abandon-delivery`; shared receipt, conflict identity and removal policy | Publish/reconcile and explicit “Abandon local delivery; keep remote branch” actions share controller state; errors/results and inspected branch identity are visible | New writes require matching protected Codex/Pi build/review provenance, deterministic verify/handoff provenance, non-synthetic bound artifacts and a qualified GitHub Actions tree. Shared delivery status exposes `workflow_qualification` and the same reason blocks CLI/API/dashboard capability and publication/retry. Candidate workflow changes, unsupported triggers/syntax, or active generated-push, selected-ref-dispatch and PR jobs with write/secrets/environment/OIDC/deploy access, self-hosted runners or ambiguous privileged guards refuse trusted writes. Supported ASCII guard comparisons follow GitHub's case-insensitive string semantics; unknown PR refs, non-ASCII mismatches, and glob/escaped branch filters cannot prove a privileged job inactive. The shared summary's `action_mode` distinguishes new/resumable publication from read-only reconciliation and drives idle and pending task button wording. Branch-only collisions and unknown/abandoned states offer neither; known PR receipts and pending PR-creation checkpoints retain read-only reconciliation. Abandonment checks the current run, saved intent, exact branch head and absence of an associated PR; it writes no provider data, preserves the remote branch/evidence, disables republishing and permits local removal. Uncertain effects and incompatible evidence stay blocked. Destination remains private operator config; patch-only remains default |
38
- | Delivered-commit check readback | `publish JOB_ID` reconciles, `status` returns saved checks | Existing publish/status routes return the same `delivery_status.checks` | Delivered-commit checks, per-row conclusions/scope, uncertainty and refresh | 0.13.1 verifies exact commit/provider identity; installed/live/browser qualification pending; no required-check or mergeability claim |
39
+ | Delivered-commit check readback | `publish JOB_ID` reconciles, `status` returns saved checks | Existing publish/status routes return the same `delivery_status.checks` | Delivered-commit checks, per-row conclusions/scope, uncertainty and refresh | 0.13.1 delivered in PR #97 with installed/live/browser qualification recorded; no required-check or mergeability claim |
39
40
  | Optional trusted web verification | `web probe` performs a real local Chromium interaction; `doctor` reports readiness | Verify stores a shared story summary and protected JSON artifact in the run | Task history shows passed/failed/unavailable/inconclusive plus tool, candidate, policy and story hashes | Disabled by default. Required operator stories and Playwright/Chromium image ID are frozen in attempt policy. Linux Chromium proof cannot qualify native/mobile OS behavior; see [the browser contract](web-verification.md) |
40
41
 
41
42
  The current generic task form can name the Defence workflow; that is not a
package/docs/npm.md CHANGED
@@ -104,8 +104,8 @@ installation or retained attempt needs them.
104
104
 
105
105
  ## Protected evidence compatibility
106
106
 
107
- Factory 0.13.1 recognizes version-1 execution profiles emitted by native
108
- **0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.11.0, 0.11.1, 0.11.2, 0.12.0, 0.13.0 and 0.13.1**. This is an exact allowlist in
107
+ Factory 0.15.0 recognizes version-1 execution profiles emitted by native
108
+ **0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.11.0, 0.11.1, 0.11.2, 0.12.0, 0.13.0, 0.13.1, 0.14.0 and 0.15.0**. This is an exact allowlist in
109
109
  `factory/execution-profile.mjs`, independent of the installed package version;
110
110
  it is not a semver range or an automatic promise for later releases. Unknown
111
111
  runtime strings, unknown profile formats and incomplete legacy acceptance
@@ -170,6 +170,17 @@ and publication validation tests; old records remain immutable and unknown
170
170
  versions remain blocked. Provider check observations are separate from protected
171
171
  Verify evidence and cannot authorize acceptance or publication.
172
172
 
173
+ Version 0.14.0 preserves the v1 writer only for unchanged inherited installations:
174
+ policy bytes, candidate/check/review/acceptance bindings, mounts and credential
175
+ rules stay compatible. Adopted role overrides use **v2 from 0.14.0 and 0.15.0**, recording
176
+ role/provider/effort and an exact selection digest. The executor verifies the
177
+ frozen common configuration before phase selection; continuation and both delivery
178
+ validation paths require matching protected v2 evidence and private frozen config.
179
+ V1 cannot attest an override. Mixed roles share one policy across deterministic
180
+ and agent phases. Rollback can restore a prior policy without rewriting a record.
181
+ See the [definition contract](definition.md); installed Docker/provider qualification
182
+ remains separate from schema compatibility.
183
+
173
184
  Old installed releases retain their own files and mount paths until an idle,
174
185
  reviewed update. No installed catalog, execution profile or historical hash is
175
186
  rewritten by this layout change. Qualify the exact updated package/image before
@@ -216,3 +227,17 @@ delivery under [#61](https://github.com/arcitai/software-and-defence-factory/iss
216
227
 
217
228
  References: [npm/npx](https://docs.npmjs.com/cli/v11/commands/npx/),
218
229
  [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
230
+
231
+
232
+ The 0.15.0 compatibility audit preserves unchanged v1/v2 policy construction,
233
+ protected checks, candidate reconstruction, read-only review and acceptance guards.
234
+ Historical 0.14.0 v2 validation compares its actual writer version rather than
235
+ relabeling it as the installed version. Local registry selection is a new execution
236
+ contract: every phase of a local/hybrid attempt requires **v3 from 0.15.0** and its
237
+ exact protected frozen configuration. v1/v2 cannot attest local binding fields,
238
+ providers or a common policy containing a selected local role. A selected endpoint,
239
+ model, limit or compatibility change invalidates the current policy; explicit
240
+ rollback can restore it without editing historical evidence. Controlled regressions
241
+ exercise legacy v2 readback and local v3 rejection/tamper cases. Installed-package
242
+ Docker and independent Review remain delivery qualification, not inferred from this
243
+ compatibility audit.
package/docs/recovery.md CHANGED
@@ -13,7 +13,7 @@ Use `status --state PATH` and the private supervisor.log to identify the active
13
13
 
14
14
  Do not remove active.json merely to unblock a job. Establish that its PID, process group and labelled containers are stopped. PID reuse or missing process identity requires operator investigation. Preserve logs and work before cleanup.
15
15
 
16
- For backup, stop the installation and copy the complete private state directory, including SQLite files, factory.json and credentials, to an authorized private destination. Restore only while stopped. Update the repository path if it moved, verify ownership/permissions and the pinned image, then inspect state before any retry. Keep previous backups; no automatic destructive schema migration is provided.
16
+ For backup, stop the installation and copy the complete private state directory, including SQLite files, factory.json, role-definition.json when present, and credentials, to an authorized private destination. Restore only while stopped. Update the repository path if it moved, verify ownership/permissions and the pinned image, then inspect state before any retry. Keep previous backups; no automatic destructive schema migration is provided.
17
17
 
18
18
  Earlier experimental engines use a different journal. Start a new state directory for the native 0.3 runtime; preserve old journals separately. There is no automatic import of their jobs or approval state.
19
19
 
@@ -136,6 +136,16 @@ Unknown formats/versions remain blocked. Published PR receipt reconciliation
136
136
  stays read-only, and compatibility does not relax the original-base/remote-target
137
137
  guard or add checkpoint continuation.
138
138
 
139
+ In 0.14.0, role overrides use v2 protected evidence and one frozen common policy.
140
+ Use [definition rollback](definition.md) through an idle controller to restore the
141
+ previous portable selection. It preserves all attempts and changes the definition
142
+ revision; it does not change separate private settings or credentials. Changed
143
+ roles invalidate checkpoint/new-publication evidence until the exact prior policy
144
+ is restored or a fresh complete cycle succeeds. Task-wide model overrides are
145
+ refused when role overrides are active; an old task with such a model needs a
146
+ replacement admission without it. Incomplete definition temporary files are ignored
147
+ on restart; never splice historical execution evidence into a new profile.
148
+
139
149
  Attempts made before this metadata existed display **Not recorded
140
150
  (legacy/unknown)**. Do not copy today's profile onto them. For an investigation,
141
151
  compare the retained per-attempt measurement, logs, candidate/check/review hashes
package/docs/setup.md CHANGED
@@ -183,6 +183,18 @@ An installation already using Codex account auth may set the validated
183
183
  Codex agent phases receive it. Pi and checks do not. See the [quickstart
184
184
  inference guidance](quickstart.md#connect-an-application) for constraints.
185
185
 
186
+ For separate Implement/Review/Investigate harnesses or models, export and review
187
+ [the portable role definition](definition.md), then explicitly apply its preview
188
+ through the idle controller. No overrides preserves the current private command
189
+ and legacy evidence. Do not put credential values, host paths, resources or
190
+ arbitrary command arguments in that file. Shared settings remain in private
191
+ `factory.json`; inference stays in `model.env`. Adoption starts no work or schedule.
192
+ Keep harness final-message capture in ephemeral `/tmp`, separate from durable
193
+ Factory reports. Review reuses protected exact-candidate checks; its read-only
194
+ workspace and noexec temporary space cannot repeat every dependency install or
195
+ executable fixture. Qualify each selected role with the actual image, provider
196
+ and platform; declared configuration and a discovered binary are not model proof.
197
+
186
198
  Checkpoint: record the exact source revision, image ID, check command, resource
187
199
  limits, inference connectivity and CI result. Keep product controllers stopped
188
200
  until their tasks are explicitly ready to run.
@@ -377,3 +389,44 @@ To add operator scope at admission, use `issue start --url URL --workflow softwa
377
389
  --brief-file operator.md --state PATH` with an optional UTF-8 brief of at most
378
390
  16000 characters. This keeps the remote identity and current-content check;
379
391
  local requests still use `issue start --file` or `--draft` without `--brief-file`.
392
+
393
+
394
+ ## Optional keyless local or hybrid inference
395
+
396
+ Use the [local binding recipe](definition.md#opt-in-local-bindings-0150-69) to adopt
397
+ an explicit private endpoint/model map and portable Pi role references. Keep the
398
+ working default and a stopped private-state backup; preview, apply while idle and
399
+ use revision-guarded rollback. A local Implement role can be paired with an existing
400
+ cloud Review role. No downloads, service restarts, port changes or jobs occur during
401
+ configuration. Authenticated endpoints, sampling overrides and custom thinking
402
+ maps are unsupported. Local bindings may request OpenAI-style `reasoningEffort`:
403
+ `default` (or omitted), `none`, `low`, `medium` or `high`. Default omits the request;
404
+ it does not disable server thinking. Qualify the endpoint's actual semantics before
405
+ using a request as a thinking-budget control. Unsupported requests fail without
406
+ fallback when the endpoint rejects them; transport success alone cannot prove a
407
+ server honored the request. Existing omitted choices remain unchanged.
408
+
409
+ Qualify the actual installed image and endpoint from an isolated job before using
410
+ it for application work. Record server/harness versions, exact model ID and digest,
411
+ quantization, GPU/backend and actual offload, available and peak memory, endpoint
412
+ reachability, tool-call/result compatibility and report/check/review outcomes.
413
+ Keep host inference access separate from controller/forge credentials. Unknown
414
+ values stay unknown; registry discovery only proves client capability.
415
+
416
+ Reconcile the client's configured context with the server's actual allocation and
417
+ per-request/model overrides. Do not infer a 65k allocation from a remembered agent
418
+ setting or a server default. A bounded 64k/128k allocation experiment, where
419
+ supported, must record KV-cache and Flash Attention settings, memory and allocation
420
+ success separately from long-context task quality. This worker supplies no such
421
+ measurements or driver/kernel advice. Do not recommend larger windows from the
422
+ schema's upper limit.
423
+
424
+ The operator still owns #69's matched two-fixture comparison: pinned bases,
425
+ comparable prompts/contexts/trials, a measured existing local baseline and one
426
+ selected alternative, decisive independent checks and separate Review contexts.
427
+ Retain failures, repairs and human time. Record wall time, observable prefill/decode,
428
+ input/cached/output tokens, memory/offload and all reviewer usage. Factory currently
429
+ leaves Pi usage unknown; controlled protocol fixtures are not token or quality
430
+ benchmarks. Include cloud Review in hybrid totals. No provider token billing for
431
+ local inference does not mean zero electricity, hardware or operator cost. Only
432
+ then qualify a suitable real Factory issue; no customer jobs are part of this slice.
package/docs/workflows.md CHANGED
@@ -5,7 +5,7 @@ installation with `factory definition --state PATH`, or its
5
5
  Agents, Skills and Definition pages. Both read the same effective catalog.
6
6
 
7
7
  Software follows **Implement → Check → Review → Accept & hand off**. Implement
8
- and Review are separate agent invocations using the installation's harness/model.
8
+ and Review are separate agent invocations using their resolved role profiles.
9
9
  Check runs the project's command. Accept requires operator approval and confirms
10
10
  that the candidate and policy still match their evidence. It does not push,
11
11
  merge, deploy or publish. Revisions start a new build/check/review and preserve
@@ -139,11 +139,12 @@ handling, resource limits and stop behavior. No schedule is created by onboardin
139
139
 
140
140
  ## Change the definition
141
141
 
142
- Select the harness, model, check and resource limits in the private `factory.json`
143
- while the installation is stopped, then restart. Workflow order and packaged
144
- skills change through reviewed Factory releases. This release does not support
145
- per-role profiles or arbitrary editable workflow graphs. Versioned editable
146
- definitions are tracked in [#53](https://github.com/arcitai/software-and-defence-factory/issues/53).
142
+ Version 0.14.0 supports portable harness/model selections for Implement, Review
143
+ and Investigate. Use the shared [role definition workflow](definition.md) to
144
+ export, validate, preview, apply while idle and roll back. Missing overrides
145
+ inherit the exact private installation profile. Shared checks/resources remain
146
+ in private `factory.json`; workflow order and packaged skills follow reviewed
147
+ Factory releases. Broader definition editing stays under #53.
147
148
 
148
149
 
149
150
  Inbox groups URL case, HTTP/HTTPS, trailing-slash, query and fragment aliases by GitHub