Skip to content

docs(adr-002): align Preflight entity design with Ekrem alignment decisions#2459

Closed
GeezerPelletier wants to merge 41 commits into
mainfrom
sites-44290-preflight-adr-update
Closed

docs(adr-002): align Preflight entity design with Ekrem alignment decisions#2459
GeezerPelletier wants to merge 41 commits into
mainfrom
sites-44290-preflight-adr-update

Conversation

@GeezerPelletier
Copy link
Copy Markdown
Contributor

Summary

Updates ADR-002 to reflect decisions from the SITES-44675 alignment session with @ekdogan. The ADR was previously marked as pending that alignment — this PR closes it out.

Four changes to the Data Model section:

  • asyncJobId field added to the entity schema — makes the 1-to-1 FK relationship to AsyncJob explicit; field is never exposed to API consumers
  • Creation flow documented — controller creates AsyncJob first, receives asyncJobId, then creates Preflight with that FK; ordering ensures the execution primitive exists before the domain record that references it
  • url index annotation removed(indexed) on url was inconsistent with the collection method already specifying in-memory filtering; composite (site_id, url) index is explicitly deferred (7-day TTL bounds per-site volume to a manageable size)
  • Alignment placeholder replaced — "should be aligned with @ekdogan" sentence replaced with a summary of confirmed decisions

Related

Generated with Claude Code

Guy Pelletier and others added 30 commits May 8, 2026 14:25
Captures the decision to replace /preflight/jobs and /preflight/beta/jobs
with site-scoped endpoints under /sites/:siteId/preflights.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AsyncJob has no siteId index; GET /sites/:siteId/preflights requires
either extending AsyncJob or a new Preflight entity in shared-data-access.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eId index

AsyncJob TTL (~7 days) makes a purpose-built Preflight entity unnecessary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Existing job creation paths must not be affected; new endpoints
populate siteId at creation time and query by it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Capture IMS caller identity server-side at job creation for audit purposes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sponse

Per RFC 7231 §6.3.3 the created resource URL belongs in the Location
response header, not a custom body field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add error response table to POST endpoint (400/403/404/500)
- Disabled-site case returns 403 immediately; no job record created
- Previous CANCELLED-job behavior on disabled preflight is explicitly removed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both /preflight/beta/jobs and /preflight/jobs are deprecated and run in
parallel with the new endpoints until consumers migrate and a deletion
milestone is agreed upon.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Confirmed by Ben: identify/suggest are no longer separate steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dev-only override, not part of the public contract.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both fields available on IMS profile at no extra cost.
Easier to extend in future without breaking API contract.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Prevents callers submitting a url belonging to a different site than
the :siteId in the path. Returns PREFLIGHT_INVALID_REQUEST if mismatch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Id response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…moved

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iteId

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GeezerPelletier and others added 10 commits May 13, 2026 08:24
…resultType

- Flatten GET list response from URL-grouped to flat array sorted by createdAt desc
- Add optional ?url= query parameter to filter list by specific page URL server-side
- Remove 50-record cap; 7-day AsyncJob TTL is the natural bound, pagination deferred
- Rename createdBy.id -> createdBy.email throughout (consistent with profile field name)
- Note that createdBy is stored in async job metadata at creation time
- Remove resultType and resultLocation from GET by ID response; preflight results are
  always stored inline in async_jobs.result, never in S3
- Clarify result field: always inline, null until job completes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ght entity

Rewrites the Data Model section of ADR-002 to introduce a first-class
Preflight entity in spacecat-shared-data-access rather than extending
the generic AsyncJob model. AsyncJob is shared by preflight, preflight-beta,
site-detection, and pr-review — using it as the preflight store forces
type discrimination via metadata blobs with no schema enforcement.
References SITES-44650 for the spacecat-shared-data-access alignment
work with @ekremney.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…yncJob

A dedicated Preflight table scopes every row to preflight by definition.
Querying AsyncJob by siteId would require a compound (site_id, job_type)
filter or composite index to isolate preflight records from the other
workflows sharing the table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The /preflight/beta/jobs endpoint was a temporary internal development
path, never intended as a durable design. Calling it out as an anti-pattern
is noise — it was always going away.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The /preflight/beta/jobs endpoints were an internal development path
with no external consumers. This redesign is their replacement — they
are removed outright, not deprecated. Only /preflight/jobs carries a
deprecation timeline since it has external consumers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ions

- Add asyncJobId FK field (1-to-1 with AsyncJob) to entity schema
- Document controller creation flow: AsyncJob first, then Preflight with asyncJobId
- Remove (indexed) annotation from url field; composite index deferred
- Replace open alignment question with confirmed decisions from SITES-44675
- Clarify TTL: TTL column at 7 days, verify column name in mysticat-data-service

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…oved not deprecated

Only /preflight/jobs is the legacy endpoint that continues in parallel.
/preflight/beta/jobs is replaced outright by the new endpoints.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

This PR will trigger no release when merged.

@GeezerPelletier GeezerPelletier deleted the sites-44290-preflight-adr-update branch May 21, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant