Skip to main content

Software Factory

@mgreten/software-factoryv2026.08.21.1· 1d agoMODELSREPORTSSKILLS
01README

A fully generic, model-driven state machine for guiding agents through a software development lifecycle. The entire machine — stages, transitions, gates, required artifacts, review skills, agent commands, system prompts — lives in the model definition's globalArguments as data. The engine ships no lifecycle concepts: adversarial review, comprehensive testing, release, and UAT stages are expressible (see examples/), never assumed.

How this package differs

This is not a different kind of software factory. It is an extended fork of the same generic engine published as @swamp/software-factory and @adam/software-factory.

The current published packages compare as follows:

Capability @adam @swamp @mgreten
Configurable stages, transitions, gates, and artifacts
Dispatch records and queryable status views
Bundled driver skill
Migrate an active run after its definition changes
Recover a terminal run without resetting its history
Bind approvals to exact artifact versions and contents
Attempt leases, heartbeats, retries, and orphan detection
Official @swamp package

This package is closest to @swamp/software-factory: both include dispatch recording, schema-validated artifacts and evidence, materialized status and validation records, a static work-item summary report, and a driver skill. Those shared capabilities are not unique to this package.

Compared with the currently published @swamp and @adam packages, this package additionally provides:

  • explicit, compatibility-checked migration of active runs to an edited factory definition without discarding their recorded history;
  • explicit recovery of a terminal run at a named non-terminal stage;
  • optional approval and rejection binding to exact artifact/evidence versions and canonical payload digests, plus immutable, non-authorizing authority challenges for those exact subjects; and
  • provider-neutral attempt leases, heartbeats, bounded retry outcomes, and orphan-attempt claims for workflow execution.

Use @swamp/software-factory as the simpler official default when those additions are unnecessary. Use this package for longer-lived runs that need definition migration, failure recovery, exact-subject approvals, or durable workflow-attempt tracking. @adam/software-factory is an earlier, smaller variant without the newer operational features shown above.

This is an engine, not a turnkey SDLC or an agent runtime. It does not ship a prescribed lifecycle, coding-agent provider, repository integration, issue tracker, CI system, or release implementation. Consumers supply those in factory definitions, workflows, and companion extensions.

How it works

An instance is a factory serving many work items concurrently — every method takes workItem, and all run data is namespaced per work item:

swamp model create @mgreten/software-factory my-factory
swamp model edit my-factory      # fill globalArguments: stages
swamp model method run my-factory start --input workItem=ISSUE-42

The driver loop is the same for every factory: status persists a self-describing packet (current stage, work spec with run-data bindings resolved, per-gate transition readiness, context manifest) as a queryable status-<workItem> record, and the driver reads exactly the fields it needs with swamp data query --select rather than re-parsing a whole blob; it then does the stage's work, records products, and advances. Gates are hard enforcement — evaluated in pre-flight checks and re-validated inside advance.

Methods

  • start — validate the graph and start a work item at the initial stage (refuses to restart; resume with status)
  • begin_attempt / heartbeat_attempt / complete_attempt / claim_orphan_attempt — provider-neutral workflow-attempt leases and bounded terminal decisions
  • migrate — explicitly adopt a compatible definition change for an active run without discarding its state, artifacts, or approvals
  • resume — recover a terminal run at an explicitly named non-terminal stage without destructive reset
  • status — the driver's entrypoint: what a work item requires right now, or a factory-wide overview of all runs
  • record_dispatch — record that a stage's work ran (before it runs); proves execution so a stage can't be skipped, and drives the runaway-loop guard (third dispatch of an entry hard-fails as runaway-loop-suspected)
  • record_artifact / record_evidence — versioned, schema-validated work products and external facts (every artifact and evidence carries a declared schema, validated on record; strict objects by default)
  • resolve_findings — resolution notes on kind: findings artifacts
  • mint_authority_challenge — mint an immutable engine-bound challenge for the current exact approval subject. This first legacy-subject increment is explicitly non-authorizing: it cannot approve, dispatch, or advance and does not claim trusted human approval.
  • approve / reject — human gate decisions, cycle-scoped; gates may bind decisions to exact artifact/evidence versions and canonical payload digests
  • advance — move along a gated transition
  • summary — full implementation history of a work item as markdown, rendered statically from the run data (no LLM); also persisted via the @mgreten/software-factory/work-item-summary report
  • validate / describe — definition lint; Mermaid + tables
  • reset — destructive restart, requires confirm=reset

Gates

