The .factory folder
Everything the runtime writes is in .factory/, at the factory repo's root: the folder the session or the factory command runs from. It is generated: add it to .gitignore, and don't sync it between machines. It belongs to the host that runs the factory.
.factory/
├── factory.json the lines and stations the session read at start
├── stations/IN1/
│ ├── input/ doing/ output/ done/ failed/
│ ├── output/approved/ a sub-bin
│ ├── intake-registry.jsonl a line head's registry (ctx.seed)
│ └── cursor.json a line head's cursor (ctx.cursor)
├── work_records/<work_record_id>/ a local copy of what a run attached, and its files
└── runs/IN1.json the output of the last npx factory stations run IN1
| Path | Written by | Holds |
|---|---|---|
factory.json | startBinWatcher(), when the session starts | The lines at this session's location and their stations, as the Orchestrator held them. Read by al-control and by tests. |
stations/<CODE>/<bin>/ | the lib, the conveyor and your station | The station's bins, each holding workpiece folders |
stations/<CODE>/intake-registry.jsonl | ctx.seed only | One line per item taken in: { workpiece_id, dedup_key, seeded_at }, plus reason and workpiece_id: null for a skip |
stations/<CODE>/cursor.json | ctx.cursor | The cursor's last saved value |
work_records/<id>/ | the attach calls, and your station through workRecordFile | report.md, documents, attached files and workpieces.json (the outcomes the run reported) |
runs/<CODE>.json | npx factory stations run | What the station returned |
The lib never deletes work record folders or finished workpieces; a job in your factory does. temp/ at the factory root is the factory's own scratch: the lib doesn't write there.
bin(station, ...segments)
Returns the absolute path of a station's bin, or of a folder under it, and creates it.
bin('IN1', 'input'); // <root>/.factory/stations/IN1/input
bin('IN1', 'output', 'approved'); // <root>/.factory/stations/IN1/output/approved
workRecordFile(work_record_id, filename)
Returns the absolute path of a file in .factory/work_records/<work_record_id>/, and creates the folder. Use it for a file about the whole run, such as a spreadsheet to attach:
const file = workRecordFile(ctx.work_record.id, 'invoices.xlsx');
See Where a station keeps its data.
The root is fixed at import
bin() and workRecordFile() resolve from the current directory at the moment lib-factory is first imported. A test that runs a station in a temporary folder changes into it before importing the lib: see Run and test a station.