AGENTASIAN data and storage
Status: Ready
Truth label: Current
Audience: Fleet operator, System designer
Reader outcome: Know every store the product writes, who owns it, how durable it is, and how to back up, restore, and check it.
Last verified: 2026-09-13
1. Data roots
Forge and Brain normally use the same configured root:
~/.agent_asian
Forge reads SE_MANAGER_DATA_DIR. Brain reads DATA_DIR. Set both to the same
location only when the services run on the same trusted host and are intended
to share ledgers and traces.
Each remote worker also has a local Forge data root. Its credential and outbox are local to that worker and are not automatically copied to Central.
2. Complete storage inventory
| Path | Owner | Format | Purpose | Sensitive |
|---|---|---|---|---|
forge.sqlite3 | Forge Central | SQLite | Projects, tasks, workers, leases, result deduplication, run-token hashes | yes |
forge.sqlite3.lock | Forge Central | lock file | Exclusive Central ownership | no |
traces.sqlite3 | Brain and Forge | SQLite | Chat-turn and task-run lineage index | yes |
sources.sqlite3 | Brain | SQLite | Influence source IDs, import/review history, publication generations, and named selections; original/extracted text stays in the external influence library | yes |
context.sqlite3 | Brain | SQLite | Versioned operator briefs, decisions, preferences, lessons, and rules with activation and applicability | yes |
writing.sqlite3 | Brain | SQLite | Studio drafts/versions, learning consent/projection state, versioned operator chat defaults, evaluation cases/versions, frozen comparisons, review history, versioned evaluation suites, and batch membership | yes |
traces/raw/ | Brain and workers | files | Exact prompts, CLI events, stderr, and raw provider artifacts | yes |
cpmi.sqlite3 | Brain | SQLite and FTS5 | Derived project-memory records and lexical search | yes |
chroma/ | Brain | Chroma files | Semantic knowledge, notes, learnings, conversations, voice examples, and CPMI projection | yes |
outbox/<worker_id>/ | Worker | JSON | Durable terminal-result payloads and run tokens | yes |
worker-credentials/ | Worker | token files | Cleartext worker identity credentials | yes |
task_sessions, session_meta in forge.sqlite3 | Forge Central | SQLite | Current session records and one-time legacy import marker | yes |
sessions/sessions.json | Forge Central | JSON | Retained original from the one-time session import; subsequent edits use SQL | yes |
schedules.json | Forge Central | retained legacy JSON | One-time recurrence migration input; current schedules live in Forge SQLite | yes |
runs.jsonl | Forge Central | JSONL | Completed and superseded run summaries | yes |
chat_usage.jsonl | Brain | JSONL | Chat token, timing, and prompt-shape metadata | potentially |
decisions.jsonl | Forge Central | JSONL | Checkpoint decisions, notes, and grades | yes |
scope_audit.jsonl | Brain | JSONL | Scoped-search returned and denied counts | potentially |
candidates_resolved.jsonl | Brain | JSONL | Promoted and dismissed learning candidates | no |
conversations/ | Brain | JSON | Named saved chat histories | yes |
logs/ | Forge and supervisor | text | Task logs, service logs, alerts, and supervisor history | yes |
file_hashes.json | Brain | JSON | Ingestion change detection | potentially |
backups/ | backup script | ZIP | Rotated Central snapshots | yes |
Legacy projects/, tasks/, and workers/ JSON directories may remain after
migration. Central imports them once into SQLite and renames migrated files.
Managed influence imports use sources.sqlite3 plus the external
INFLUENCE_LIBRARY_DIR/.cortex-sources/ directory. Preserve both authorities in a
restore. Chroma generations are derived and only the active published generation
is eligible. Old rows remain available for citation inspection. The data-root
backup includes the SQLite file; back up external originals and extraction files
separately. Restoring an extraction records a new review revision and
restored_from_revision; it retains the current publication until a separate
publish action. Groups remain in external influence_pack.toml, while lens edits
use external voice-pack TOML. No new database is added for these editors. See
the Cortex influence library.
Studio drafts are canonical in writing.sqlite3; their Chroma voice examples
are derived. Withdrawal and revision checks apply before prompt injection even
if index cleanup is pending. Operator profile definitions remain in the external
voice pack. See Cortex writing. The existing top-level SQLite
backup discovery includes the new database.
3. Forge SQLite schema
Document tables
projects, tasks, and workers use one JSON document per row:
id TEXT PRIMARY KEY
data TEXT NOT NULL
This preserves the existing document contracts while moving mutations under SQLite transactions.
Task leases
task_id PRIMARY KEY
worker_id
fence
acquired_at
expires_at
ttl_seconds
Only the current worker and fence may renew a lease.
Result deduplication
PRIMARY KEY (task_id, fence)
recorded_at
This makes terminal result application idempotent.
Run tokens
PRIMARY KEY (task_id, fence)
token_hash
worker_id
issued_at
Only a token hash is stored. The cleartext token is returned with the claim and persists in the worker outbox until the result is acknowledged.
4. Transaction and writer model
Forge opens SQLite in WAL mode with synchronous=NORMAL and a 30-second busy
timeout. Mutations use reentrant BEGIN IMMEDIATE transactions.
Central holds an advisory process lock for its lifetime. A second Central for
the same data root raises SecondWriterError.
Forge rejects database paths reached through WSL drvfs or 9P. SQLite WAL and advisory locks are not considered reliable across that boundary.
The supported topology is one Central process with a database on its native local filesystem.
5. Project model
Important project fields:
| Field | Purpose |
|---|---|
| id | Eight-character generated identity |
| name | Operator label |
| path | Literal execution path |
| repo_url | Optional origin reference |
| supervision_mode | Default for tasks |
| status | active, paused, or archived |
| description | Operator context |
| client_id | Confidentiality scope, absent means internal |
| shared | Export internal methodology to client-scoped retrieval |
shared is valid only for an internal project. Project status is currently
descriptive and does not stop task routing.
6. Task model
Identity and routing
- task id
- project id and stored project path
- title, description, optional spec file
- priority
- assigned worker
- engine and required capabilities
- persona and skills
- session and parent-task ids
Authority and lifecycle
- supervision mode
- task permission
- auto-execute flag
- task status
- cancellation request
- checkpoint stage
- pipeline stage
- QA rework budget and count
Attempts and retries
- current run UUID
- monotonic run attempt and fence
- resume session id
- verification command
- automatic retry flag
- retry budget and count
Outcome evidence
- result or error
- plan and steps
- verification result
- LLM call count
- reported cost
- changed files
- free-form run metadata
- timestamps
A task can have several execution attempts. The task id is not a unique run identity. Use the run UUID and fence for attempt lineage.
7. Worker model
Worker identity is hostname plus instance name. A worker record contains:
- generated worker id
- network and host labels
- capability tags
- installed engines
- idle, busy, or offline status
- current task id
- heartbeat timestamps
- worker-token hash
The cleartext worker token exists only on the worker. Deleting a worker record is the credential-reset procedure.
8. State durability
Claim durability
Task assignment, run identity, lease insertion, and worker-busy state commit in one transaction. A crash cannot leave a task assigned while the worker remains idle, or vice versa, from a partially committed claim.
Result durability
The worker writes the result payload to its outbox before the first HTTP delivery. A process restart or Central outage therefore does not lose a completed result.
Stale result handling
When a lease expires, Central increments the fence. A late report from the old attempt is authenticated if its historical run-token row still exists, then recorded as superseded. It cannot replace current task state.
Log handling
Logs use a soft fence. Stale lines are tagged instead of discarded so incident evidence survives. Terminal state uses a hard fence.
9. Trace model
Every task claim gets a run UUID. Every completed chat request gets a turn UUID.
The trace index records:
- type and parent identity
- attempt number
- lifecycle status and timestamps
- provider and model
- prompt hash and prompt manifest
- retrieval manifest
- usage
- outcome
- raw-artifact references
Task traces currently place full task.result and task.error values in the
indexed outcome. The API therefore exposes response content. This differs from
the intended sanitized-manifest design.
Raw task artifacts are produced on the worker. A distributed worker does not automatically upload them to Central.
10. Chroma and embedding identity
Brain persists embeddings by collection. Each collection records the embedding provider and model used to create its vector space. Brain rejects a mismatched identity rather than writing incompatible vectors into the same collection.
Changing embeddings requires one of these actions:
- restore the original embedding settings
- rebuild the collection under the new identity
- use a new data root
Chroma is not treated as a multi-process distributed database. Keep its writes under one controlled Brain process.
11. Canonical project memory
CPMI SQLite is authoritative for canonical records. It stores stable ids, repository identity, source paths and lines, content hashes, type, status, dates, and searchable text.
The Chroma CPMI collection is a rebuildable semantic projection. FTS5 provides exact lexical fallback when embeddings are unavailable.
Deleted or superseded source records are pruned during a full project sync.
12. Current backup behavior
scripts/backup_data.py archives everything in the data root except
backups/ itself, process locks, and WAL sidecars. Every *.sqlite3 database
at any depth is copied through the SQLite backup API rather than as bytes, so
the archive is safe to take while Central and Brain are writing. The inventory
is exclusion-based on purpose: the earlier allowlist rotted (decisions.jsonl
and scope_audit.jsonl were added by later work and never reached an
archive), and tests/test_backup_restore.py asserts that a new ledger is
included by default. Output is a timestamped deflated ZIP under
<data_root>/backups/, retained to the configured count, carrying a
MANIFEST.json with a SHA-256 per member and the archive's role (central,
worker, or combined). --verify <archive> proves the bytes; --encrypt
writes AES-256-GCM under a scrypt-derived key from AA_BACKUP_PASSPHRASE, and
an --output outside the data root refuses plaintext unless acknowledged.
scripts/restore_data.py verifies every member against the manifest before
writing, refuses a role mismatch, refuses to run over the live data root while
Central or Brain is up, and deletes nothing: the current contents move to
<data_root>/pre-restore-<stamp>/. --dry-run writes nothing and
--data-dir restores into a scratch directory for a drill. The runbook's
Backups section is the operator procedure.
13. Backup gaps
A Central archive cannot contain remote-worker credentials, outboxes, or raw artifacts because those files are on another machine; run the same script on each worker. No archive contains external content roots: the voice pack directory, the influence library originals and extraction files, and pack history directories need their own copy. Restore validation is a rehearsal the operator runs, not an automated job.
14. Required backup topology
Central backup set
- every top-level SQLite database through the SQLite backup API
- Chroma
- sessions and schedules
- all JSONL ledgers
- conversations
- task and service logs required by retention policy
- Central-owned raw traces
- configuration inventory without cleartext secrets
Worker backup set
- worker credential file
- active and retained outbox entries
- worker-owned raw trace artifacts
- engine session metadata needed for resume
- supervisor configuration and logs
Worker credentials and outbox entries should be encrypted at rest in backup.
15. Restore procedure
- Record the source archive, date, version, and expected data root.
- Stop Cortex, Brain, Central, and every worker writing to the target root.
- Restore into a new empty directory.
- Verify archive checksums when available.
- Run SQLite integrity checks for every restored database.
- Confirm the Forge database is on a native filesystem.
- Point Brain and Central to the restored root.
- Start Central and confirm the process lock and
/health. - Start Brain and confirm
/health, collections, and CPMI stats. - Inspect project, task, worker, session, schedule, trace, and decision counts.
- Restore or re-enroll worker credentials deliberately.
- Start workers and confirm retained outboxes drain once.
- Verify a duplicate result remains idempotent.
- Record recovery time and discrepancies.
Do not merge a backup into a live data root.
16. Retention recommendations
The code does not implement one global retention policy. Adopt an explicit operator policy for:
- raw prompts and provider outputs
- task results and logs
- client learnings
- saved conversations
- scope-audit records
- decisions and grades
- backups
Decisions, result-dedup evidence, and superseded-run lineage have higher audit value than ordinary progress logs. Client material should follow the strictest client retention requirement.
17. Data classification
| Class | Examples | Handling |
|---|---|---|
| Credentials | fleet bearer, operator token, worker token, run token, provider keys | Never log or commit; restrict file access; encrypt backups |
| Client confidential | project memory, task results, prompts, conversations, traces | Scope, minimize, back up securely, delete by policy |
| Internal sensitive | rules, methodology, analytics, project paths | Trusted operator access only |
| Operational | health, counts, timestamps, non-content metrics | Retain as needed for reliability |
18. Data integrity checks
Recommended read-only checks:
sqlite3 <data-root>/forge.sqlite3 "PRAGMA integrity_check;"
sqlite3 <data-root>/traces.sqlite3 "PRAGMA integrity_check;"
sqlite3 <data-root>/cpmi.sqlite3 "PRAGMA integrity_check;"
Also verify:
- no two workers use the same hostname and instance unintentionally
- no active task lacks a lease
- no idle worker retains a current task
- every pipeline child references the intended parent
- every outbox entry has a task id, fence, and expected run token
- every client project has the intended
client_id
19. Related documents
- Architecture design
- Security model
- System manual
- Runbook
- State transaction design
- Worker credential design
Cortex complete pack saves retain authored content snapshots under each external pack's .cortex-history and versioned content files under .cortex-versions. Include both in operator-content backups; top-level runtime SQLite backups exclude them. See voice-pack management.
Task-intake additions to forge.sqlite3: task_settings retains current operator/project override sets and their versions; task_requests retains idempotent creation receipts. Tasks store resolved setting provenance in creation_context. These use the existing Forge transaction and backup boundary. See task defaults.
Retained delivery: attempt manifests remain private traces/raw/<run-id>/diff.json artifacts. Derived text versions have separate immutable raw JSON files and deliverable_versions rows in traces.sqlite3. Restore both metadata and raw artifacts. See deliverables.
Frozen task briefs and acceptance
Forge's canonical document tables task_briefs, attempt_briefs, criterion_assessments and acceptance_decisions retain versioned intent and operator review. Assignment writes the attempt snapshot in the claim transaction. Trace verification.json retains CLI check evidence; artifact/response hashes bind assessments to the inspected output. Artifact versions stay in traces.sqlite3 and raw files. Keep these stores together in backups; a decision without its underlying file is not reconstructed proof. See task acceptance.
Voice-pack activation settings
voice-pack-settings.json in the Brain data root canonically stores registered external pack directories, activation/order, revision and configuration history after the first Cortex save. Environment pack settings bootstrap installations without that file. Writes serialize with the existing writing-store lock and publish by atomic file replacement. Content itself remains in external packs, including inactive/unregistered ones. Back up both locations. Configuration changes reload the serving Brain; other processes retain their existing reload boundary.
Prompt allocation settings and evidence
prompt-budgets.json in the Brain data root stores canonical budget profiles and revision history. Writes use the writing-store lock and atomic file replacement. Chat generation records retain section identities/hashes and per-call allocation without copying their text into the budget report. Comparison manifests retain frozen budgets and cohort keys include them. Local polish reports keep separate budget checks. See context budgets.
Worker attempts retain a validated active-profile snapshot in memory and preserve the resolved revision, actual provider/model, phase, estimates, section hashes, inclusion decisions and shortening records in run_metadata.context_allocations. Forge's run ledger and trace prompt manifest retain those allocation reports. CLI private prompt capture contains the dispatched text. Direct tool-loop observation excerpts retain their existing storage limits; allocation hashes do not imply complete raw observation retention. A settings fetch failure records the application fallback.
Source-group edits retain external INFLUENCE_LIBRARY_DIR/.cortex-manifest-history/<sha256>.toml versions. These contain rules/settings rather than book content and are excluded by document format discovery. Full-definition restore preserves history and applies with the current revision. Include this directory in external-library backups.
Completed Brain chat traces now retain chat-provider-inputs.json for actual allocated system/history/user/tool inputs and tool schemas. Cortex reads these only through explicit turn inspection; they are not reconstructed from current settings. Trace backup/retention also covers these private prompt texts.
Named Cortex conversation snapshots and versions live in Brain conversations.sqlite3 (workspaces, workspace_versions). They reference stable draft IDs/versions and retain messages/settings. They do not replace the legacy conversations/*.json, vector conversation memory, or per-turn trace store. Browser controls are cached under the active conversation ID.
Queued task execution revisions and immutable claim settings use Forge task_settings, under execution:<task>:<revision> and execution-attempt:<run>. They preserve creation provenance and distinguish requested worker pins from actual claims. See execution settings.
Managed linear definitions, their immutable versions, and launched session snapshots use Forge workflow_templates, workflow_versions and workflow_runs. Workflow request IDs retain duplicate-launch receipts. Stage creation context retains its exact template revision and stage definition. See Cortex workflows.
Stage handoffs use Forge handoff_notes and attempt_handoffs. Exact prior results are retained under the child attempt's private trace directory as prior-stage-result.txt; worker copies use prior-stage-worker-copy.txt. Hashes detect changed retained content. Captured input references are separate from current artifact/acceptance state. See stage inputs.
Portable methods and immutable versions live in Forge method_packages and method_versions. Each submitted task retains its selected package as method_context, with method ID/revision and a content hash in creation metadata. Worker-local copies live under <Forge data root>/methods/method-* and do not modify project files. See managed methods.
Cortex local processing declarations and their revision history live in DATA_DIR/local-processing.json. Atomic replacement and the writing-store transaction serialize edits. The file supersedes the environment bootstrap after first save. New turns retain one boundary snapshot, while comparisons recheck revocation before each candidate. See local processing hosts.
Source replacement and migrated-selection history live in source revision payloads. library_archived_passages in sources.sqlite3 stores exact historical passage text and provenance as compressed, hash-checked blobs before indexed copies are deleted. These private passage texts are part of runtime backups. Cleanup does not delete external originals or extraction files. See source lifecycle.
Chat defaults use operator_settings and operator_settings_versions in writing.sqlite3. The legacy writing_settings row is a read-only fallback until first save, which retains its baseline in history. See chat defaults.
Polish judgments and private regression cases use the four revision_verdicts,
revision_verdict_versions, revision_cases and revision_case_versions tables
in writing.sqlite3. Cases contain private request/draft/candidate text. New
polish attempts retain their exact linted input in chat-polish-input.txt beneath
the trace root. Explicit CLI trials now use the same Cortex-managed revision_trials history. See
polish meaning review for retention and content limits.
Direct chat ratings use chat_turn_feedback and chat_turn_feedback_versions in writing.sqlite3. These retain judgments, comments and original turn/provider/voice identity, independently of Chroma feedback and learning consent. See reply ratings.
revision_trials in writing.sqlite3 retains local checker runs, full frozen public/private case inputs, model/endpoint/budget configuration, case and implementation hashes, ownership leases, results and partial-run status. Cortex exports include private inputs and endpoint configuration. See meaning trials.
Managed source quality records
Source payloads and source versions retain extraction diagnostics and optional operator quality verdicts. Verdicts bind to the extraction hash and the versioned report hash; changed or restored text requires fresh review. Repair previews persist nothing. Saving a proposed repair creates an ordinary external extraction version; original bytes and active published generations are retained. See Cortex source quality.
Structured extraction metadata
New Markdown/Word extraction files retain heading paths and section indices. Published chunks and exact passage traces carry those locators. Original DOCX bytes remain in the managed external library. Unsupported Word structures are recorded as extraction warnings and contribute to the retained quality report. The new extraction pipeline identifies itself as library-extraction-v2; existing source generations are not automatically rebuilt.
Source passage settings
Source payloads and versions retain optional chunking settings and the reviewed preview manifest summary. Publication records its resolved settings and splitter version. Original extraction text is unchanged by a settings edit. Preview hashes bind the source revision, extraction hash, settings, algorithm and passage-content hashes. Old published generations retain their own text; saved configuration does not rewrite citations.
Managed recurrence state
forge.sqlite3 stores recurrence_schedules, recurrence_versions,
recurrence_occurrences and recurrence_meta. Records include frozen task
templates and supplied writing context, so backups can contain operator text.
Deleted definitions remain inspectable in Cortex; waiting occurrences become
cancelled and created tasks retain their independent lifecycle. Legacy JSON is
retained after atomic one-time migration. See recurring tasks.
Managed research evidence
writing.sqlite3 also owns research_briefs, research_brief_versions,
research_runs, research_operations, research_evidence, research_findings
and research_finding_versions. These contain questions, provider queries,
frozen source policy, retained public page text and hashes, starting writing
context, exact finding references and operator review history. Page metadata
and provider snippets remain distinguishable from inspected evidence.
Conversation settings retain an optional research run ID. Run-wide inventories and actual turn inputs remain separate evidence. Retiring a brief does not erase its runs or close an existing collection. See Cortex research.
Research-backed context stores exact finding-version references in the existing context evidence field. Historical findings and passages stay in research tables; context selection rechecks current acceptance without rewriting historical turn snapshots. These cross-database checks are not a distributed transaction.
Research evidence with kind=library retains one exact published passage, its
text hash, metadata and source locator. The run's library policy freezes selected
publication generations. Live eligibility checks preserve historical bytes while
excluding retired or changed publications from new accepted use.
Forge SQLite adds recurrence_cursors, recurrence_cursor_versions and recurrence_results. Reviews retain occurrence/task/run identity, the observed output and acceptance digest, operator judgment, source position and explanation. Accepted results atomically advance a versioned cursor. Rejections preserve it. Dispatch copies the current same-project cursor into writing_context.recurrence_context and task instructions when the frozen schedule template enables reuse.
Brain feedback.sqlite3 contains append-only feedback_events and a versioned
feedback_current pointer for each task/run target. New Chroma feedback documents
carry canonical-feedback-v1 authority metadata. Legacy vector events remain
unchanged and are merged into task history by ID. Canonical ratings survive a
failed feedback embedding or learning metadata update. Reconciliation serializes
current projections and chooses an exact attempt rating before a task rating.
Historical statuses record earlier application; they are not a claim that an old
rating is still effective after correction.
Exact output judgments also use feedback SQLite: output_feedback_events retains immutable values and bounded evidence snapshots; output_feedback_current selects the current artifact-version or lesson-text judgment. These records are not embedded. Lesson overrides are resolved against current content at retrieval time, preserving the existing task/attempt projection as fallback. See feedback.
Recurring workflow definitions retain workflow_snapshot with exact stage content. Occurrences retain that snapshot, their session ID, ordered task IDs and the workflow launch record. Required stage states and evidence digests participate in recurring-result review freshness. Session creation and stage launch share the recurrence transaction through an explicit savepoint.
Memory correction journal
document-edits.sqlite3 in the Brain data root contains document_edits (operator requests, resource/revision, before/after records and application status) and document_edit_receipts (opaque IDs retained after history deletion). Chroma remains the active record source. Pending journal text is not retrieval authority. Back up the journal with the active index. See Memory collections for retries, restoration and deletion semantics.
Operating-file editing retains a private local history database and before/after publication receipts under the owning host's runtime data root. Recursive backup includes the nested SQLite database and receipts. Canonical project and installation sources require their normal project/code backups. Central retains bounded file requests, responses and advertised worker support in its transactional store. The response text can be private. Relay records older than one day are removed during worker file polling. See operating-file management.