Your data
Find your data, export it to a text file, back it up and move it to another machine. Your cases, results and decisions are yours, and you can take them out at any time.
Where the data lives #
Mainworthy keeps structured records in PostgreSQL 18, selected by MAINWORTHY_DATABASE_URL.
compose.yaml starts that database with its own named volume. Running elsewhere is possible but not yet supported.
Attachment bytes live in blobs/ and archive transfers use spool/ in the app data directory.
That directory defaults to ~/.mainworthy, or /data in the container. Set MAINWORTHY_DATA to change it.
PostgreSQL controls database storage, access, and write-ahead logging. Mainworthy no longer opens a SQLite file, makes upgrade copies, runs reader or checkpoint threads, or locks a local database directory. Secure and back up both PostgreSQL and local attachments. The app volume contains only the files.
At startup, the server takes a migration advisory lock to keep other instances from migrating the database at the
same time. It installs the PostgreSQL baseline on an empty database, then recovers pending work. During startup,
/health returns HTTP 503 with ok: false and state: "upgrading". Other requests receive HTTP 503 with
Retry-After: 5 until the server is ready. Readiness requires ok: true.
A result can correct only another result in the same project. If an upgrade finds a stored correction that crosses projects, it stops and names both results and projects. The database stays at its previous schema. Startup fails until you remove that row.
Schema 27 refuses to upgrade a database if the release before it, schema 25, still needs to repair it. The error identifies the problem. The database may be below schema 12, may still need to reconcile inherited standing on a commit that heads two changes, or may hold a disputed run without its question. Start the schema 25 release with the job runner on. Wait for the repair to finish, then upgrade.
The PostgreSQL conversion starts with an empty database. Existing SQLite records do not move automatically into PostgreSQL. The old SQLite file remains untouched on its volume. Its identities, tokens and sessions do not sign in to the new database. There is no automatic data conversion or upgrade-copy rollback.
On SIGTERM or SIGINT, the server stops accepting connections and closes change streams. Requests in flight
have five seconds to send their replies before remaining connections close. The server then closes its database
pools. If a write loses its reply, retry with the same command id, cmd, so it is not applied twice.
The server writes the whole archive to a temporary file before sending it. It also saves the entire upload
before reading it. Leave enough space for transfers that overlap. Only the server user can access the temporary
directories and files. The server removes them after a transfer completes, fails validation, or is cancelled.
If the server process is killed, it can leave files in spool/. Stop the server before removing that directory.
The database holds every project, case, version, result, decision, and policy. It also holds actors, grants, and a hash of each token. Protect the database as you would any private data. The privacy page explains what Mainworthy keeps about people and for how long.
Mainworthy names each attachment file by its SHA-256 hash. Identical content shares one disk file, even across
results. Back up blobs/ with the database. The files are necessary to restore attachments. An archive keeps
each file's bytes once, as base64 under its hash. The archive digest covers those bytes. Import checks each
file's hash, size, and content type against the rows that name it.
By default, export refuses to continue if attachment content is unavailable. It counts all failures and lists the first 100 missing or damaged attachments by attachment id and result id. If the list is longer, it ends with "and N more". An export also fails on storage I/O errors.
There is no automatic evidence expiry or total disk quota. Monitor free space and budget for retained attachments and temporary archive files. A failed write or import can leave an attachment file that no record references. A background job removes these files once they pass a grace period. Each upload refreshes the file's age before writing or reusing its bytes. This keeps a cleanup job on another instance from removing the file while the upload transaction is still within its time limit.
Mainworthy keeps referenced evidence when it forgets the person who reported it. Attachment contents and file names may contain personal information. Mainworthy does not scan or redact them.
Recover from an unverifiable assertion cause #
If an operation reports invalid: cannot reconstruct assertion root <id>, a stored
assertion cause's hash matches neither its normalized text nor a verified file-split cause.
Startup schedules the assertion rebuild as a job; a failed rebuild leaves the server available
for other work. The affected project may refuse operations until its evidence is repaired.
Import refuses an archive with the same inconsistency and rolls back.
- Stop the app and preserve PostgreSQL plus the attachment directory. Follow Back up.
- Keep the exact error, signature id and image commit that refused to start.
- Restore a tested database backup and its attachments to an isolated instance, or import a matching archive into a fresh PostgreSQL database. Check its evidence before directing traffic to it.
Without a tested backup, keep the preserved data and request a repair of the named signature. There is no automatic repair command for this error. Changing hashes or deleting evidence to force a rebuild bypasses the consistency check rather than repairing the recorded cause.
Export everything #
To export your whole organisation, run the command below with the admin capability, which lets you manage
membership, tokens, and grants and accept policy changes. In server mode, supply a token with admin using
--token or MAINWORTHY_TOKEN.
The archive contains every project in your organisation and its people, agents, pipelines, teams, and grants. Other organisations' records stay private. Mainworthy takes one consistent snapshot while the server keeps handling requests.
$ mainworthy export --out mainworthy.gz
exported to mainworthy.gz
Only the operator who runs the instance (MAINWORTHY_OWNER) can export every organisation in it. Use
mainworthy export --instance --out instance.gz or GET /api/export?instance. On an instance with one
organisation, such as a self-hosted instance, both archives contain the same projects, people, and command
history. The instance archive also contains the instance's own settings.
If cleanup of a retired demo is pending, the server refuses a whole-instance export. Retry after cleanup. You can still export an active project. This prevents a restore from bringing back retired data without the local record that tells Mainworthy to clean it up.
When content cannot be recovered, explicitly use mainworthy export --omit-unavailable-attachments --out recovery.gz
or GET /api/export?omit-unavailable-attachments. Combine it with --instance or --project for that scope.
This produces an incomplete backup and warns about the number of omissions. It does not change stored source rows.
It keeps every other record and each valid attachment's bytes, including a valid attachment sharing a hash with
an invalid row. Unexpected storage I/O errors and a file changing between inspection and its second read still
fail the export; they never produce a completed archive.
Import retains attachment metadata and the original step trail, including the positions of omitted screenshots.
A screenshot whose content is omitted remains unavailable; later screenshots keep pointing to their own files.
It reports the omitted count
and the first 100 attachment ids, result ids and reasons, followed by "and N more" if needed.
Keep the first archive for the original omission reason: after restore, a re-export records previously damaged content as missing if its bytes remain absent. An ordinary unexplained absent blob still refuses import.
CLI import prints omission warnings and includes the count and warnings in --json output. Import refuses an omission if matching bytes already exist in the destination store, including unreferenced files left by a failed import; use separate empty attachment storage for that restore.
A successful export exits 0, including an explicit export with omissions. Programs must read omittedAttachments
in export's --json output or the numeric x-mainworthy-archive-omitted-attachments HTTP response header.
Both are zero for a complete export. The finished archive's final JSON line also includes omittedAttachments,
alongside end: true and sha256, so a program can read the count without importing the archive.
Import checks that this count matches the omission records covered by the digest. Unknown export query keys,
including misspelled scope or omission options, are refused as invalid input rather than using defaults.
A file name that ends in .gz is compressed, and any other name is plain text. Mainworthy makes the file readable only by you. It builds the file beside the destination and renames it when the export is complete. A failed export therefore leaves an earlier backup alone. The web UI has no export button.
Format 3 replaces format 2. Older builds refuse format 3, and this build refuses earlier formats. The archive schema remains 49 because the exported table layout is unchanged.
An archive is one text file with these sections in order.
- The first line identifies archive format 3 and lists the tables in restore order.
- Each table starts with a line naming it and its columns. PostgreSQL
COPYtext follows, with one tab-separated row per line. It uses\Nfor NULL and backslash escapes for tabs, line feeds, and backslashes. The line\.ends the rows. The next line gives the row count, byte count, and SHA-256 of the rows. - Each unavailable attachment has a line with its id (
omittedAttachment), result id (result), expected SHA-256 (hash), size, and reason (missingordamaged). The final digest covers these lines. - Each available attachment's bytes appear once under their hash, as lines of base64 ending in
\.. - The last line gives the SHA-256 of everything before it and the total
omittedAttachmentscount.
$ gunzip -c mainworthy.gz | head -c 120; echo
{"mainworthy":"archive","format":3,"schema":49,"exportedAt":1791875678677,"tables":["meta","orgs","actors",
$ gunzip -c mainworthy.gz | tail -n 1
{"end":true,"sha256":"ca0a5d4d76fe0de47415d595159393df3fad4fc517e4227325a4e5b5ca6b9cf7","omittedAttachments":0}
You can read the archive with any tool that reads text or search it with grep. A table's rows are what psql's \copy writes, so other tools read them too. If the data is suitable for version control, you can keep the archive there.
The archive holds attachment bytes along with the database records, and actors, personal and team grants, memberships and team history. It leaves out tokens, sessions, linked identities, invitations, sign-up records and billing records. It also leaves out the search and assertion-presence indexes. Mainworthy rebuilds both on import. Tracker delivery requests are excluded, so restoring an archive never sends an issue again.
The archive leaves out which changes have ended. After an import every change is open. Questions that were closed when a change ended stay closed. If a failure on such a change is reported again, use mainworthy change to record again that the change ended.
The archive also leaves out which project is a demo. An imported demo keeps its data and its dates, and accepts no more writes dated in the past. Anyone who reads the archive reads your cases and decisions, so store it as you would the data itself.
Export one project #
To export one project of your organisation, run the following command with the project's key. As with an organisation export, you need an organisation-wide admin grant.
$ mainworthy export --project shop --out shop.gz
exported to shop.gz
The archive keeps the project's cases and versions, results and their attachment bytes, runs, questions, decisions, policies, and command history. It keeps case aliases, custom field definitions in the policy, IDs, head hashes, and verdicts.
The archive includes the organisation and its owner. It also includes actors from that organisation who acted
in the project, signed its decisions, or have a grant on it, plus the people they act on behalf of. It includes
the actor recorded as rule. This actor represents the policy when it answers automatically. It keeps grants on the project or on every project.
Relevant teams in the organisation keep their memberships, grants on this project or every project, and history for that scope. Other projects, their grants and team grant events, instance metadata, and commands outside the project stay out. The archive also excludes every actor, team, and grant from other organisations. Tokens, linked identities, and other sign-in records stay out.
The HTTP equivalent is GET /api/export?project=shop, with the same admin requirement as an organisation's export.
The key is looked up in your organisation: a key that only another organisation holds is an unknown key, and an unknown key is an error. Without --project, the command exports your whole organisation, even when
MAINWORTHY_PROJECT is set. The operator imports any of these archives into a fresh instance with the command below,
which is how an organisation moves to an instance of its own. Import refuses an instance that already has data, and
only the operator may import. After an import the first organisation is the operator's until they hand it to its
owner with mainworthy admin --do org.transfer --to <name>.
Archives preserve recorded project command replies.
A matching imported command can still be retried with its original command id.
The archive must be of this build's format and archive schema; an archive of format 1, written by a build before
2026-11-09, and one of an older schema are refused. Export again with the build that wrote it.
Import also refuses an archive whose inherited standing on a commit that heads two changes rests on one of them
alone, or that is still marked for the repair of that standing. The release before schema 27 repaired both on import:
import the archive there, export it again, and import that archive. Import also refuses an archive holding a disputed
run without its dispute question, which that release's recover-disputes job gave it: import the archive there with
the job runner on until that job has run, export it again, and import that archive.
Import also refuses text a database column cannot hold: a NUL character (U+0000) or half of a two-unit character,
whether PostgreSQL refuses it in the value itself or inside the JSON a column holds, such as a proposal's resolved
edits, a pending batch's results, a question's subject or evidence, a decision's answer, a grant or a run's accepted
commit. The error names the table, row and field, and nothing is imported. It also refuses JSON in those columns that
PostgreSQL cannot read as jsonb, such as a number too large to store or JSON nested too deep, naming the table, row
and PostgreSQL's reason. Import never rewrites such a value, since that would change the archive's content.
Export and verify an audit #
If you have admin on the project, you can export its retained decision history for a time range. Run the export command, then verify the saved file.
mainworthy audit export --project shop --from 2026-10-01T00:00:00Z --to 2026-10-15T00:00:00Z --out shop-audit.ndjson
mainworthy audit verify shop-audit.ndjson
--from includes the start and --to excludes the end. Dates are nonnegative Unix
milliseconds or ISO timestamps with a timezone. Omit both for all retained history
through the server's current snapshot. An end later than the snapshot time plus one
millisecond is refused. The export uses the selected project's admin capability and
writes a private file atomically. The file is plain NDJSON. The operation buffers
the reply in memory. For large histories, select a smaller period.
The registry equivalent is audit { from, to } at POST /api/p/<project>/audit.
Its JSON reply contains format, project, records, sha256, and ndjson.
The operation reads one consistent snapshot and records no write. The web UI has
no audit export control. mainworthy audit verify <file> needs neither a running
server nor a token. Exit code 0 means the file passed the structural checks. Invalid
files exit 4. --json prints the record count, checksum, number of before-range
references, and number of decisions without a recorded historical evidence hash.
Quarantine decisions retain the test ref, prior quarantine decision and exit rule in their immutable effects, including manual exits and replaced entries. Their signers retain the person's reason. The current quarantine row is not a historical audit record.
Audit format 1 #
Each line is canonical JSON with lexically sorted object keys and one LF. The file
uses UTF-8 without a byte-order mark and ends with an LF. The header has
mainworthy: "audit", format: 1,
project, from, to, exportedAt, and the snapshot's project seq. It also
states grantChanges: "team-history-only", teamState: "at-export",
evidencePayloads: "not-retained", and
actorNames: "at-export".
Context records come first, sorted by id using English collation. Events follow,
ordered by time, sequence, and id using the same collation. Events without a
sequence sort as sequence zero. Verification refuses records outside this order.
English collation uses JavaScript's a.localeCompare(b, "en") rather than character order.
It compares the digit runs in an id as text but puts : before digits.
For example, version:1:2 comes before version:12:1.
A verifier in another language needs the same Unicode collation, using ICU with locale en and default strength.
This file order does not imply that timestamps follow reference dependencies.
Each record has a type and a unique id:
| Type | Content |
|---|---|
question | question:<id>, public ref, kind, fingerprint, openedAt, openedSeq, and prior question reference. Only referenced questions and their predecessors are included. |
evidence | evidence:<question-id>:<hash>, question reference, and the recorded hash. This is a digest record, without the original input payload. |
result | result:<id>, immutable test, target, commit, repository, environment, job, method, producer, outcome, signature, time and sequence for inherited head and base results. These context records can precede from. |
team | team:<id>, name, creation time, current members and current grants on this project or every project. This is state at export time, including for a historical range. |
team-event | team-event:<id>, time, team reference, actor, action, affected person, project and capabilities. Includes scoped grant changes and membership history in the range. These instance events have no project sequence. |
change-end | change-end:<change-id>, change id, key, repository, ending time, and state, either merged or closed. Includes the retained ending for this project's changes when its time is in the range. No ending actor or sequence is retained. Reopening deletes the ending, and a later close replaces it. This is not a full change-state history. |
merge-receipt | merge-receipt:<id>, change id and key, reporting actor, server report time and sequence, and the frozen head gate. The receipt is a bounded manifest with its gate summary, result and evidence counts, and content hash. Frozen results and gate collections are exported in separate bounded pages; supporting decision ids refer to the immutable decision ledger. All retained receipts in range are included, even after a corrected head, reopening or closing clears their active selection. The time is when the merge was reported, not when it happened. |
decision | decision:<id>, time, sequence, kind, answer, basis hash, holds, effects, expiry, question, prior decision, evidence, signers, and typed inherited result and base references. Each signer retains its actor, clause, policy version, and reason. Withdrawals, expirations, and outdated decisions are included. |
answer | answer:<id>, time, sequence, actor, question, answer, reason, whether it counted, and the exact evidence hash seen. Advice is included. |
policy | policy:<version>, time, sequence, actor, preset, clauses, settings, previous policy, and adopting decision. The initial policy has no adopting decision. |
case-version | version:<case-id>:<version>, public case ref, time, sequence, author, reason, full body, body and claim hashes, parent version, and adopting decision. |
A range export contains receipt manifests, not their result payloads. For every receipt you need, export evidence pages separately. The full-history decision export retains the immutable answers, signers, holds, basis and expiry that result standings reference; a narrow time range may omit an earlier decision, so keep that earlier history too.
mainworthy audit export --out receipt-12-page-1.ndjson --receipt 12 --limit 50 --json
mainworthy audit export --out receipt-12-page-2.ndjson --receipt 12 --cursor 12.evidence.49 --limit 50 --json
Use the cursor from each reply to request the next page. Stop when the cursor is null. Each file is
independently verifiable with audit verify. The API reply also names snapshot and
evidenceCount. A page has at most 50 members and 64 KiB of source evidence. Each
merge-evidence record carries receipt id, ordinal, kind (result or gate), body and
full SHA-256 of its UTF-8 body. Order all members by ordinal; require exactly
evidenceCount contiguous ordinals starting at zero, with gate records first and result records ordered
by numeric result id. Version 2 uses the following canonical tree hash in place of the unpublished flat-list hash.
- Recompute each body's SHA-256 and require it to match the record's
hash. - Build separate radix-32 trees for results and gate records. Result keys are their frozen numeric
resultids. Gate keys are zero-based positions among gate records. Keys must be unique nonnegative safe integers. - A leaf, level 0, groups keys by
floor(key / 32). Its entries, ordered bykey % 32, are[slot, bodyHash, 1]. Hash the UTF-8 JSON array["mainworthy.receipt.node.v2",0,entries], without spaces. - Group the resulting nodes by the same rule for levels 1 through 10. Each entry is
[childKey % 32, childHash, childMemberCount]; its parent key isfloor(childKey / 32). Hash["mainworthy.receipt.node.v2",level,entries]. Omit missing children and empty nodes. The count of a branch is the sum of its child counts. After level 10 there is one root per nonempty tree. - An empty tree has a null root hash. Hash
["mainworthy.receipt.snapshot.v2",resultRootHash,gateRootHash]with the same JSON encoding and require it to equalsnapshot.
This reconstructs roots from exported bytes, independently of database node ids or edit history. All
numbers and slots use numeric order. Completeness requires both the counts and root hash to match.
Verifying one page alone does not establish bundle completeness. The result body is JSON with frozen result fields and its
supporting decision id and displayed answer. Gate bodies are JSON frames: collection: open
contains numbered part text chunks which join to the original blocking-ref JSON array;
collection: waiting contains one complete shard-wait item. Exports and reads never
recompute historical standings. A manifest alone is not a complete receipt evidence export.
An actor contains id, name, and kind. Names reflect the time of export and use
a pseudonym after forgetting. A reference is { scope: "included", id } or
{ scope: "before-range", id, at }. Only event references can precede the range.
Their at must precede from. The exporter resolves the original event in the same
project before creating that marker. Question and evidence context always appear
inside the file.
A signer's numeric policy resolves to policy:<version>. A full-history file
has from: 0 and to: exportedAt + 1: the exclusive end includes the export
millisecond. Every other range is partial, including a to-only export ending
earlier. A full-history file must include every signing policy; verification
checks that each included policy's project sequence does not follow its decision.
In a partial file an omitted positive signing policy counts once per signer in
omittedSigningPolicyReferences, separately from timestamped before-range
markers counted in beforeRangeReferences. The header and numeric signer version
do not distinguish an omitted policy before from from one at or after to.
Policy version order need not match timestamp order, as demo seeds write past
history after project creation. Partial verification cannot confirm an omitted
policy's existence, date, or sequence, so success does not establish those signing
policies. Included policies receive the same sequence checks in both file types.
Neither file type proves server authenticity: the checksum detects byte changes,
but a rewritten file can have its checksum recomputed.
Recorded evidence is { state: "recorded", hash, ref }. A decision made before
migration 16 has { state: "not-recorded" } because its exact seen-evidence hash was
not retained. Its material basis remains available. A policy change or case version
reaches its evidence through the adopting decision. The initial policy has none.
The footer is { end: true, records, sha256 }. records counts context and event
records, excluding the header and footer. sha256 covers every preceding UTF-8 byte,
including LFs. Verification refuses a leading byte-order mark. It also rejects the following:
- Unsupported formats.
- Unknown keys.
- Noncanonical lines.
- Records out of order.
- Duplicate ids.
- Unresolved or wrongly typed references.
- Invalid range markers.
- Reference cycles.
- Skipped case or policy predecessors.
- Decisions or answers before their question's opening sequence.
- Inconsistent evidence hashes.
- Changed case body hashes.
Record errors name the line and record id when it can be read.
Demo projects can date writes out of order, so a predecessor can appear later in
the event list. If a time range excludes a required demo predecessor that has a later
date, export fails and asks you to widen --to.
Verification checks the file's integrity and internal references. The checksum alone cannot verify the source or show whether the export includes every database record. An offline verifier cannot confirm old events outside the file or reconstruct the original evidence payloads. Team history covers teams with current or historical grants on this project or every project. Other project grants and their events stay out. Personal grant changes have no complete event history. An admin request sent with a command id can leave a receipt with the actor, time, and outcome. These optional receipts retain a request digest rather than the action and cannot reconstruct all grant changes. They are not exported. Membership removal by forgetting has no retained event history. Current team state cannot prove who was eligible to sign in the past. Mainworthy has no signatures with re-authentication and meaning, retention, legal hold, or recorded text redaction. A passing file check is not a regulated conformance claim.
Migration 16 adds nullable decision evidence hashes to instance archives. It
preserves the current archive version because a missing hash imports as NULL and
exports as not-recorded. Older archive versions still need their matching build.
Bring cases from another tool #
Use mainworthy import with --format csv, --format testrail, or --format qase
to propose cases in the selected project. Unlike an archive import, this adds cases
to an existing project. Mainworthy groups the file into proposals of at most 200 edits. The project's policy determines who must accept them.
Exit code 0 means every proposal was adopted. Exit code 2 means at least one part needs attention.
For a split import, proposals lists every response envelope, including refusals. Each successful
response names its proposal and question. Accept it through the queue when the policy asks.
For custom column mappings and a server-side dry run, use Import cases from a mapped CSV. The commands below use fixed column mappings.
mainworthy import cases.csv --format csv --project checkout
mainworthy import testrail.csv --format testrail --project checkout
mainworthy import qase.csv --format qase --case-prefix PAY --project checkout
The file must use UTF-8, comma separators and a header row. Quoted cells may contain commas, doubled quotes and line breaks. Each file is limited to 32 MB. Mainworthy parses the whole file before sending it. Malformed files produce no proposals. If an alias already exists, Mainworthy refuses its proposal. Each proposal applies in full or changes nothing. A proposal waiting for review does not hold up the others. Imports create cases. They do not update cases with matching foreign ids. If a connection fails, keep the proposal receipt. Before sending a file again, check the project, especially if the file has no ids.
For a spreadsheet, use these exact headers. Only title is required.
| Header | Meaning |
|---|---|
id | Foreign alias, such as OLD123. Leave empty if none exists. |
title | Case title, from 1 to 300 characters. |
preconditions | Preconditions as text. |
steps | One action block, which may contain line breaks. |
expected | Expected result for that action block. |
execution_type | manual, automated, to-be-automated, or not-applicable. Empty means manual. |
folder | Folder path, such as Checkout/Coupons. |
tags | Comma-separated tags that follow Mainworthy's tag grammar. |
id,title,steps,expected,execution_type
OLD123,Apply coupon,Enter SAVE10,Total falls by 10%,to-be-automated
An automated case gets the auto method. A manual case gets human.
to-be-automated keeps human and sets automation intent to wanted.
not-applicable keeps human and sets intent to not-applicable.
TestRail CSV must include ID and Title. C1234 remains an alias, so
mainworthy get C1234 reads the imported case. Include Section and Section Depth
to recreate nested folders, including their parents. A section that holds no case of its own has no row in TestRail's export.
If a parent section has no row, the importer places its child under the preceding section. Check the folders after an import.
Text steps use Steps and Expected Result. Separated steps use Steps (Step) and Steps (Expected Result).
A following row with an empty id and title, or the same id and title, adds a step.
Automation Type uses the execution values above. If it is empty or absent,
Type equal to Automated selects auto. Other testing types keep human.
References entries that are requirement keys become coverage links.
Qase CSV supports the older id header and the current v2.id header, with title.
Numeric ids become QASE-123 by default. Pass the source project key with
--case-prefix PAY to keep an alias such as PAY-123. Suite definition rows and
suite_id, suite_parent_id, and suite become folder paths. The automation
slugs is-not-automated, to-be-automated, and automated map to the methods and
intent above. steps_actions, steps_result, and steps_data must have matching
numbered entries. Step data follows its action under Data:. Current v2 classic
steps decode their quoted JSON strings. Gherkin actions stay plain text. Child
steps become flat steps with paths such as [1.1] in their actions. Use v2 when
an older export has multiline step content that cannot be read as numbered lines.
Aliases are unique within a project and case-sensitive. They contain at most 120
ASCII letters, digits, _, ., :, /, or -, and start with a letter or digit.
An alias cannot be a bare number or start with C-, Q-, R-, T-, or P-,
in either letter case, because those names belong to Mainworthy.
An alias is another name for an imported case. You can use it with get, history and a typed result sent through report with test: {case: "C1234"}.
Report annotations and properties accept it too. For example, a JUnit test named
signs in @C1234 or with the property mainworthy=C1234 identifies the imported case.
Aliases keep their original letter case and resolve within the report's project.
See Link tests to cases for the other formats and version claims.
Every source case column, including dates, descriptions, custom fields and any history
column, stays in the case body's fields as JSON under import.<format>.row.<record>.
Read it with mainworthy get C1234 --md or export the instance. Tags outside
Mainworthy's grammar stay there but do not become tags. The imported case starts
at version 1 with the importing actor and time. Source metadata does not create
native revisions, results, actors, or decisions. The checked vendor CSV examples
contain snapshots, not revision history. These case importers do not support XML, JSON, XLSX, attachments, earlier revisions, or results.
Parser diagnostics from mainworthy import --format csv|testrail|qase quote external values and escape terminal
control characters. Diagnostics shorten long suite and step-type identifiers. For an invalid execution type, they show the full value and explain how to correct it. A CSV read failure shows the quoted filename and filesystem error code.
All CLI errors fold CR/LF runs into ; and escape other controls. Imported case content stays unchanged.
Human-readable CSV previews also escape controls in case titles, folders, aliases
and refusal messages. CLI warnings, receipts and Markdown output apply the same
terminal protection. Canonical Markdown keeps its line breaks and encodes controls
and command prefixes reversibly, so parsing get --md or fmt output recovers the
original values.
Import into a new instance #
An import loads an archive into a new instance. A full archive restores every project it contains. A project archive restores only the selected project. Import does not merge data. While import runs, requests to read or write the tables it fills wait for it to finish. A new instance has no other data to serve. The /health endpoint still answers.
Browser-initiated imports require recent proof of the caller's own credential in
that session, checked again after upload before import begins. If the server returns recent_proof_required, confirm it is you again and retry. Bearer-token CLI and local
imports keep their existing operator authority.
To import an archive, follow these steps:
- Start a new instance, and make no changes before importing, apart from the sign-in a browser import needs (step 2).
- Run
mainworthy importwith the archive. The CLI imports with a bearer token or in local mode, so it needs no recent proof. To import from a browser session instead, sign in with the owner token, or confirm it is you with the provider, within ten minutes of the import.
$ mainworthy import mainworthy.gz
imported 67 rows across 49 tables
Import replaced the bootstrap rows. Your previous session may no longer exist. The configured local owner was refreshed.
A .gz suffix tells the command to decompress the file. The server imports the archive in one transaction.
- It empties the new instance's initial rows and removes the tables' foreign keys and plain indexes.
- It streams each table's rows in with
COPYand checks the row counts, table digests, and archive digest. - It restores the indexes and foreign keys. This checks every foreign-key reference once. The server then checks the references and constraints that foreign keys cannot check.
- It rebuilds the search and assertion indexes and moves each id sequence past the largest restored id.
If a check fails, the transaction rolls back. The keys, indexes, and rows return to their previous state. An instance the size of production, about 830,000 results, restores in well under a minute. An import has a one-hour time limit in place of the two-minute limit for ordinary writes.
What a restore refuses, besides a damaged file:
- A value a column cannot hold: the wrong type, a NULL where none is allowed, a CHECK a row breaks, a duplicate key, or a reference to a row that is not there. PostgreSQL refuses these as it would any write, and the error names the table.
- A result or runner-try duration outside the report input range of zero through 30 days (2,592,000,000 ms), inclusive. The error names the table, row and permitted range. Missing or NULL stored durations remain unknown. Pending reports must pass the per-result input checks, including each runner try, before import can recover them. Import does not check report-level batch limits. Import refuses the whole archive rather than changing its evidence; this also applies when importing an archive backup.
- A case version whose body is not a case, or whose body hash or claim hash is not its body's; a version whose pinned methods are not its body's; a case whose head hash or claim hash is not its head version's; a case without its head version.
- A row that refers to a row of another project, or to an actor or team of another organisation: through any of the schema's foreign keys (a result's test, target or batch, a slot's case, a case's folder, a version's author), checked from the catalog so a key a later version adds is held too, and through the references the schema declares no key for (a question's decision, a target's change, a version's proposal, a result's run, and the rest of a list the tests hold complete), each of which must also name a row that exists. A slot whose obligation is not an exercise obligation of its own run. A result's correction that does not name an existing result of the same project, test and actor.
- A proposal whose stored resolution is malformed, or whose resolved edits name a case or folder outside its project, including a placement anchor or parent folder. The refusal names the proposal and, for a project boundary violation, the case or folder.
- A run whose obligations are more than a plan accepts, or name an id twice. A failure question whose stored subject the inbox cannot read. A pending report whose staged results fail the result input checks.
- A policy version whose clauses are more than the policy accepts, or a current policy that this build's rules refuse.
- An attachment row whose bytes are not in the archive, or whose size or content type is not what the bytes say; attachment bytes no row names.
A refusal names the table and row, and the whole import rolls back.
A successful export can produce a backup that this build refuses to import. Before the report limit added on 2026-10-22, reports could store durations above 30 days. Export preserves those values. When exported duration columns contain invalid values, the CLI warns on stderr after saving the file. HTTP export returns the warning in X-Mainworthy-Archive-Warning. Neither changes the archive's evidence.
Keep the original archive. To retain every timing measurement, restore an isolated PostgreSQL backup as described under Back up. To make an importable archive by discarding invalid timings, first stop the app and back up PostgreSQL and its attachments. Restore into an isolated database, keeping the original unchanged. Open the restored database with psql and inspect the affected rows:
SELECT 'results' AS table_name, id, duration_ms FROM results
WHERE duration_ms IS NOT NULL AND
duration_ms NOT BETWEEN 0 AND 2592000000
UNION ALL
SELECT 'result_tries', id, duration_ms FROM result_tries
WHERE duration_ms IS NOT NULL AND
duration_ms NOT BETWEEN 0 AND 2592000000;
If you accept losing these timing measurements, set only those values to NULL on the copy. The results and tries remain, with unknown durations.
BEGIN;
UPDATE results SET duration_ms = NULL
WHERE duration_ms IS NOT NULL AND
duration_ms NOT BETWEEN 0 AND 2592000000;
UPDATE result_tries SET duration_ms = NULL
WHERE duration_ms IS NOT NULL AND
duration_ms NOT BETWEEN 0 AND 2592000000;
COMMIT;
Start the isolated app with MAINWORTHY_DATABASE_URL pointing at the restored database and its own attachment directory, export again and test import into a throwaway instance. These queries change only the two stored duration columns. A pending report can still fail its per-result checks; its error names the offending field.
An instance that already has data refuses an import and keeps what it has:
$ mainworthy import mainworthy.gz
conflict: import needs a fresh instance; existing projects or user data will not be replaced
A fresh instance has only its first project, scratch, and its owner. That project has no edits and no policy change. Making a token for a new person, agent or pipeline adds an actor, and that is enough to make the instance non-fresh. There is no merge yet. To bring an archive into an instance that has data, start a new instance.
An archive imports into a build with the same archive format and archive version as the one that wrote it. The database schema may be newer. An added nullable column can stay compatible: an archive that lacks it is restored with that column at its default, NULL. Import refuses missing required columns, unknown columns, and a table that is unknown, missing or named twice.
A migration changes the archive version if it adds or removes exported tables, removes or renames exported columns, or adds a column with a non-NULL default. Writes to exported data also change the archive version, including backfills and transforms that leave the table shape unchanged.
An archive with a newer version is refused with a message to upgrade. An archive with an older version is refused because Mainworthy cannot yet transform it. Use matching archive versions on both sides.
This build uses archive format 3 and schema 49. Import validates the table and column shapes and the evidence before committing. It does not open or convert a SQLite database file, and it does not read format 1, the archive of builds before 2026-11-09: export again with the build that wrote it, or preserve its database and a matching executable.
After an import in server mode, the tokens are gone, because the archive carries none. It carries no linked identity or invitation either. The people, agents and pipelines are still there with their grants.
To restore access in server mode, follow these steps:
- Restart the server. With no owner token configured, the server prints a new one. With
MAINWORTHY_OWNER_TOKENset, the server uses that value. - Make new tokens for the others with
mainworthy token new. - As the owner, sign in with the owner token, link your identity at the provider, and invite each person again with
mainworthy invite new <name>. For an existing person, the command prints a recovery link, which they accept by signing in at the provider.
In local mode, Mainworthy refreshes the owner and you can carry on.
Back up #
Run an export on a schedule, from any machine that can reach the server. Keep the files somewhere other than the server.
$ MAINWORTHY_URL=https://mainworthy.example.com MAINWORTHY_TOKEN=<token> \
mainworthy export --out backup-2026-11-09.gz
exported to backup-2026-11-09.gz
Test a backup by importing it into a throwaway instance before you rely on it.
To preserve tokens, sessions and credentials too, back up PostgreSQL and attachment bytes together.
- Stop the app while leaving PostgreSQL running, so attachment files match the database snapshot.
- Dump PostgreSQL with
pg_dumpand copy the app'sblobs/directory. In Compose, usedocker compose exec -T postgres pg_dump -U mainworthy -d mainworthy -Fc > mainworthy.dump. - Restore the dump into an isolated PostgreSQL 18 database with
pg_restore, restore its matchingblobs/, and start the same app version with that database URL and attachment directory. - Check the restored cases, tokens and attachments before using the backup for recovery.
Do not copy a running PostgreSQL data directory as if it were an ordinary file. Use PostgreSQL backup tools.
Move to another machine #
To move your data, export on the old machine and import on the new one:
- On the old machine, run
mainworthy export --out mainworthy.gz. - Copy the file to the new machine.
- On the new machine, install the same version of Mainworthy.
- In server mode, set
MAINWORTHY_OWNER_TOKEN. - Start a server with an empty PostgreSQL database and a separate attachment directory.
- Run
mainworthy import mainworthy.gz. - Restart the server, so the owner token you set becomes a token.
- Make new tokens for agents and pipelines.
- Put the tokens into your CI secrets and agent settings.
- Point
MAINWORTHY_URLat the new address. - When everything reports to the new server, stop the old server.
To keep tokens, restore a PostgreSQL backup and its matching attachment directory, as described under backups.
See also #
- Configuration for
MAINWORTHY_DATAand the owner token. - People, agents and pipelines for making tokens again.
- Command line for the flags of
exportandimport.