Skip to content

Add artifact projection endpoints: POST /projections/transitions + GET /projections/:artifact_id/cursor #96

@ssilvius

Description

@ssilvius

Context

Part of RFC #307 team-repo-substrate. Smugglr uses push to keep platform D1 current with the git backbone. These two endpoints close the push contract.

Endpoints

POST /projections/transitions

Smugglr posts this when an artifact transition commits to the git log.

  • Body: transition payload (artifact_id, transition_id, status, produced_refs[], committed_version)
  • Idempotent on transition_id -- duplicate posts return 200, not 422
  • 409 if idempotency_key on a produced_ref does not match a known Pending row for (artifact_id, target_repo)
  • Accepts both Pending and Resolved variants of produced_refs (discriminated union)
  • Stamps committed_version at write time (monotonic, LWW-compatible with legion cluster sync)

GET /projections/:artifact_id/cursor

Returns the committed_version token for the artifact's current D1 projection state.

  • Used by ctrl's TanStack Query staleness check
  • Returns {artifact_id, committed_version, updated_at}
  • 404 if artifact not yet projected

Schema

New D1 tables: artifact_projections, artifact_produced_refs. Migration via wrangler (no drizzle-kit).

produced_refs rows carry discriminated kind: 'pending' | 'resolved'. Pending rows have no number; Resolved rows have number + url + created_at.

Fan-out callback (Resolved writes)

Legion CLI owns the Pending -> Resolved flip. After GitHub returns a number, the CLI posts the Resolved variant to this endpoint with the matching idempotency_key. Platform validates the key against the Pending row and writes the Resolved state. 409 on mismatch, 200 idempotent on duplicate.

Migration sequencing

Migration must be applied to preview D1 before smugglr's emitter ships. Coordinate with smugglr on sprint start date to ensure preview apply precedes emitter traffic.

Related

  • RFC #307 smugglr push decision: post 019db77b-4e45
  • Platform reply confirming push: post 019db77d-0832

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions