Sixteen things that must always be true
If a requirement, the HLD and this page conflict, the requirement wins, then the HLD. Fix the conflict before coding.
- I-01A record cannot reference another tenant's project or child.
- I-02A submitted revision never changes, and its reviewer differs from its author.
- I-03An accepted work item creates its base payable at most once.
- I-04A scenario group sits in exactly one split of a release.
- I-05An approved run binds one exact config and a bounded spend.
- I-06One attempt holds a run's execution authority, with a rising fence.
- I-07At most one approved GPU execution holds the global slot.
- I-08Replaying a tool action changes state at most once.
- I-09Unscorable infrastructure outcomes have no numeric reward.
- I-10A checkpoint is usable only after a complete-artifact and clean-load check.
- I-11A trainer cannot read final-test content or hidden outcomes.
- I-12Corrections keep historical evidence and block new use separately.
- I-13An approved run points at a complete, current baseline of its exact starting model.
- I-14In one project, a person holds one expert side, training or benchmark.
- I-15An attempt review never changes a stored score and never reads a sealed attempt.
- I-16Lab weights and raw traces stay in the lab's account, and no role of ours can export them.
New to these words? Plain-English meanings
| Word | What it means here |
|---|---|
| Rollout | One complete attempt by the model at one task. |
| Checkpoint | A saved copy of the model's weights at one moment. |
| Adapter | A small trainable add-on. The base model stays frozen underneath it. |
| Baseline | The saved score of the starting model, taken before any training. |
| Sealed test | Tasks that training can never read, kept for the final comparison. |
| Verifier | Protected code that scores an attempt. The model cannot see or reach it. |
| Unscorable | The infrastructure failed, so there is no score at all. This is different from scoring zero. |
| Tenant | One customer. Their data must never reach another customer. |
| Idempotent | Sending the same request twice has the same effect as sending it once. |
| Outbox | A to-do note saved with the data it describes, so a crash cannot lose it. |
| Lease | A time-limited right to act that must keep being renewed. |
| Fence | A number that rises with each attempt, so writes from an old worker get rejected. |
| Reconcile | Ask the cloud provider what really happened before acting on a guess. |
| Digest | A fingerprint of a file. If one byte changes, the digest changes. |
| Manifest | A signed-off list of the exact files and versions a step used. |
| Quarantine | Block something from new use while keeping its history intact. |
| RLS | Row-level security: the database itself filters rows by tenant. |
Fifteen modules, each the only writer of its state
| Module | Public operations | Owns |
|---|---|---|
identity | Start and finish login, resolve and revoke session | Identity links, sessions |
access | Resolve scope, assign side, grant, revoke, authorize purpose | Memberships, sides, grants |
projects | Create, revise and approve brief, close | Project, brief versions |
workforce | Invite, qualify, allocate, claim, renew, release | Agreements, assignments, claims |
tasks | Save draft, submit, open rework, quarantine | Tasks, drafts, revisions |
reviews | Assign, decide, adjudicate, review attempt | Decisions, acceptance, attempt reviews |
releases | Validate, publish, set eligibility | Versions, releases, members |
runs | Freeze, validate, approve, cancel, classify | Intent, approvals, attempts, reservations |
episodes | Create, step, inspect, finish, close | Runtime state, receipts, snapshots |
scoring | Score state, audit, publish corrected score | Judgment access, score results |
checkpoints | Register, seal, validate, finalize | Manifests, validation state |
evaluation | Freeze protocol, record baseline, compare, sign off | Baselines, evaluations, evidence, reports |
delivery | Assemble, approve, issue download, record acceptance | Manifests, access grants |
payables | Create obligation, adjust, reconcile | Compensation, settlement events |
operations | Outbox, reconcile, watchdog, register lane, delete, restore audit | Jobs, leases, lanes, incidents |
Key operations and their failure contract
| Operation | Output | Failure and side effects |
|---|---|---|
RunService.approve | Run revision, approval and reservation IDs | Commits approval, budget, audit, outbox once. No AWS call. |
RunService.request_cancel | Durable receipt | Revokes new episodes and promotion. Provider stop is async. |
TaskService.submit | Immutable revision ID and digest | Stale draft conflicts. Nothing is overwritten. |
ReviewService.decide | Decision and task-state receipt | Rejects author conflict. Acceptance and pay share a transaction. |
ArtifactStore.read_verified | Stream with verified size and digest | Missing version or bad checksum is a typed integrity failure. |
JobProvider.submit | Provider ID, rejection or unknown | Network failure after send is unknown, never safe to retry. |
JobProvider.inspect | Versioned provider observation | Changes no business status. The reconciler validates that. |
EpisodeService.step | Safe observation and sequence | Same action returns prior result. Changed payload conflicts. |
ScoreService.verify | Valid score or unscorable error | No default numeric reward on an error. |
CheckpointService.finalize | Complete ID or recorded failure | A stale attempt cannot publish or replace a manifest. |
Implement these as small services and Protocols after the first compatibility experiment. Test doubles are fine for domain units. A simulated optimizer never passes the training gate. Share generated OpenAPI types with the web client, never ORM models.
The two data maps that matter
PostgreSQL 17, with reviewed Alembic migrations. Every project row carries organization and project IDs, and foreign keys include them.
Column rules
Identity
uuid keys. Composite parent keys with organization and project.
Time
timestamptz in UTC, shown in the user's zone. An end time stays empty until it happens.
Versions
revision bigint, positive, rises with each mutation.
Digests
SHA-256 as 32-byte bytea, shown as lowercase hex.
Money
amount_minor bigint plus currency. No floats or implicit FX.
Over HTTP
Large numbers as decimal strings. Never rounded in the client.
Status
Bounded text and a named CHECK. Provider statuses stay out.
JSON
jsonb for task bodies and recipes only. Keys, money and state are columns.
Deletion and immutability
No blanket cascades. App roles cannot update evidence, and maintenance uses a separate audited role.
CREATE TABLE reviews (
id uuid PRIMARY KEY,
organization_id uuid NOT NULL,
project_id uuid NOT NULL,
task_revision_id uuid NOT NULL,
author_id uuid NOT NULL, -- copied, then proven by the key below
reviewer_id uuid NOT NULL,
decision text, -- empty until decided, then sealed
revision bigint NOT NULL CHECK (revision > 0),
created_at timestamptz NOT NULL,
FOREIGN KEY (organization_id, project_id, task_revision_id, author_id)
REFERENCES task_revisions (organization_id, project_id, id, author_id),
CHECK (reviewer_id <> author_id) -- nobody approves their own work
);Every table and column (63 tables)
Unless a table is marked global, every row also has organization_id uuid, project_id uuid and created_at timestamptz, and foreign keys include the first two. Rows that change also have revision bigint. Money uses _minor bigint with a currency char(3). Digests are 32-byte bytea. This is a proposal: engineers turn it into reviewed migrations and test them.
Identity and access (6)
| Table | Columns | The rule that matters |
|---|---|---|
organizations | id uuid, name text, state text | Global. Owns projects. |
users | id uuid, issuer text, subject text, state text | Global. Unique issuer and subject. No merging by email. |
memberships | user_id uuid, state text, granted_at timestamptz, revoked_at timestamptz | Unique organization and user. |
project_grants | user_id uuid, role text, purpose text, state text, expires_at timestamptz | Unique project, user, role and purpose. Work grants must match the user's side. |
project_sides | user_id uuid, side text, assigned_by uuid | Primary key is organization, project and user, so a second side cannot exist. Side is training or benchmark. |
application_sessions | id uuid, user_id uuid, token_hash bytea, issued_at timestamptz, last_seen_at timestamptz, expires_at timestamptz, idle_expires_at timestamptz, revoked_at timestamptz | Global. Unique hash. The raw token is never stored. |
Projects and people (7)
| Table | Columns | The rule that matters |
|---|---|---|
projects | id uuid, owner_id uuid, support_owner_id uuid, state text, region text | Top of the tenant boundary. |
project_briefs | version int, owner_id uuid, mode text, capability text, rights_policy text, region text, cap_minor bigint, approved_by uuid | Unique project and version. Approved versions never change. Mode is internal_demo or customer. |
agreements | user_id uuid, terms_asset_id uuid, terms_version text, accepted_at timestamptz, eligibility_ref text | Immutable. No production work without one. |
qualifications | user_id uuid, rubric_version text, decision text, reviewer_id uuid, evidence_ref text | Immutable decisions. The latest applicable one is resolved explicitly. |
assignments | id uuid, assignee_id uuid, work_type text, terms_version text, due_at timestamptz, compensation_rule text, state text | One payable work item. Types: task_authoring, task_review, test_authoring, test_review, attempt_review, demonstration. |
assignment_claims | assignment_id uuid, claimant_id uuid, lease_until timestamptz, state text | One current row per assignment. Expiry is checked under lock. |
upload_intents | id uuid, assignee_id uuid, declared_type text, max_bytes bigint, purpose text, object_key text, expires_at timestamptz, asset_id uuid | The server picks the key. Expired intents are cleaned up. |
Tasks and reviews (6)
| Table | Columns | The rule that matters |
|---|---|---|
tasks | id uuid, author_id uuid, current_revision_id uuid, state text | Author is stable. Reassigning is an audited step before submission. |
task_drafts | task_id uuid, body jsonb, judgment_ref text, asset_ids uuid[], saved_at timestamptz | One per task. Every save checks the revision. |
task_revisions | id uuid, task_id uuid, revision_no int, author_id uuid, content_digest bytea, judgment_ref text, fixture_ref text, scenario_group_id text, contract_versions jsonb, submitted_at timestamptz | Immutable. Unique task and number. A second unique key on ID and author supports the review check. |
reviews | id uuid, task_revision_id uuid, author_id uuid, reviewer_id uuid, assignment_id uuid, rubric_version text, decision text, issue_codes text[], rationale text, decided_at timestamptz | Reviewer differs from author. Sealed once decided. |
adjudications | id uuid, review_id uuid, adjudicator_id uuid, decision text, reason text, decided_at timestamptz | A linked record by an independent person. The original review stays. |
acceptances | task_revision_id uuid, decision_ref uuid, acceptor_id uuid, accepted_at timestamptz | Unique per revision. Immutable. |
Pay (3)
| Table | Columns | The rule that matters |
|---|---|---|
payables | id uuid, source_work_item_id uuid, beneficiary_id uuid, amount_minor bigint, rule_version text | Unique work item, so a replay cannot pay twice. |
payable_adjustments | id uuid, payable_id uuid, amount_minor bigint, reason text, approver_id uuid, reference text | Append-only and signed. The approved total can never go negative. |
settlement_events | id uuid, payable_id uuid, provider text, external_ref text, kind text, amount_minor bigint, evidence_ref text | Unique provider and reference. Reversals append. |
Assets and versions (5)
| Table | Columns | The rule that matters |
|---|---|---|
assets | id uuid, bucket text, object_key text, version_id text, digest bytea, size_bytes bigint, media_type text, scan_state text, source_ref text, sensitivity text | Pinned after approval. Identical bytes do not transfer rights. |
rights_versions | id uuid, asset_id uuid, authority text, allowed_uses text[], recipient_limits text[], expires_at timestamptz, retention text, evidence_ref text | Immutable. Current eligibility is a separate record. |
environment_versions | id uuid, commit_sha text, image_digest bytea, schema_version text, tool_schema_digest bytea, report_ref text | Unique image digest per published version. |
verifier_versions | id uuid, commit_sha text, image_digest bytea, score_contract text, reward_components jsonb, audit_ref text | Immutable once published. |
model_versions | id uuid, source text, source_revision text, weights_manifest_ref text, tokenizer_digest bytea, template_digest bytea, license text, approved_uses text[], attestation_id uuid | Immutable. Source is a registry, or a lab attestation with no copy on our side. |
Releases (3)
| Table | Columns | The rule that matters |
|---|---|---|
dataset_releases | id uuid, manifest_digest bytea, environment_version_id uuid, verifier_version_id uuid, purpose text, publisher_id uuid, published_at timestamptz | Immutable after publishing. |
release_groups | release_id uuid, scenario_group_id text, split text | One row sets a group's split: train, development or test. |
release_members | release_id uuid, scenario_group_id text, task_revision_id uuid, fixture_ref text, rights_version_id uuid | Keyed to the revision's real group, so a member cannot be relabelled. |
Runs and budget (5)
| Table | Columns | The rule that matters |
|---|---|---|
training_runs | id uuid, brief_id uuid, model_version_id uuid, train_release_id uuid, dev_release_id uuid, baseline_id uuid, parent_run_id uuid, recipe_digest bytea, state text, cancel_requested_at timestamptz | No test manifest in inputs. Approval needs a current baseline. |
run_approvals | id uuid, run_id uuid, config_digest bytea, approver_id uuid, reservation_id uuid, limits jsonb, retry_allowance int, approved_at timestamptz | Immutable, and bound to one exact config. |
budget_accounts | id uuid, cap_minor bigint, committed_minor bigint, reserved_minor bigint | One per project and currency. Never negative. Updates lock the row. |
budget_reservations | id uuid, account_id uuid, intent_ref text, approval_id uuid, parent_reservation_id uuid, amount_minor bigint, consumed_estimate_minor bigint, state text | One active per intent. Evaluation can draw a child allocation. |
cost_entries | id uuid, reservation_id uuid, category text, amount_minor bigint, source_ref text | Append-only. Overruns are recorded, never cut to fit. |
Execution and lab lanes (6)
| Table | Columns | The rule that matters |
|---|---|---|
run_attempts | id uuid, run_id uuid, ordinal int, approval_id uuid, lane_id uuid, fence bigint, dispatch_token text, provider_job_id text, state text, heartbeat_at timestamptz, lease_until timestamptz, failure_code text, parent_checkpoint_id uuid | Unique run and ordinal, token and provider ID. One attempt holds authority. |
provider_jobs | provider_job_id text, attempt_id uuid, dispatch_token text, discovered_at timestamptz, observation jsonb, is_winner boolean, stop_evidence_ref text | Keeps every discovered duplicate. One winner per attempt. |
compute_slots | slot_name text, owner_intent text, attempt_id uuid, fence bigint, acquired_at timestamptz, state text | Global. One row in the MVP. A lost heartbeat alone never frees it. |
execution_lanes | id uuid, account_ref text, role_ref text, bundle_digest bytea, state text, revoked_at timestamptz | Lab lanes need a passing rehearsal and an attestation. Every job checks the state. |
lane_rehearsals | id uuid, lane_id uuid, account_ref text, bundle_digest bytea, report_ref text, passed boolean, ran_at timestamptz | Immutable. A rehearsal is valid for one bundle digest only. |
lane_attestations | id uuid, lane_id uuid, checkpoint_ref text, weights_digest bytea, signed_by text, signature bytea, attested_at timestamptz | The lab signs. We hold checksums and never the weights. |
Rollouts, scores and review (5)
| Table | Columns | The rule that matters |
|---|---|---|
rollout_groups | id uuid, attempt_id uuid, iteration int, task_revision_id uuid, policy_version text, expected_size int, valid boolean, discard_reason text | Unique attempt, iteration and group. Sealed before optimizing. |
rollouts | id uuid, group_id uuid, ordinal int, episode_id uuid, trace_ref text, terminal_reason text, score_id uuid, policy_version text | Unique group and ordinal. Tokens live in restricted objects, not SQL. |
score_results | id uuid, episode_id uuid, final_state_digest bytea, verifier_version_id uuid, valid boolean, total numeric, components jsonb, error_code text | Immutable. Valid needs a finite bounded total. Invalid needs an error and no total. |
attempt_samples | id uuid, attempt_id uuid, rule_digest bytea, seed bigint, frozen_at timestamptz | A frozen selection rule, training split only, with high scores included. |
attempt_reviews | id uuid, sample_id uuid, rollout_id uuid, assignment_id uuid, reviewer_id uuid, rubric_version text, finding text, evidence_ref text, decided_at timestamptz | Immutable. Has no path to edit a score. Findings: valid_success, model_failure, task_defect, verifier_defect, exploit. |
Checkpoints, evaluation and delivery (6)
| Table | Columns | The rule that matters |
|---|---|---|
checkpoints | id uuid, attempt_id uuid, global_step bigint, manifest_ref text, manifest_digest bytea, validation_state text, validation_ref text, parent_checkpoint_id uuid | Unique attempt and step. One manifest per checkpoint. |
evaluation_protocols | id uuid, digest bytea, original_model_id uuid, test_release_id uuid, inference_recipe jsonb, sampling jsonb, metrics jsonb, thresholds jsonb, missingness_rule text, stat_method text, frozen_at timestamptz | Frozen before any test access, and names no candidate. |
evaluations | id uuid, protocol_id uuid, kind text, baseline_id uuid, candidate_checkpoint_id uuid, attempt_id uuid, state text, evidence_ref text, signed_off_by uuid | Kind is baseline or comparison. A comparison must name its baseline and candidate. |
reports | id uuid, evaluation_id uuid, version int, metrics_ref text, analysis_digest bytea, efficacy text, review_decision text, predecessor_id uuid | Unique evaluation and version. Immutable once published. |
deliveries | id uuid, report_id uuid, checkpoint_id uuid, package_digest bytea, approval_ref text, acceptance_state text | Pins exact versions. Hidden tests are never included automatically. |
delivery_grants | id uuid, delivery_id uuid, user_id uuid, asset_id uuid, purpose text, issued_at timestamptz, expires_at timestamptz, revoked_at timestamptz | Rights and access are rechecked for every link. |
Runtime episodes (3)
| Table | Columns | The rule that matters |
|---|---|---|
episodes | id uuid, attempt_id uuid, task_revision_id uuid, policy_version text, seed bigint, purpose text, state text, next_sequence int, counters jsonb, deadline_at timestamptz, snapshot_ref text | Broker and restricted runtime roles only. No private labels. |
episode_actions | episode_id uuid, action_id uuid, sequence int, payload_digest bytea, safe_result jsonb, state_digest bytea, usage jsonb | Unique episode and action, and episode and sequence. Immutable once committed. |
episode_snapshots | episode_id uuid, sequence int, state_ref text, state_digest bytea, frozen boolean | The verifier reads frozen final state only. |
Operations (8)
| Table | Columns | The rule that matters |
|---|---|---|
outbox_events | id uuid, aggregate_type text, aggregate_id uuid, aggregate_revision bigint, schema_version int, body jsonb, available_at timestamptz, lease_until timestamptz, published_at timestamptz | The payload never changes. Only a restricted worker marks it published. |
inbox_receipts | consumer text, event_id uuid, result_ref text, completed_at timestamptz | Unique consumer and event. |
command_receipts | actor_id uuid, route text, idempotency_key text, request_digest bytea, status int, resource_ref text, expires_at timestamptz | Unique actor, project, route and key. |
job_leases | job_id uuid, holder text, lease_until timestamptz, fence bigint, state text, last_error text | Compare-and-set renewals. Separate from GPU slot ownership. |
eligibility_blocks | target_ref text, reason text, scope text, issuer_id uuid, effective_at timestamptz, cleared_by_id uuid | Append-only. A quarantine is never silently erased. |
lineage_edges | parent_type text, parent_id uuid, parent_version text, child_type text, child_id uuid, child_version text, relation text | Unique edge, indexed both ways. Written with the record that creates the link. |
audit_events | actor_id uuid, action text, resource_ref text, resource_version text, reason text, request_id uuid, correlation_id uuid, occurred_at timestamptz | The app can add but never edit. No raw credentials or prompts. |
deletion_requests | scope text, authority text, categories text[], hold_decision text, state text, evidence_ref text, backup_expires_at timestamptz | Linked to the register kept outside the database. |
Index project queues by tenant, project, state and time. Paginate with a stable timestamp and ID cursor, never a growing OFFSET. Partial index predicates must not depend on the current time. CHECK constraints cannot query other tables, so cross-row rules use composite keys and transactions. Store token counts and durations as numbers with units. lineage_edges is a lookup for tracing impact, and real foreign keys stay in place.
Deny by default, in this order
- 1AuthenticateOpaque cookie to session
- 2Resolve ownerWithout disclosing others' content
- 3MembershipVerified, never from a header
- 4Operation and purposeAllowed for this role
- 5State rulesReviewer identity, side, sealed test
- 6Open transactionRecheck contested grants
Workload authority has short clocks
Heartbeat loss causes investigation and stop behavior, never automatic admission of a replacement. A short token alone is not revocation, so every request also checks current attempt state and lease. A local watchdog stops work when renewal fails past 90 seconds, and a provider watchdog handles a process that ignores it.
Login, tokens and database context
Browser. Cognito authorization code with PKCE, state and nonce, through a maintained library. A __Host-session cookie with Secure, HttpOnly and SameSite=Lax. Keep only the token hash and expiry times on the server. Issue a new session at login and on any privilege change, and ask again before sensitive grants or exports.
Every write. A CSRF token and a checked origin, because a cookie alone gives no CSRF protection. Removing someone from a project blocks their next action, even if Cognito still knows them.
Database. Each request resolves an ActorScope, set with transaction-local settings. RLS uses USING and WITH CHECK. Test with the real app role, which is never an owner, a superuser or BYPASSRLS. Policies enforce tenants, and services enforce reviewer identity, sealed-test purpose and approved use.
Elevated functions. A security-definer function fixes its search_path, names objects in full, revokes public execution and gets its own review and denied-access tests. The environment never gets an open database connection.
Workers. Tokens are signed with an asymmetric KMS key and fixed algorithm, carrying audience, project, run, attempt, fence and purpose. A bootstrap secret is rotated per attempt, exchanged once and never in prompts or logs. A duplicate container cannot get authority after another has won.
Every write has the same shape
All routes start with /api/v1.
A request carries
If-Match with a positive revisionStrict versioned body, size-cappedRequest ID, server generatedA receipt returns
An error returns
What the status codes mean
| Code | When | Code | When |
|---|---|---|---|
| 201 | Creation complete | 409 | Business conflict, or same key with different payload |
| 202 | Background work accepted | 412 | Stale If-Match |
| 400 | Malformed | 422 | Schema validation |
| 401 | No or expired session | 428 | Missing If-Match |
| 403 | Known resource, disallowed operation | 429 | Rate or quota limit |
| 404 | Other tenant's data, non-disclosing | 503 | Temporary dependency outage |
Exact routes: what to send and what comes back
| Route | Send | Get back |
|---|---|---|
POST /projects | Brief, mode, region, currency, cap | Project, state, decisions still missing |
POST /projects/{project_id}/sides | User and side | Side row, or side_conflict |
POST /assignments/{assignment_id}/claims | Key. Eligibility is worked out by the server. | Claim and lease expiry |
PUT /tasks/{task_id}/draft | If-Match, content, asset IDs | New draft revision, saved time, issues |
POST /tasks/{task_id}/submissions | Exact draft revision, key | Immutable revision and digest |
POST /assets/upload-intents | Type, size, purpose | Short-lived POST policy, server-chosen key |
POST /assets/{asset_id}/complete | Upload intent | Pinned version and scan state |
POST /reviews/{review_id}/decision | If-Match, revision, rubric, decision, reason | Sealed decision and task state |
POST /dataset-releases | Revisions, group splits, versions, use | Validation job. Publishing is a second command. |
POST /evaluations | kind, protocol digest, models, sealed release | Evaluation ID and frozen inputs |
POST /training-runs | Full manifest and digests | Run, config digest, validation job |
POST /training-runs/{run_id}/approvals | Digest, baseline ID, reservation, retries, If-Match | Approval, reservation, queued state |
POST /training-runs/{run_id}/cancel | Reason, key | Durable request. Repeats return the same one. |
POST /attempt-reviews | Sampled rollout, rubric, finding, evidence | Sealed review and payable |
POST /internal/attempts/{attempt_id}/start | Bootstrap proof, provider ID, token, fence | Lease and scoped token, or a losing result |
POST /internal/attempts/{attempt_id}/finalize | Fence, manifest digest, evidence | Validation job. Complete comes later. |
POST /deliveries/{delivery_id}/downloads | Artifact and purpose | Short-lived link after a fresh rights check |
All sit under /api/v1. The browser never picks its own author, reviewer, approver or storage key. Every response carries a request_id.
Critical commands and the event and artifact shapes
| Command | Needs | Commits |
|---|---|---|
| Submit task | Task ID, exact draft revision | Immutable revision and digest |
| Decide review | Review, target revision, rubric, decision, reason | Sealed decision, acceptance, payables |
| Publish release | Passing report, digest, group splits, purpose | Purpose-specific manifests, release ID |
| Record baseline | Frozen protocol digest, original model, release | Queued baseline evaluation with its own reservation |
| Assign side | Project, user, side | One side row. A second side returns side_conflict. |
| Approve run | Manifest digest, report, baseline ID, reservation, bounds, retries | Approval, reservation, queue. No GPU slot yet. |
| Submit attempt review | Sampled rollout, rubric, finding class, evidence | Sealed review, payable, and any follow-up rework or quarantine event |
| Register lab lane | Account reference, role, bundle digest, passing rehearsal, attestation | Active lane. Revocation is checked before each job. |
| Claim attempt start | Attempt, token, provider ID, fence, bootstrap proof | Lease, or an explicit losing denial |
| Cancel intent | Run revision, reason | cancel_requested, revoked new work, stop event |
| Finalize checkpoint | Fence, step, sealed manifest, evidence | Validation job. Complete waits for the validator. |
| Request comparison | Baseline ID, frozen candidate, same protocol digest | Queued intent with separate spend |
| Issue download | Approved delivery, artifact, purpose | Short-lived URL, checksum, size, expiry |
Canonical JSON. Versioned, sorted keys, UTF-8, no NaN, duplicate keys rejected. Prefer RFC 8785. A concurrent duplicate waits or gets a bounded in-progress result, and cannot create a second effect.
Events. ID, schema version, aggregate and revision, project, time, correlation ID. Names like task.submitted.v1, task.accepted.v1, release.published.v1, run.approved.v1, attempt.finalization_requested.v1, evaluation.requested.v1, delivery.approved.v1. Never a prompt, weights, secret or signed URL.
Artifact reference. Allowlisted bucket, server-chosen key, pinned version, SHA-256, size, type, sensitivity, purpose and rights version.
Submit and accept, each as one transaction
Lock the task before its review and assignments. Acceptance inserts the unique acceptance and each work item's payable under its agreed rule, because some contracts also pay for rejected or review work. No settlement call happens inside the transaction.
Publishing a dataset fails on one defect
- 1CandidateExact revisions, versions, purpose, group splits
- 2ValidateOwnership, acceptance, rights, duplicates, solvability
- 3Build manifestsTrain, development, sealed test, judgment, separately
- 4Upload stagedVerify digests first
- 5PublishShort transaction, recheck, insert, outbox
A changed member invalidates the report, because publication needs the same input digest. Near-duplicate detection flags work for a reviewer, and cannot certify independence alone. Orphan staged objects have no authority and get cleaned up. A later quarantine blocks use through eligibility checks.
No training without a saved before
Baseline stays valid while
A comparison then
Runs the candidate under the same protocol.
Approval reserves money before anything runs
A reservation covers
Rules
Preflight checks the real stack, rights, tool schema, token handling, gradient flow, save and reload, GPU memory and credentials, and binds a passing report to the exact digest. A database cap is an admission policy and no guarantee about provider billing. Keep reservations until every job and duplicate is reconciled.
An unknown reply is not a failure
Consuming and reconciling
Outbox and queue
SKIP LOCKED batch with a leaseDuplicates expectedAck only after durable handling5 deliveries before dead-letterOne work-intent ID per eventProvider jobs
Lease expiry alone does not free the physical GPU slot, because a partitioned worker might still run. Reconcile and stop the old job, close the attempt, then allocate a new fence. Fencing protects accepted changes. It does not make an unreachable process disappear.
A run, an attempt and a provider job are three things
The run is the intent. An attempt is one execution. A provider job is one observed cloud job, duplicates included.
A timeout must never apply an action twice
| Operation | Needs | Commits |
|---|---|---|
| Create | Active lease and fence, permitted split, eligible task, capacity | One session, pinned fixture, seed, policy, schema, limits |
| Reset | New episode, verified fixture | Initial digest, sequence zero. A repeat returns the same state. |
| Step | Scope, schema match, open episode, budget, action ID, sequence | Pure transition, journal, receipt, safe observation |
| Inspect | Same episode and scope | Committed, not found or pending |
| Finish | Open episode or already-frozen terminal | Frozen state, termination reason, one verifier request |
| Close | Owner or expiry worker | Release capacity once, keep evidence |
Termination reasons are listed above. The last two are unscorable. Replaying fixture plus journal must produce the stored digest, and a mismatch blocks scoring and quarantines the environment version. If future tools have outside side effects, this atomic guarantee no longer holds, so do not hide that change inside step.
Zero reward and no reward are different things
Valid score
A real outcome. Zero is a legitimate failure.
Unscorable
Infrastructure failed. Nothing to learn from.
A rollout trace, validated field by field
| Field | Rule |
|---|---|
| Provenance | Run, attempt, fence, group, revision, policy, tokenizer, template, environment, verifier. All in the manifest. |
| Prompt tokens | Integer IDs in vocabulary. The actual input, not reconstructed text. |
| Completion tokens | Ordered sampled IDs and turn boundaries. Empty generation is a recorded outcome. |
| Eligibility mask | Same length. Prompt, observation and padding are zero. |
| Likelihood data | Finite values aligned to the exact tokens and policy. Never synthesized. |
| Episode result | Ordered actions, terminal reason, final digest, restricted evidence. |
| Usage | Tokens, elapsed time, action count, permitted cost estimate. |
One optimization step
- 1BatchChoose tasks, freeze the policy version
- 2SampleDeclared attempts per task, 4 to start
- 3ValidateMembership, policy, masks, scores, limits
- 4DiscardA failed group goes whole, with a bounded retry
- 5OptimizeTRL's supported GRPO path
- 6RecordSettings, reward spread, tokens, parameter deltas
In the adapter recipe the base stays frozen. A zero-initialized adapter factor may show zero gradient early, so check the trainable set over the supported interval instead of requiring every tensor to move each step. Add vLLM only after synchronization tests, and pin an exact version of the integration.
Paid experts help between runs, and scores stay put
People diagnose what the model did. The optimizer still changes the weights.
- 1Freeze sampleA recorded rule and seed, training split only. Include high scores.
- 2AssignTraining-side experts, with a rubric and an agreed rate
- 3ReviewA safe trace view, then a finding with evidence
- 4SealImmutable review and one payable
- 5ActRoute the finding through versioned work
valid_success→model_failure→parent_run_id.task_defect→verifier_defect→exploit→Reviews never edit a score or feed a reward in the first recipe, because the reward stays deterministic. Demonstrations use the same assignment and pay path, and enter as a declared warm-start stage so the report can separate that gain from RL.
A success marker alone authorizes nothing
Resuming
New attempt, new fence.
A new trajectory
Must be labelled as one.
A new run
Or a reviewed separate phase.
Use a CPU worker for the first clean-load check. If a GPU loading check is needed, run it serially inside the current attempt after unloading the trainer, never as a hidden second GPU job. Do not promise identical bytes across GPU stacks. State supported versions, deterministic environment behavior and an evaluation tolerance.
Separate job, separate role, frozen first
Report covers
Efficacy result
Separate from technical completion.
Scenario groups are the independent units. The analyst picks a paired grouped method before seeing outcomes. An outage uses the predeclared rerun rule for both models. A published report never changes, and a correction links a new version. If final-test feedback informs tuning, retire that test for the new claim.
Downloads and payments are checked, not assumed
Assemble
Second engineer loads it clean.
Customer acceptance
Never inferred from a download.
Compensation is its own state machine
- ObligationRecorded on the agreed rule
- AdjustmentIf needed, approved
- InitiatedOutside this product
- SettledWith provider evidence
- Failed or reversedAppended, never overwritten
A duplicate reference cannot add a settlement twice. Currency mismatches go to review. An export file does not mean paid. Copies a customer already saved are governed by the agreement, because no system can delete them remotely.
Running in a lab's account, in six steps
Built after the first delivery. See the HLD view.
- 1AgreeContract settles access, telemetry, ownership
- 2RehearseInstall the signed bundle in a separate test account
- 3InstallLab reviews and applies it with their keys
- 4AttestLab signs the checkpoint's checksums. No copy reaches us.
- 5RegisterA lane with its narrow role and bundle digest
- 6CloseRevoke the role, stop compute, record what stays
The same contracts
JobProvider gets a lab adapterStart lease, fence, watchdog unchangedFrozen manifests and sides unchangedChanges for a lab lane
model_versions source is a lab attestationArtifact references point at lab storageReports state who could reach the testEvery job checks
If the role is revoked mid-run, dispatch and inspection stop at once. The local watchdog in the lab's account stops work when its lease expires, and the attempt stays unresolved until the lab confirms the stop.
Deletion must survive a restore
Upload accepts
Bound to a presigned POST with a length limit.
Upload rejects
A clean signature scan never means safe to run.
Bytes stay immutable. Rights expiry, quarantine and withdrawal are separate eligibility records, checked at every new release, run start, resume, evaluation and download. Long runs recheck at safe points and stop on material invalidation.
Each failure family has one retry rule
authorization_denied, scope_not_found→revision_conflict, review_already_decided→idempotency_payload_conflict→asset_unapproved, rights_blocked, release_quarantined→dispatch_unknown→provider_rejected, capacity_deadline→lease_stale, fence_stale, attempt_not_current→episode_sequence_conflict, action_payload_conflict→environment_unavailable, verifier_unavailable→trace_invalid, reward_invalid, nonfinite_training→checkpoint_incomplete, checkpoint_load_failed→budget_exhausted, runtime_limit→baseline_missing, baseline_stale→side_conflict→lane_revoked, attestation_mismatch→A 429 or 503 may carry retry-after, and the client keeps the same idempotency key when it retries. A timeout on a write never justifies a new request ID.
The web app presents. It never decides.
It does not decide payability, approval, score or ownership.
| Screen | Must behave like this |
|---|---|
| Task editor | Autosave with If-Match, show saved time, keep the local edit on 412 |
| Review | Show the exact revision. Same idempotency key on a transport retry. |
| Release builder | Show input digest and issues. Changes invalidate the report. |
| Training approval | Frozen config, cost bound, preflight. Changes create a new config. |
| Run detail | Poll with backoff. Show waiting, unknown, active, interrupted, finalizing, cancelled, complete. |
| Evaluation | Separate completion from efficacy. Show sample size, uncertainty, missingness. |
| Baseline | Show only the viewer's side. Mark a stale baseline and block approval. |
| Attempt review | Safe trace, rubric, finding class. Never show or edit a score field. |
| Downloads | Request on click, show expiry and checksum, handle revocation. |
| Payments | Show owed, initiated, confirmed, disputed. No fake success animation. |
Query keys include organization, project, resource and authorization context, and private caches clear on logout or project switch. Hidden buttons never replace API checks. Keyboard use, focus after errors, labels and readable mobile layouts are acceptance criteria.
Configuration and release operations
Validate config at startup and fail on a missing secret reference, schema version, endpoint, image or policy. Never fall back to a permissive local mode in production. Migrate by expand and contract with a dedicated role, and check active trainer callbacks too. A rollback of the image does not undo destructive data changes. Use GitHub Actions OIDC and keep real-cloud and budgeted GPU suites outside the fast CPU checks.
32 tests, each with an action and an assertion
Unit tests cover pure rules. Real PostgreSQL covers constraints and races. Real cloud covers IAM and providers. Real GPU covers optimization.
L-01 to L-11, access, tasks, money and episodes
| Test | Do this | Must hold | Covers |
|---|---|---|---|
| L-01 | Reuse a pooled connection across projects | Scope does not leak | R-52, 53 |
| L-02 | Submit a draft concurrently, then change payload | One revision, then a conflict | R-08, 09, 46 |
| L-03 | Accept as author through another role | API and database both reject | R-10 |
| L-04 | Commit acceptance, crash before send, replay | One acceptance and payable | R-05, 46 |
| L-05 | Assign siblings to different splits | Publication names the members | R-12, 26 |
| L-06 | Read test keys with trainer and environment roles | List, read, decrypt, API all denied | R-22, 27, 54 |
| L-07 | Approve two runs on a near-empty budget | No negative available amount | R-38 |
| L-08 | Force unknown submit, discover two jobs | One winner, slot held, costs kept | R-47 |
| L-09 | Expire a lease while the job still runs | No replacement starts | R-45, 47, 49 |
| L-10 | Repeat a lost action, then reuse its ID | Original once, then a conflict | R-15, 16 |
| L-11 | Crash the environment around commit | No partial state, exact replay | R-14, 18, 19 |
L-12 to L-22, training, evaluation and operations
| Test | Do this | Must hold | Covers |
|---|---|---|---|
| L-12 | Supply bad reward, mask, policy or group | No optimizer step uses it | R-23, 33, 34, 36 |
| L-13 | Train the real model on a remote GPU | Finite delta, evidence, reload | R-31 to 36 |
| L-14 | Corrupt a shard, finalize from an old fence | Neither becomes complete | R-48 |
| L-15 | Interrupt and resume full state | New attempt, links, real costs | R-37 |
| L-16 | Race cancel against completion | First commit wins | R-49 |
| L-17 | Lose control plane with a hung trainer | Watchdog stops compute in bound | R-38, 60, 63 |
| L-18 | Evaluate with deliberate missingness | Both follow the frozen rule | R-39 to 44 |
| L-19 | Deliver to a clean environment | Loads, checks, reproduces | R-50, 66 |
| L-20 | Revoke access, replay a settlement | No new URL, no duplicate | R-06, 51 |
| L-21 | Delete, restore older DB, replay register | Stays blocked before writes reopen | R-57, 62 |
| L-22 | Additive schema, then roll images back | Both versions operate | R-59, 61 |
L-23 to L-32, the full engagement loop
| Test | Do this | Must hold | Covers |
|---|---|---|---|
| L-23 | Approve a run with no baseline | Approval rejected | R-67 |
| L-24 | Change the verifier after a baseline | Comparison refused as stale | R-68, 70 |
| L-25 | Read sealed results as a training role | API, storage and report all deny | R-69 |
| L-26 | Grant a second side concurrently | API and database both reject | R-71 |
| L-27 | Add a training-side author to a sealed release | Publication fails | R-72 |
| L-28 | Build a sample that reaches test attempts | Rejected, and the rule is recorded | R-73 |
| L-29 | Replay an attempt review | One review and payable, score unchanged | R-74, 75 |
| L-30 | Copy weights out with our role in a rehearsal account | Denied at storage and network | R-78 |
| L-31 | Revoke our role during a run | No new jobs, watchdog stops work | R-79 |
| L-32 | Install a tampered bundle | Signature check fails before start | R-77 |
Eleven slices, the riskiest first
Estimate dates after slice one. Actual RL, independent review, honest evidence and basic data protection stay required, even in the demo.
- One custom task, verifier and real RL runLock, schema, gradients, GPU profile, reload
- Identity, grants, schema, storage permissionsDenied-access matrix, pool-reuse test
- Agreement, claim, draft, review, payableFull path with race and retry tests
- Action journal, scoring, immutable splitsReplay, bypass tests, purpose manifests
- Baseline and the two expert sidesApproval gate, side conflict, sealed read denials
- Freeze, preflight, approval, outbox, dispatchUnknown-submit, stale authority, spend-stop drills
- Checkpoint validation, recovery, cancelCorruption, interruption, race on real compute
- Paid attempt review and linked roundsFrozen sample, one payable, score unchanged
- Sealed evaluation, report, clean deliveryFair comparison, audit, cost, loading
- Backups, deletion replay, handoff, second projectAnother engineer runs the runbooks
- Lab lane in a rehearsal account, then a real labNo-egress, revocation, tampered-bundle tests, lab review