artifact-exists, artifact-fresh (subject-version + recordedThisCycle), findings-clear, human-approval (optionally subject-bound), evidence-recorded (cycle-scoped, field matching), cooldown, max-cycles (routing), cel (CEL predicates over run data), workflow-succeeded (verified against swamp's own workflow run records, not driver attestation).

Every stage carries maxCycles (default 5): entries past the limit park the run for an explicit human cycle-override approval.

Run data

All resources are versioned, immutable, and namespaced per work item: state-<workItem>, artifact-<workItem>-<name>, evidence-<workItem>-<name>, approval-<workItem>-<gateId>, authority-challenge-<eventDigest> (content-addressed, non-authorizing prerequisite events), validation-<workItem>-<target> (recorded payload-validation failures, bindable as retry feedback), an append-only journal-<workItem>, and a status-<workItem> materialized view (refreshed on every status call; status-_factory holds the fleet overview) that the driver queries instead of scraping a log line.

02Models1
@mgreten/software-factoryv2026.08.21.1software_factory.ts
fn begin_attempt(attemptId: string, owner: string, leaseSeconds: number)
Acquire a provider-neutral lease for a workflow attempt.
ArgumentTypeDescription
attemptIdstring
ownerstring
leaseSecondsnumber
fn heartbeat_attempt(attemptId: string, leaseSeconds: number)
Renew an active workflow attempt lease.
ArgumentTypeDescription
attemptIdstring
leaseSecondsnumber
fn complete_attempt(attemptId: string, decision: enum, reason: string, result?: record)
Complete an attempt with a bounded retry, fail, or stop decision.
ArgumentTypeDescription
attemptIdstring
decisionenum
reasonstring
result?record
fn claim_orphan_attempt(attemptId: string, owner: string)
Mark an expired attempt lease orphaned, idempotently.
ArgumentTypeDescription
attemptIdstring
ownerstring
fn start()
Validate the definition and start a run for a work item at the initial stage. Fails if that work item already has a run (resume with 'status').
fn reset(confirm: string)
Destroy a work item's run progress and re-enter the initial stage. Requires confirm=reset.
ArgumentTypeDescription
confirmstringMust be the literal string 'reset'
fn migrate(expectedDefinitionHash?: string)
Adopt the current validated factory definition for an existing run without discarding its state, artifacts, or approvals. Refuses incompatible stage graphs instead of silently rewriting the run.
ArgumentTypeDescription
expectedDefinitionHash?stringOptional previous definition hash; when supplied it must match the persisted run hash
fn resume(targetStage: string, reason: string)
Resume a terminal blocked run at an explicitly named non-terminal stage without destroying its durable history. Intended for degraded recovery after a factory or environment fix.
ArgumentTypeDescription
targetStagestring
reasonstring
fn record_dispatch(stageId?: string, mode?: string, runId?: string, note?: string)
Record that the current stage's work is being executed — call this BEFORE dispatching subagents / running a workflow or method. It proves the stage ran (so it can't be skipped) and drives the runaway-loop guard: re-dispatching the same stage entry warns loudly, and the third attempt is rejected.
ArgumentTypeDescription
stageId?stringThe stage being executed; defaults to the current stage
mode?stringWork mode being executed (interactive|dispatch|workflow|method)
runId?stringWorkflow/method run id, for the audit trail
note?string
fn record_artifact(name: string, payload: union, note?: string)
Record (or re-record) an artifact declared on the work item's current stage. Payload is validated against the declared schema.
ArgumentTypeDescription
namestringArtifact name declared on the current stage
payloadunionJSON object payload (or a JSON string)
note?string
fn record_evidence(name: string, payload: union)
Record opaque external evidence declared on the work item's current stage (PR URL, CI outcome, release link).
ArgumentTypeDescription
namestringEvidence name declared on the current stage
payloadunionJSON object payload (or a JSON string)
fn resolve_findings(artifact: string, resolutions: array)
Mark findings on a kind: findings artifact as resolved, with notes.
ArgumentTypeDescription
artifactstring
resolutionsarray
fn mint_authority_challenge()
Mint an immutable, engine-bound, NON-AUTHORIZING challenge for the current exact approval subject. This is a prerequisite record only; it cannot approve a gate or authorize work.
fn approve(gateId: string, actor: string, note?: string)
Record a human approval for a human-approval gate or a cycle-override. When the gate declares a subject, the approval is bound to a digest of exactly those artifact/evidence records, so a later mutation invalidates it. Only call on explicit human instruction.
ArgumentTypeDescription
gateIdstring
actorstringWho approved (a human identity)
note?string
fn reject(gateId: string, actor: string, note: string)
Record a human rejection for a human-approval gate, with a reason. When the gate declares a subject, the rejection is bound to that exact subject — reworking it clears the block; re-seeking approval on the same subject does not.
ArgumentTypeDescription
gateIdstring
actorstring
notestringWhy this was rejected
fn advance(transition: string)
Move a work item along a named transition. Gates are evaluated in pre-flight checks and re-validated here.
ArgumentTypeDescription
transitionstring
fn status()
What is required right now for a work item — or, without workItem, an overview of every run on this factory.
fn summary()
Render the full implementation history of a work item — every stage visit, artifact version, finding, approval, and transition — as a markdown report built statically from the recorded run data.
fn validate()
Lint the definition: meta-schema + graph rules. Fails when errors exist.
fn describe()
Render the state machine (Mermaid) plus stage/transition tables.

Resources

state(infinite)— Per-work-item stage, cycle counts, and run status (instances: state-<workItem>)
artifact(infinite)— Versioned, schema-validated data products (instances: artifact-<workItem>-<name>)
evidence(infinite)— Schema-validated external facts recorded by the driver (instances: evidence-<workItem>-<name>)
approval(infinite)— Human gate decisions, cycle-scoped (instances: approval-<workItem>-<gateId>)
authority_challenge(infinite)— Engine-minted immutable non-authorizing challenge events (instances: authority-challenge-<event-digest>)
validation(infinite)— Recorded payload-validation failures, bindable as retry feedback (instances: validation-<workItem>-<target>)
journal(infinite)— Append-only audit trail per work item (instances: journal-<workItem>)
status(infinite)— Materialized 'what is required next' view, refreshed on every status
attempt_lease(infinite)— Provider-neutral workflow attempt lease and outcome
03Reports1
@mgreten/software-factory/work-item-summarymethod
work_item_summary_report.ts

Linear implementation history of a factory work item, rendered statically from its recorded run data

software-factory
04Skills1
software-factory7 files
05Previous Versions5
2026.08.19.1
2026.08.18.2
2026.08.18.1

Modified 1 models

2026.08.12.2

Modified 1 models

2026.08.10.1

Initial @mgreten maintained fork: subject-bound approvals, recovery note validation, approval subject diffs, dispatch override recovery, definition-drift journaling, and corrected workflow gate binding.

06Stats
A
100 / 100
Downloads
6
Archive size
212.8 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License declared1/1earned
  • Verified public repository2/2earned
07Platforms
08Labels