File Storage
A per-element file store backed by a git-backed content-addressable store — upload, download, list, and delete arbitrary files in the element's own repository, where every write is a commit that carries a message and content hash, so you keep a full version history of what changed.
Working with it
Opening a File Storage launches a file browser — its dedicated working surface.
How it appears
The same element type rendered as a definition, a circle instance, and a live workspace card.
When to use / not
When to use
- Holding binary or document content an app produces or serves — generated PDFs and CSVs, uploaded assets, exported reports.
- Giving an action element a place to read and write files: attach a Files element and read or write through its upload / download / list ops.
- Bulk-importing many files in one versioned commit via the import op, or inspecting write history via the log op (the git commit log of the file repository).
When not to use
- Storing structured, queryable records — use data/sql, data/entity, or data/document, which index and search their contents.
- Holding embeddings for similarity search — that is data/vector's job.
Topology
Created from the library and placed inside an app or circle. It is a top-level building block you compose with other elements.
Properties
descriptionstring- Human-readable description of what this file store holds
Operations
- activityGET
- attachmentsGET
- batch_statsGET
- composePOST
- contextGET
- createPOST
- deleteDELETE
- delete-fileDELETE
- disablePOST
- downloadGET
- enablePOST
- export_bundleGET
- getGET
- importPOST
- import_bundlePOST
- intentionGET
- listGET
- logGET
- promotePOST
- readmeGET
- readme_updatePOST
- remove-modifierPOST
- restorePOST
- schemaGET
- sourceGET
- source_branchesGET
- source_fixturesPOST
- source_promotePOST
- source_repairPOST
- source_statusGET
- source_validatePOST
- statsGET
- treeGET
- updatePATCH
- update_metaPATCH
- uploadPOST
- versionGET
Composition
Errors / when it fails
- Description must be 512 characters or fewer
- Fails unless:
description == null || len(description) <= 512
File Storage (files)
Category: data | Form: | Symbol: Fi
Store and retrieve files in a git-backed content-addressable store
File storage backed by a per-element git content-addressable store (CAS). Upload, download, list, and delete files; every write is a commit carrying a message and content hash, and the log op returns the repository’s commit history. Provide file content as base64. Attach to action elements so they can read and write the element’s files through its ops.
Guide
Store and retrieve files via S3-compatible object storage
What It Does
Files (File Storage) is a data-storage element that holds arbitrary file
content in S3-compatible object storage backed by RustFS. Any file type can be
stored — content is transmitted as base64 and decoded on upload. Each Files
element gets its own bucket namespace, so two Files elements never share keys.
Writes are versioned: the operation contract carries commit semantics over the
object store — upload accepts a commit_message and returns a content sha,
import writes multiple files in a single versioned change, and the log op
returns the change history (with an optional path filter). MIME types are
inferred from the file extension (jpg, png, pdf, csv, json, wasm, etc.).
Files is a data atom (a leaf with no wired ports). It is not invoked through
a port graph — files move in and out through its operations (upload,
download, list, delete-file, import, log). Other elements attach to a
Files element rather than wiring to it: per the contract, action elements
reference a Files element via uses, receiving the S3 endpoint and credentials
as environment variables.
Element Definition
| Property | Value |
|---|---|
| Type | files |
| Category | data |
| Form | atom |
| Symbol | Fi |
| Icon | folder / #6366F1 |
| Workbench | workbench-files-grid |
Properties
| Field | Type | Required | Constraint | Description |
|---|---|---|---|---|
description | string | No | maxLength 512 | Human-readable description of what this file store holds |
States
| State | Meaning |
|---|---|
provisioned | Initial state — store created (initial state) |
active | Store is live |
error | Store is in an error condition |
Transitions: provisioned → active, active → provisioned, error → provisioned.
Attachments
Files accepts these modifier attachments (contract.attaches): auth-policy,
rate-limit, variable. It has no contains and no uses of its own; action
elements reference it via their uses.
Capabilities
| Capability | Description |
|---|---|
object-storage | Files stored in a per-element S3 bucket namespace (RustFS backend); any file type supported |
base64-encoding | Binary content transmitted as base64; decoded automatically on upload |
content-type-detection | MIME type inferred from file extension (jpg, png, pdf, csv, json, wasm, etc.) |
version-history | Change history accessible via the log op with optional path filter |
bulk-import | Multiple files written in a single versioned change via the import op |
prefix-listing | Tree listing with optional path-prefix filter via the list op |
Error Codes
| Code | Class | Retryable | Description |
|---|---|---|---|
FILES_KEY_EMPTY | validation | No | Upload key is empty |
FILES_KEY_TRAVERSAL | validation | No | Upload key contains .. path-traversal sequence |
FILES_KEY_TOO_LONG | validation | No | Upload key exceeds 1024 characters |
FILES_INVALID_BASE64 | validation | No | File content is not valid base64 |
FILES_NOT_FOUND | not_found | No | Requested file key does not exist in this store |
FILES_STORAGE_ERROR | internal | Yes | Object-store operation failed |
Operations
upload — POST upload
Uploads a file to the element’s object store. Provide the file content as
base64-encoded data with a key/path; the write is recorded with a commit
message and content sha. Auth: write.
- Input:
key(string, required),content(string, required, base64-encoded),commit_message(string, optional — auto-generated if omitted). - Output:
path(string),sha(string),size(integer).
download — GET files/{file_path}
Returns the content of a file at the given path. Binary files are returned as
base64-encoded strings. Auth: read.
- Output:
path(string),content(string),size(integer).
delete-file — DELETE files/{file_path}
Deletes a file. Auth: write. (UI section: danger.)
- Output:
deleted(boolean).
list — GET files
Returns a tree listing of all files with paths, sizes, and types. Supports
optional prefix filtering. Auth: read.
- Input:
prefix(string, optional — path prefix filter),recursive(boolean, defaulttrue). - Output:
files(array of{ path, size, kind }).
import — POST import
Imports multiple files in a single commit. Provide an array of file objects with
path and content. Auth: write.
- Input:
files(array of{ path, content }, required),message(string, optional commit message). - Output:
imported(integer),sha(string).
log — GET log
Returns the change history for this file store, showing past writes with
messages and timestamps. Auth: read.
- Input:
limit(integer, default20),path(string, optional — filter by file path). - Output:
commits(array of{ sha, message, timestamp }).
Quick Start
Create a Files element
POST /api/{circle}/{project}/
Content-Type: application/json
{
"element_type": "files",
"slug": "reports",
"name": "Quarterly Reports",
"spec": {
"description": "Generated PDF and CSV reports"
}
}
Upload a file
content must be base64-encoded:
POST /api/{circle}/{project}/reports/ops/upload
Content-Type: application/json
{
"key": "reports/q1.pdf",
"content": "JVBERi0xLjQKJ...",
"commit_message": "Add Q1 report"
}
Response: { "path": "reports/q1.pdf", "sha": "...", "size": 20480 }.
List, download, and inspect history
GET /api/{circle}/{project}/reports/ops/list?prefix=reports/
GET /api/{circle}/{project}/reports/ops/files/reports/q1.pdf
GET /api/{circle}/{project}/reports/ops/log?limit=10
Bulk import in one commit
POST /api/{circle}/{project}/reports/ops/import
Content-Type: application/json
{
"files": [
{ "path": "reports/q1.pdf", "content": "JVBERi0x..." },
{ "path": "reports/q1.csv", "content": "ZGF0ZSx..." }
],
"message": "Import Q1 set"
}
Common Mistakes
Sending raw (non-base64) content.
upload/import content must be base64-encoded — the executor decodes it.
Non-base64 content fails with FILES_INVALID_BASE64.
Path traversal in the key.
A key containing .. is rejected with FILES_KEY_TRAVERSAL. Use forward
slashes for directory paths (e.g. reports/q1.pdf); never ...
Empty or over-long keys.
An empty key returns FILES_KEY_EMPTY; a key longer than 1024 characters returns
FILES_KEY_TOO_LONG. Keep keys non-empty and ≤ 1024 characters.
Downloading a key that was never written.
A missing key returns FILES_NOT_FOUND — call list first to confirm the path
exists before downloading.
Description over the limit.
The description spec field is capped at 512 characters; longer values fail
element create/update validation (description_max_length).
Relationships
- Attaches to: auth-policy, rate-limit, variable
Capabilities
- git-backed-storage: Files committed to a per-element CAS git repository; any file type supported
- base64-encoding: Binary content transmitted as base64; decoded automatically on upload
- content-type-detection: MIME type inferred from file extension (jpg, png, pdf, csv, json, wasm, etc.)
- version-history: Full git commit log accessible via the
logop with optional path filter - bulk-import: Multiple files committed atomically in a single git commit via the
importop - prefix-listing: Tree listing with optional path-prefix filter via the
listop
Properties
| Property | Type | Default | Description |
|---|---|---|---|
description | string | — | Human-readable description of what this file store holds |
Operations
activity
Get /ops/activity | Auth: Read
Get activity events for this element
Scope depends on element capabilities: individual elements query by element_id, project-form elements with activity-scope-members include member activities, circle-level elements with activity-scope-all query the entire circle. Gracefully returns empty list if activities table is missing (old circles).
attachments
Get /ops/attachments | Auth: Read
List all modifiers and resources attached to this element
Returns both modifiers (policy enforcement) and resources (data injection) with is_modifier flag to distinguish. Items in the generated MODIFIER_TYPES list are modifiers; everything else is a resource. Includes cascade_policy and version pin info.
batch_stats
Get /ops/batch_stats | Auth: Read
Get per-element statistics for all children of this element
Returns per-child stats plus an aggregate. Most meaningful on compound or manifest form elements (repositories, circles, projects); atoms have no children so the result is an empty children array with a zeroed aggregate. Uses efficient GROUP BY SQL. Weighted averages for eval scores.
compose
Post /ops/compose | Auth: Execute
Batch add and remove modifiers on this element in a single call
Declarative composition: add modifiers by ref path (slug or path@version) and remove by attachment ID, all in one atomic call on the target element. Each ‘add’ entry resolves the source element, validates topology, attaches with optional priority and cascade policy. Each ‘remove’ entry deletes the attachment row. Returns a summary of what was added and removed. Example: compose({ add: [{ref: “my-prompt”}, {ref: “rate-limit/api@v2”, priority: 50}], remove: [{attachment_id: “uuid”}] })
context
Get /ops/context | Auth: Read
Get connected elements (graph traversal)
Graph traversal showing all connected elements with their relationship type (contains, contained_by, references, referenced_by, attaches, etc.). Use ?depth=N to control traversal depth (default 1) and ?types=actor,data to filter by element types.
create
Post /ops/create | Auth: Write
Create child element
POST to the parent path — element_type goes in the request body, NOT the URL. Both element_type and slug are required and must be non-empty. Name is derived from slug if omitted. Writes to both Git and PostgreSQL. All elements are stored flat under the circle — no intermediate library wrapper rows.
delete
Delete /ops/delete | Auth: Admin
Delete element (soft delete)
Soft delete — sets state to ‘deleted’ but retains the record. Cannot delete elements that have children (has_no_bond precondition) or active runs. Requires admin auth and confirmation.
delete-file
Delete /ops/files/{file_path} | Auth: Write
Delete a file
disable
Post /ops/disable | Auth: Admin
Disable element (hides and prevents use)
Idempotent — safe to call on already-disabled elements. Optionally pass a reason string. Disabled elements cannot be invoked or executed. Inverse of enable.
download
Get /ops/files/{file_path} | Auth: Read
Download a file by path
Returns the content of a file at the given path. Binary files are returned as base64-encoded strings.
enable
Post /ops/enable | Auth: Admin
Enable element (makes usable and visible)
Idempotent — safe to call on already-enabled elements. Transitions element to ready/enabled state. Cannot enable deleted elements. Inverse of disable.
export_bundle
Get /ops/export/bundle | Auth: Read
Export element as downloadable git bundle
On non-root-namespace elements, returns a binary git bundle. On root-namespace (circle) elements, dispatch hands off to the circle’s own export_bundle op, which returns a multi-element JSON envelope with one base64 bundle per child element — this is intentional, not an error.
get
Get /ops/get | Auth: Read
Get element details
Element is already resolved by the routing layer — this returns the cached element, not a fresh DB query. Use the path /api/{circle}/{slug} to address elements.
import
Post /ops/import | Auth: Write
Bulk import files
Imports multiple files in a single commit. Provide an array of file objects with path and content.
import_bundle
Post /ops/import/bundle | Auth: Write
Import git bundle into element
Accepts a base64-encoded git bundle in the JSON bundle_base64 field. Use overwrite=true to replace existing elements with same slug (default skips duplicates). Imported elements get new UUIDs. Returns counts of imported/skipped elements and any errors.
intention
Get /ops/intention | Auth: Read
Get element intention with full inheritance chain
Returns three levels: direct (this element’s intention), inherited (from category and root), and resolved (final merged intention). Useful for understanding an element’s purpose in context of its hierarchy.
list
Get /ops/files | Auth: Read
List all files in the repository
Returns a tree listing of all files with paths, sizes, and types. Supports optional prefix filtering.
log
Get /ops/log | Auth: Read
Get commit history
Returns the git commit log for this file repository, showing all past commits with messages and timestamps.
promote
Post /ops/promote | Auth: Admin
Promote element configuration to a target environment
Only for manifest-form elements (projects). Environments advance: dev → demo → live. dev→demo requires member+ role, demo→live requires admin. Freezes member versions at promotion time (creates snapshot). Persists environment config to spec.environments.
readme
Get /ops/readme | Auth: Read
Get element README.md content
Reads README.md from the element’s git repository. Returns empty content (not an error) if no README exists. Always returns markdown format.
readme_update
Post /ops/readme_update | Auth: Write
Update element README.md content
Creates or overwrites README.md in the element’s git repo. Commits to the draft branch. Content must be provided as a markdown string.
remove-modifier
Post /ops/remove-modifier | Auth: Execute
Remove an attached modifier from this element by attachment ID
Removes a modifier/resource attachment by its row ID. The ID comes from the attachments or context API. This is the reverse of attach — called on the target element, not the source.
restore
Post /ops/restore | Auth: Admin
Restore element to a specific version
Automatically snapshots the current state before restoring (creates a ‘Before restore to vN’ version entry). Writes restored spec to git as .triform/spec.yaml. Git failures warn but don’t fail the operation — DB state is authoritative. Cannot restore deleted elements.
schema
Get /ops/schema | Auth: Read
Get element input/output schema (MCP tools/list compatible)
Returns type-level port schemas from the TypeRegistry — not instance-specific overrides. Includes direction (input/output), required flag, and JSON schema per port. Useful for understanding what data an element accepts and produces.
source
Get /ops/source | Auth: Read
Get any file’s content from the element’s git repository
Reads an arbitrary file from the element’s CAS-backed git tree by its relative path. Same store as
readme, just generalized. Path safety: rejects..traversal, leading/, and null bytes. Use this to viewmain.pyfor action elements, asset files for SPAs, etc. Returns empty content (not an error) if the file doesn’t exist.
source_branches
Get /ops/source/branches | Auth: Read
List Source branches for this element
Returns the standard draft/demo/live Source branches, their current commits, and promotion relationships. Use GET /api/{element_path}/ops/source/branches.
source_fixtures
Post /ops/source/fixtures | Auth: Write
Dry-run or apply approved Source seed fixtures
Scans
.triform/fixtures/manifests from the addressed data element Source repo. Defaults to dry_run=true and never imports live runtime data. Apply requires dry_run=false plus confirm=true and dispatches approved records through existing generated element ops.
source_promote
Post /ops/source/promote | Auth: Write
Promote Source branch forward
Promotes draft to demo or demo to live through the generated element op path. Direct Git pushes to demo/live are blocked by Source policy.
source_repair
Post /ops/source/repair | Auth: Write
Inspect or repair the element Source index
Runs Source repair through the element operation path. Defaults to dry_run=true; set dry_run=false only after reviewing a dry-run report.
source_status
Get /ops/source/status | Auth: Read
Get Source control status for this element
Returns the branch-aware clone URL, checkout commands, current draft commit, child source-link count, portable export summary, Source health, warnings, and auth hints for the addressed element. Use the element-first path: GET /api/{element_path}/ops/source/status.
source_validate
Post /ops/source/validate | Auth: Read
Validate Source branch contents
Validates a Source branch before accepting local Git workflow changes or promotion. Defaults to branch=draft and rejects runtime data, generated output, secret material, and unreadable CAS refs.
stats
Get /ops/stats | Auth: Read
Get aggregate statistics for this element
Health status is computed: error if errors_per_day > 5 or success_rate < 0.8, warning if errors_per_day > 0 or success_rate < 0.95. Firing alerts escalate health to error/warning. Default period is ‘day’. Returns runs_per_day, success_rate, avg_duration_ms, and more.
tree
Get /ops/tree | Auth: Read
Get the element’s position in the graph — ancestors, children, references, and subtree statistics
Uses per-circle ElementGraph cache for O(1) lookups. Returns ancestors (containment chain), children (direct), members (references), referenced_by (reverse refs), attachments, and subtree stats. Default depth is 3, max is 10. Pass ?include_metadata=true for name/state on each node.
update
Patch /ops/update | Auth: Write
Update element
Partial update — send only the fields you want to change.
spec,name, andintentionare all independently optional.specMUST be a JSON object when present; deep-merged into the existing spec by default. Empty{"spec":{}}preserves existing spec content but still records a new version (no-op for content, not for version state). To clear/replace the entire spec wholesale send{"spec":{...},"deep":false}. List-typed spec fields use replace semantics (the patch list replaces the existing list, no array merging). Coordinates Git + DB writes. Slug cannot be changed after creation.
update_meta
Patch /ops/update_meta | Auth: Write
Update element metadata (lightweight merge — does NOT bump version or snapshot spec)
Shallow JSONB merge into element.meta. Top-level keys in the provided value replace existing meta values; other keys are preserved. Used for UI metadata like canvas positions, panel state, viewer preferences. Wire-shape op_name is
update_meta(distinct fromupdate) so SSE subscribers + the cache auto-invalidator can distinguish lightweight metadata changes from spec edits without inspecting the payload. The MutatingElementStore wrapper stamps this op_name on the lifecycle event emitted byupdate_element_metastorage calls.
upload
Post /ops/upload | Auth: Write
Upload a file
Uploads a file to the element’s CAS repository. Provide the file content as base64-encoded data with a key/path. The file is committed to the git-backed store. Content must be base64-encoded.
version
Get /ops/version | Auth: Read
Get current version or full history
Returns current version by default. Pass ?history=true for full version history (up to ?limit=N, default 50). Versions are backed by the element_versions table. Every spec update creates a new version entry.
Error Codes
| Code | Class | Retryable | Description |
|---|---|---|---|
FILES_KEY_EMPTY | validation | no | Upload key is empty |
FILES_KEY_TRAVERSAL | validation | no | Upload key contains ‘..’ path-traversal sequence |
FILES_KEY_TOO_LONG | validation | no | Upload key exceeds 1024 characters |
FILES_INVALID_BASE64 | validation | no | File content is not valid base64 |
FILES_NOT_FOUND | not_found | no | Requested file key does not exist in this repository |
FILES_STORAGE_ERROR | internal | yes | CAS git repository operation failed |
Observability
Defined for this element
Metrics
- files_upload_count
- files_download_count
- files_delete_count
- files_list_count
- files_import_count
- files_bytes_uploaded_total
- files_upload_size_bytes
Events
- files.file.uploaded
- files.file.upload_failed
- files.file.downloaded
- files.file.deleted
- files.files.listed
- files.files.imported
Pricing / cost
Platform default
Operation costs
- create: free
- update: free
- delete: free
- get: free
- list: free
- invoke: 10000 micro-AU
- tool_use: free