Use these commands with an existing Factory journal and a prepared JSON request. They expose the accepted local Branch health and Owner policy modules. Live polling and ask import still need their separate commission.
Prepare the inputs
Use Node 26.8.1 or later from the repository root. Keep the journal and request files on trusted local storage. Each input must be a regular UTF-8 JSON file of at most 65,536 bytes. Final symlinks, devices and pipes are refused. The commands never create a journal, register a Product or send a message.
Keep request files private: subjects and rules retain the words supplied. Use the owner's stated words and times; missing facts stay unknown. See the module references for watch targets and ledger requests. Those references own the input contracts.
Poll branch health once
Prepare a watch file containing the Products, repositories and branches to read:
[
{ "productId": "example", "repository": "owner/example", "branch": "main" }
]
Choose the poll's actual start time in UTC, including milliseconds. Save that instant with the watch file before running:
npm run factory:bet -- branch-health poll \
--journal /path/to/existing.sqlite \
--watch /path/to/watch.json \
--gh /absolute/path/to/gh \
--at 2026-09-30T12:00:00.000Z
Replace the example time and paths. The executable must be an absolute path to the intended gh; sign-in remains outside this command. The reader uses the existing filtered environment and GET-only transport. There is no automatic retry or schedule.
If the outcome is uncertain, retry with the same instant and watch file. Recorded Products replay without fetching again; pending Portfolio mirrors can retry. A changed repository or branch at the same instant returns a conflict for that Product. A poll records each Product separately, so its report can contain both completed and refused Products. Do not change the instant merely to bypass a conflict.
Record an ask, answer, update or weekly note
Prepare the corresponding request from the Owner policy contract, then choose its action:
npm run factory:bet -- owner-policy channels --journal /path/to/existing.sqlite --input /path/to/channels.json
npm run factory:bet -- owner-policy ask --journal /path/to/existing.sqlite --input /path/to/ask.json
npm run factory:bet -- owner-policy answer --journal /path/to/existing.sqlite --input /path/to/answer.json
npm run factory:bet -- owner-policy update --journal /path/to/existing.sqlite --input /path/to/update.json
npm run factory:bet -- owner-policy note --journal /path/to/existing.sqlite --input /path/to/note.json
Record the first channel list before asks or updates. Its zone defines the ledger's weeks; its live flag has the meaning specified by the contract. A weekly note covers a week that has ended and was not already over when the ledger opened.
Retries use the same request, including its identity and timestamps. Changed content under an existing identity is a conflict. Recording a rule neither applies it nor grants permission to act. Recording an update does not send it.
Read the result
The command writes one JSON result. For machine use, run node scripts/factory-bet.ts with the same arguments to avoid npm's own banners. Errors also write a short code to standard error, without copying the input. Use --help for the command summary.
| Exit | Meaning |
|---|---|
| 0 | Command completed. Health can still be red or unknown; inspect the report. |
| 2 | Partial poll: inspect every Product's outcome and mirror status. |
| 64 | Invalid arguments or input. |
| 65 | Command conflict or revision mismatch. |
| 66 | Input or journal unavailable. |
| 70 | Other error; inspect the code. |
| 75 | Limit or contention. |
An error's effect is not-started before the journal opens, otherwise conservatively unknown. It is not proof that a write happened. Keep the original identity while resolving uncertainty. Missing, empty, foreign and unsupported journals are refused without initialising them. File checks do not defend against a hostile process replacing paths concurrently.
