#Jig Project Authoring SDK/1
Status: prerelease candidate.
Project Authoring SDK/1 is the inert TypeScript surface used by jig.ts and
Binding declaration files. Its values describe desired project membership and
configuration. They do not read files, install dependencies, grant authority,
admit a project, or start work.
#Public surface
No administration, execution, sandbox, event, or live routing API is exported from this surface.
#Project declaration
A bare project makes its membership explicit:
flows, bindings, and grants are independently optional. Each accepts either a
discover() value or an exact array of project-relative member paths
(flows also accepts declared npm: package selectors).
Omission means an empty source.
Discovery is shallow and inert:
- a Flow root selects immediate real directories containing exact-case
FLOW.<ext>; - a Binding root selects immediate regular
*.tsfiles; - a grant root selects immediate regular
<LocalName>.jsonpolicies; - it does not recurse, follow symlinks, execute declarations, or interpret globs; and
- a missing valid discovery root is empty, while any invalid selected member rejects the complete project candidate.
Several roots may be supplied explicitly:
They form one unordered union. Duplicate, overlapping, escaping, symlinked, case-fold-colliding, or NFC-colliding members are rejected.
An exact source is the fail-closed alternative:
#Dependency preparation limits
limits.dependencies optionally configures dependency preparation during review:
All fields accept positive integer values. Omitted fields use their individual defaults.
maxPreparations defaults to 16 distinct preparations per review and accepts at most 256.
It counts distinct captured package digests that require new dependency preparation, including Flow dependencies, npm Flow adoption, and evaluation recipes.
Repeated digests count once. Reusing admitted dependencies consumes no preparation count.
maxPreparedBytes defaults to 33,554,432 bytes and accepts at most 134,217,728 bytes.
maxPreparedFiles defaults to 4,096 combined file/alias records and accepts at most 65,536 records.
Both output limits apply per production package, including selected source, production dependencies, lock bytes, and layout JSON.
The combined byte and file budgets must fit a 192 MiB canonical artifact, including headers and maximum-length paths. Jig rejects incompatible combinations before preparation. The shared 256 MiB preparation budget and 180-second deadline still apply, independently of the count allowance. Source capture, evaluation output, and storage retain their separate limits.
The operator can override each field through its corresponding exported environment variable:
Environment values must be positive decimal integers. They take precedence over project values, followed by built-in defaults. Jig snapshots these variables before project evaluation. It resolves the effective limits once from the captured declaration. The review controller enforces the count. Workers receive explicit validated byte and file limits, never the operator environment.
The byte and file limits also apply during assembly with reused dependencies. These settings grant no execution authority or resolution-network permission. Run consumes admitted bytes without preparing dependencies again. Later environment changes cannot replace those bytes or enlarge reviewed resource grants. See limits and defaults for related constraints and override policies.
#Project entrypoint
entrypoint optionally declares how jig run starts the application. It is one
string: an exact flow:<path>, npm:<package> or binding:<id> target followed
by optional Run arguments. Both declarations use the same grammar:
The string is bounded to 16,384 characters and 512 argument words. Jig tokenizes
whitespace, single/double quotes and backslash escapes; it never invokes a shell.
Single quotes preserve their contents. Outside quotes, a backslash escapes the
next character. Within double quotes it escapes a quote, backslash, dollar sign,
backtick or newline; other backslashes remain literal. Escaped newlines are
removed. Unclosed quotes, unfinished escapes, NUL and unquoted shell operators
(|, &, ;, <, >, parentheses, backticks and $) are rejected.
Quoted values are literal: no environment, tilde, wildcard or command expansion.
TypeScript string escaping still applies before this argument parsing.
Allowed options are --input, --attach, --select, --out, --receive,
--timeout and --display-bundle, with the ordinary Run grammar. Operator controls such as
--verification and --json remain CLI options. Review validates the target,
supplied inline input, unbound read-attachment names and outgoing channel names.
A selected display bundle must name a declared writable attachment or artifact result. Its relative file path remains inside that output rather than becoming a project path. Retained application views define acceptance and receipt recovery.
Omitted required input or files can still be supplied by the caller. File
arguments are project-relative slash paths.
Traversal, absolute paths and .jig are rejected. Review does not read those job files.
jig run without a target uses the approved entrypoint in terminals and scripts.
Explicit options replace corresponding defaults: --input replaces the entire
JSON value or file reference, and --receive replaces the channel set.
File mappings replace by attachment name.
--display-bundle replaces the whole final-bundle selection.
--select replaces that attachment's whole selection set. Replacing --attach clears its default selections unless explicit
selections are also supplied. An explicit --out replaces the declared output
destination. Duplicates within either source remain errors.
An explicit target bypasses all entrypoint defaults, even when it names the same target. Without an entrypoint, terminals offer a chooser and scripts require an exact target. An invalid or unavailable entrypoint never falls back.
Declaration paths resolve from the project; explicit CLI paths resolve from the
calling directory. Job file contents are captured at invocation, while Binding
attachments remain review-pinned and cannot be overridden. Existing output
paths are never overwritten: --out DIR needs a new destination on repeat Runs.
When the effective invocation omits --out, a retained approved target declaring
a read-write attachment receives a fresh packet destination in canonical
operating-system temporary storage. Result-only targets remain stdout-only.
Unknown targets and unreviewed projects receive no invented file requirements.
Destination selection precedes command-owner reexecution and stays unchanged
through submission, including the decision to omit output. Selection creates no
reservation or file authority. Ordinary anchored-parent, protected-path,
input-root exclusion and no-replace publication checks remain authoritative;
a collision or invalid destination refuses before dispatch without retrying work.
Jig reports the actual destination on stderr and in the existing machine
delivery.destination field. Temporary packets remain after command exit, but
the operating system may clear them. Use --out for a chosen retained location.
Entry point changes are reviewed and retained with the exact project
revision. jig inspect exposes that approved string; unreviewed edits do not
change execution. Selection and submission must use the same admission.
#Default providers by contract
defaultProviders is an optional map of at most 256 contract IDs to exact
implementation selectors. It supplies ordinary implementations for omitted
slots requiring those contracts, independently of their local slot names:
Each selected package must offer a named FLOW.contract.json whose ID matches
the map key. Keys identify contracts; they are never fetched or executed.
In this example, binding:agent requires a local bindings/agent.ts included
by discovery. That file selects an existing Flow package and its configuration;
the default selector neither creates a Binding nor installs a package.
Keys are canonically ordered; each key selects one provider. The target's
actual contract, not the map alone, establishes compatibility.
Review resolves each target's omitted named requirements against these selections. An explicit Binding slot wins. Otherwise the default must match the required contract ID, version and digest exactly; a mismatch never falls back to another implementation. An incompatible default makes an automatic direct target ineligible; an omitted Binding slot with that mismatch rejects the candidate. A correct explicit Binding override can still use the package. Anonymous requirements always need explicit slots. Without an explicit selection, review may select the sole structurally provisioned target offering the exact required contract. Multiple matches require a project mapping or consumer slot; runtime availability and credentials never break ties.
A selected default must itself be invokable, require no attachments, and use
an ordinary offered interface. A flow: selection requires a direct Run target.
HTTP Request, Finite ACP, Project Command and Run Checkpoint are host-only interfaces, not
eligible ordinary defaults. Selecting a provider does not grant powers: its own
Binding must still obtain explicit admission for any resource grants it uses.
Both direct Flows and Bindings receive their own reviewed, effective routes. Admission retains those exact routes, not a map consulted at runtime. Agent requirements need a matching ordinary implementation. Only qualified root Run Checkpoint requirements may resolve implicitly to host-owned retention.
#Declared package targets
npm:<package-name> selects a Flow from a dependency declared in the Jig
project's package.json dependencies. It is valid in defaultProviders,
Binding package, Binding Flow slots, exact flows membership, and CLI Run or
inspection selectors. For example, package: 'npm:@jigging/agent-acp' configures
the dependency's own Flow. Names have no version or subpath suffix; the manifest
and Bun lock own dependency versions. The package must contain a valid FLOW
entrypoint and its own declarations; JavaScript exports are not invoked to
discover it. A library without a FLOW entrypoint is not a Flow provider.
Workspace dependencies use a captured workspace; the Jig application can be
its root or a declared member. Root dependency selection captures package metadata
and the selected dependency closure, not unrelated application files.
Workspace-root patchedDependencies
may select captured bounded .patch files, applied by contained Bun preparation.
Member-local patches, overrides and catalogs
are not supported by that preparation profile. Registry
dependencies use existing bounded, script-disabled Bun preparation. Review
does not traverse live installation links. Missing locks require the existing
explicit resolution-network permission; Run never installs or resolves.
The resulting package source, contract and execution closure are retained
together. Selecting an implementation does not grant its required resources.
Dependency Flow selection is recaptured and prepared at each review, including
the existing resolution permission for a missing lock.
The wire target remains an ordinary Flow; its retained logical package address
is the npm: selector. A dependency may require settings and grants through
a local Binding just like a directory-based Flow.
#Binding declaration
A Binding configures one exact project Flow package:
package is required. Omitting settings produces an empty object. Settings
must satisfy the package's settings.schema.json when one exists.
slots is an optional map with at most 256 entries. Each key is a LocalName
used by this Binding's package as a Run/0 flow/call slot. Each value is an
exact flow:<project-relative-path>, npm:<package-name> or binding:<LocalName> selector,
an inline resource grant, or a grant:<LocalName> selection. Grant names
are slot selections, not CLI Run targets. A Flow selector requires a direct
Flow target; a Binding selector uses that Binding's own validated settings.
Either child may invoke an ordinary Agent Flow; a configured Binding may
also use explicitly granted Project Command, HTTP or Finite ACP slots. A selected Flow or Binding
may have further Flow/Binding child routes within the fixed root resource budget; resource
slots do not count as child routes. Aggregate reservations may limit concurrency
for deeper branches; see project policy. A Binding cannot select its own package, directly or
through another Flow or Binding. Omitting slots normalizes the declaration to
{}; review then fills matching named requirements from project defaults.
The example's critic Binding selects a separate package such as
flows/critique, with its own settings and no slots.
Slots are exact project links, not requests for later resolution. Project
review binds each slot to the named Flow or Binding target in the same candidate,
and admission retains that complete relation in one immutable generation.
Explicit Binding routes belong only to that Binding: running the package through
its flow: identity never borrows them. Project defaults and qualified native
implementations are resolved independently from each target's own requirements.
Plain package paths are not slot selectors. A leading ./ after flow: is
normalized away; the binding: suffix must be a LocalName.
Resource policies are inline by default:
For intentional policy reuse or independent management, select
reference: 'grant:documents' and include
grants: discover('./grants') in jig.ts. The filename
grants/documents.json supplies the policy name; its object uses exactly the
same grammar as an inline grant. Each selected slot must declare the exact
supported contract for its resource kind. HTTP, Project Command, and Finite ACP
use the ordinary Binding slot limit of eight total; selecting a resource does
not increase execution capacity.
Grants owns capture limits and explicit authority approval.
Parent permissions are never inherited. A simple ACP policy needs no separate
grant file. The explicit review-only --agent argument may propose another
client in all selected normalized ACP policies without changing declarations;
project policy defines its retained
meaning and refusal rules. It adds no Binding field or Run override.
attachments optionally binds declared read attachments to project-relative
directories, for example attachments: { decoder: "./tools/base64" }.
Review captures those directories and includes their sources, content digests,
and complete file manifests in the proposed Binding. Approval pins those bytes;
Runs never reopen their originals. Names must match read-only declarations in
the selected Flow's FLOW.contract.json; unknown or writable selections fail.
Omission or an empty map selects nothing. A flow: target never borrows another
Binding's captured files. See reviewed attachments
for bounds, retained storage and tool-bundle limitations.
Other read attachments remain per-invocation --attach inputs; a Run cannot
override a Binding's captured selection. Root Flows and Bindings use the same
root file profile. A Binding can explicitly map a child slot to the caller's declared attachments:
Each child attachment must be mapped exactly once. from selects a complete
immutable read view from the immediate caller. create: true permits a fresh
writable artifact owned by each operation, without requiring a writable caller
port. The call supplies attachments: { deliverables: { create: true } } and
receives the sealed output through result.artifacts.deliverables.
{ supplied: "read" } instead permits a held artifact as an explicit readonly
call attachment: attachments: { source: { read: artifact } }.
Fixed from ports cannot be overridden or repeated in call attachments.
Directions must match. A mapped Binding child cannot also select its own retained attachment resources. Read aliases share the original capture without widening the physical input budget. The mapping is part of review and admission. The domain input remains ordinary JSON and artifacts are separate result metadata.
Declare allowed forwarded result names with artifactResults: ["final"] in
FLOW.contract.json, then return a selected held artifact through the handler's
terminal artifactResults: { final: artifact }. Forwarding aliases immutable
bytes. It does not merge child trees into the root writable attachment.
See child files for completion and failure semantics.
Binding identity is the declaration filename's LocalName basename. For
example, bindings/review.ts has ID review. There is no duplicate id
field, profile inheritance, overlay, ambient environment fallback, or per-Run
settings override.
Bindings are optional. A discovered Run package can also qualify as an exact direct Flow target. It must accept empty settings and fit the root attachment profile. Every requirement must resolve through reviewed ordinary defaults or qualified Run Checkpoint or Child Checkpoint support. A package without requirements needs no defaults.
The complete direct-Flow and Binding graph must be acyclic. Each branch must fit the fixed root resource budget: at most five child levels with one effect allowance. Concurrent branches share that budget. There is no hidden generated Binding.
A required named invocation is declared by uses.<slot>.contract in package
metadata. The selected Flow must offer that exact ID, version and digest
through its root FLOW.contract.json. Anonymous ordinary calls need no contract.
Optional slot declarations set uses.<slot>.optional: true and may remain
unbound in a Binding or project default.
Only qualified Run Checkpoint slots resolve implicitly to host support. HTTP Request, Finite ACP and Project Command require explicit slot grants. Those three contracts and Run Checkpoint cannot be implemented by mapping a package that merely claims their host-only identity. Review shows expected contracts and selected routes together. See project policy for qualification and limits.
#Value rules
All helpers are synchronous and side-effect-free. They return deeply frozen plain data and reject:
- unknown keys;
- explicit
undefinedornullfor optional object fields; - functions, accessors, symbols, bigint, non-finite numbers, sparse arrays, cycles, class instances, and other non-JSON/0 values;
- invalid LocalNames or project paths; and
- duplicate or colliding paths.
One leading ./ is removed from author paths. Output paths use /, remain
project-relative, and are bounded by the Project Authoring schema. Discovery
does not accept a glob language.
These checks are ergonomic only. Jig evaluates captured author modules inside its bounded default-deny execution envelope, then independently validates and normalizes their result. Forged helper output acquires no trust.
#Machine shape
The closed machine schema is
project-authoring-1.schema.json.
It validates either a normalized project value:
or one normalized Binding value:
Authors do not add a format discriminator or $schema field. Shape validation
alone is never admission evidence: Jig separately captures exact membership,
retains immutable package and declaration bytes, links references, validates
package schemas, derives the review delta, and admits only an explicitly
applied retained Plan.
#Deliberate exclusions
SDK/1 does not define dynamic child-Flow resolution, candidate catalogues,
semantic choice, Hooks, Services, Journal publishers, provider credentials,
arbitrary permission grants, runtime selection, sandbox selection, attachment
projection, or administration. Exact project defaultProviders and Binding slots
select ordinary implementations; they do not introduce a runtime registry or
widen the selected implementation's authority.