File inputs, outputs and materialization
Use the canonical File contracts from @orqio/dsl-spec/provider-contracts. Keep storage and
provider identity out of node fields, output and workflow state.
fields: {
attachment: f.file({
label: 'Attachment', required: true,
accept: ['application/pdf'], maxSize: 10_000_000,
}),
},
outputs: [{ id: 'out', schema: FileRefV1JsonSchema }],
f.file supports Document, expression, variable and reference binding. Its constraints are
outside FileRef and use authoritative metadata. Default sources are all four modes. Output
schemas can place FileRefV1JsonSchema inside declared objects or arrays. Do not copy its shape
or return bytes, URLs or provider IDs as File identity.
Create or read inside an activity
ctx.files.create streams generated bytes to managed storage and returns a FileRef only after
it reaches ready. ctx.files.openRead returns an activity-local stream; stat returns safe
metadata; readText requires a byte bound. The worker authenticates every input/output File
occurrence and checks current tenant, lifecycle and field policy. A same-workspace consumer
needs the received FileRef and live execution authority, but no consuming owner link. Reads
create no link and do not extend retention.
Materialize a remote snapshot
const body = {
async *[Symbol.asyncIterator]() {
const signal = cancellationSignal(); // from @temporalio/activity
const response = await fetch(sourceUrl, {
signal, headers: { Authorization: `Bearer ${activityCredential}` },
});
if (!response.ok || !response.body) throw new Error('Source read failed');
const reader = response.body.getReader();
try {
while (true) {
if (signal.aborted) throw signal.reason;
const next = await reader.read();
if (next.done) return;
yield next.value;
}
} finally {
await reader.cancel().catch(() => undefined);
}
},
};
const file = await ctx.files.materialize({
slot: 'source-document',
providerKey: 'my-provider',
externalRevision: revision, // optional; use a known immutable revision when available
name: 'report.pdf', mediaType: 'application/pdf',
expectedSizeBytes: knownSize, // optional
body,
});
return { output: file, nextPort: 'out' };
The async iterator opens the source lazily and uses the activity cancellation signal. Open it only inside provider execution; do not fetch before calling materialize. Keep URLs, credentials, provider identity and revision in activity memory and server-only request metadata. They never enter FileRef, graph fields, state patches, Temporal history, logs or analytics. The iterator returns a byte stream; the managed content plane owns byte limits and cancellation. Sanitize provider errors instead of logging a raw request or response.
Use one stable provider-owned slot per logical File. The creation identity uses the exact execution/node visit and slot, excluding activity retry. File Core owns the fingerprint, fenced write session, finalize and immutable result. A ready replay returns the same FileRef without opening the remote source again. Changed fingerprint metadata conflicts. With no revision, the first successful snapshot wins; a later remote edit does not change the existing File. Orqio never deletes the provider source.
Declare each File output with the canonical schema. The worker validates the complete input map
and counted { output, statePatches } root before accepting output. Depth 64, 10,000 visits and
100 distinct FileRefs apply even to non-File values; overflow is a typed error, not truncation.
Existing action-output byte limits and current workspace File quotas also apply.
Materialization reuses the existing File Core and producer execution link. Task #495 proved this path with a local remote source, real HTTP/File API, Postgres and immutable replay; activation consumes that proof. Provider-specific products still need their own accepted Task and evidence. This capability adds no Drive/Dropbox action, Provider Source capability, subprocess, malware scanner, SaaS BYOS, TTL setting or legal hold. See Files for users for Documents, Human Task flows and retention.