Tosumu Inspect API Specification
| Field | Value |
|---|---|
| Authority | Normative machine-readable inspection contract |
| Lifecycle | Current, pre-stability |
| Scope | Inspect command envelope, payloads, errors, and compatibility |
tosumu-cli exposes a machine-readable inspection contract for downstream tools such as the TUI, the WPF harness, and future companion tooling.
The inspect JSON contract currently has one baseline schema. The CLI emits that structured schema by default and does not expose a schema selector.
Common Envelope
Every tosumu inspect ... --json command returns the same top-level envelope:
Fields:
command: stable command identifier such asinspect.headerorinspect.verify.ok:trueon success,falsewhen the command failed or inspection found a failing status.payload: command-specific payload. Omitted ornullon error.error: structured error payload. Omitted ornullon success.
Current error payload shape:
{
"code": "ARGUMENT_INVALID",
"status": "invalid_input",
"message": "invalid argument: page number out of range",
"details": {
"reason": "page number out of range"
},
"pgno": null
}
Current Commands
inspect.header
Returns file-header fields plus slot-0 keyslot metadata.
Important payload fields:
format_versionpage_sizemin_reader_versionflagspage_countfreelist_headroot_pagewal_checkpoint_lsndek_idkeyslot_countkeyslot_region_pagesslot0.kindslot0.kind_byteslot0.version
inspect.verify
Returns per-page integrity results plus the B-tree invariant result.
Verification findings and partial verification states remain in the payload. The top-level error envelope is reserved for failures that prevent the command from producing any verify snapshot.
Incomplete verify states should remain in the payload when inspect can still produce a meaningful partial report. Promote them to the top-level error envelope only when the command cannot produce a reliable report envelope at all.
Verify payload findings add stable payload codes for machine handling. These payload codes classify reportable verify states without promoting them to top-level inspect errors.
Important payload fields:
pages_checkedpages_okissue_countissues[]issues[].codepage_results[]page_results[].issue_codebtree.checkedbtree.okbtree.codebtree.message
inspect.pages
Returns a lightweight page summary for every data page.
Important payload fields:
pages[].pgnopages[].page_versionpages[].page_typepages[].page_type_namepages[].slot_countpages[].statepages[].issue
Page states currently emitted:
okauth_failedcorruptio
inspect.page
Returns one decoded page and its records.
Important payload fields:
pgnopage_versionpage_typepage_type_nameslot_countfree_startfree_endrecords[]
Record kinds currently emitted:
LiveTombstoneUnknown
inspect.wal
Returns the presence and decoded summary of the WAL sidecar.
Important payload fields:
wal_existswal_pathrecord_countrecords[]
WAL record kinds currently emitted:
beginpage_writecommitcheckpoint
inspect.tree
Returns the current B-tree root and a recursive tree summary.
Important payload fields:
root_pgnorootroot.children[]root.children[].relationroot.children[].separator_key_hex
Tree child relations currently emitted:
leftmostseparator
inspect.protectors
Returns configured keyslot / protector summaries.
Important payload fields:
slot_countslots[].slotslots[].kindslots[].kind_byte
Compatibility Rules
- This contract is the current inspect baseline; do not add version selectors until a real incompatible change exists.
- Prefer one canonical field per concept over compatibility aliases.
- Command identifiers should remain stable once published.
- UI shells should not infer extra meaning beyond what the contract states; Rust remains the source of truth for file semantics.
The canonical Rust definition for the current envelope and payloads lives in
crates/tosumu-cli/src/inspect_contract.rs.
Embedded Core Verification
Embedded consumers can call tosumu_core::inspect::inspect_verification to
obtain a structured snapshot without importing Pager or BTree.
The returned report contains:
- parsed physical header information;
- WAL recovery observations;
- per-page authentication and corruption results; and
- a B-tree verification result with typed
InvalidorIncompletefindings.
Header-level failures remain TosumuError results. Reportable page and B-tree
findings remain in the successful report so callers can distinguish a partial
verification from an operation that could not produce a snapshot. The current
API does not yet provide a distinct overflow-chain finding category or an
unlock-parameter variant for encrypted embedded verification.