Repository navigation
Demo/read state - #335
Draft
AlexAxthelm wants to merge 11 commits into
Draft
Demo/read state#335AlexAxthelm wants to merge 11 commits into
AlexAxthelm wants to merge 11 commits into
Conversation
Add og_field_resource_state (one row per resource and permission profile, holding each field's winning value, its source, and the commit that computed it) and its single readiness row, plus the four exact permission profiles the table is keyed by. Schema only: the tables start empty and not ready, and nothing writes or reads them yet, so answers are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: ChatGPT <noreply@openai.com>
Compute each listable resource's rows for the four permission profiles from the same winner query the live list uses, and add the rebuild command: a full rebuild in committed batches behind the readiness flag, --if-stale for the post-deploy step (resumes where a failed run stopped), and --ids to repair specific resources. A full rebuild records the commit that built it, redoes rows computed by other code, checks the result before marking it ready, and holds a Postgres advisory lock so two can't overlap. Run the Postgres-only tests in CI. Nothing reads the table yet and API writes don't refresh it, so answers are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A full rebuild's integrity check couldn't see an --ids repair's uncommitted rows, so a repair from another image could commit between the check and readiness, leaving a table marked as built by one commit holding rows from another. Do the final check for rows from other code in the transaction that sets readiness, holding the status row exclusively (repairs hold it shared): a repair already running is waited for and its rows get another pass; one starting later waits, then refuses because other code built the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the rebuild's expected failures print as a single ERROR line; unexpected ones (e.g. an unreachable database) keep their traceback, which is what you want for debugging them. Both exit with status 1; invalid arguments exit with status 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-766) Attaching or creating sources, re-ordering a field's sources, and merging now recompute the affected resources' read-model rows in the same transaction. Each write locks its resources first (in id order for merges) and re-reads them after locking: locking later lets two writers deadlock upgrading the foreign-key locks their inserts take, and a write that waited must see a merge that committed meanwhile. Nothing reads the table yet, so answers are unchanged; each write pays ~85 ms at 50K resources for the refresh (~16 ms with #322's index). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FOR UPDATE conflicts with the key-share lock that inserting any row referencing a resource takes. Creating a merge candidate for [B, A] holds key-share on B, then waits on A, while a merge of [A, B] holds A and waits on B: Postgres aborts one. FOR NO KEY UPDATE (the lock an update of repointed_id already takes) still makes writers queue but never conflicts with key-share, so no insert path needs to lock first to stay safe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-766) List and filter-options now read precomputed rows when the caller's licensed sources exactly match a permission profile and the read model is ready (built by this commit); otherwise they answer live, unchanged. At 50K resources list requests drop from ~2-3 s to under 10 ms. Each process caches readiness for up to 5 s, so most requests skip the lookup. Operators can switch the fast path off with a new `disabled` flag that rebuilds never clear, so a deploy's rebuild can't undo it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a Rebuild Read Model job that runs `rebuild --if-stale` from the deployed API image once the API deploy finishes, so each deploy of new code gets its fast path back without a manual step. The API deploy now waits until the previous revision has stopped serving (plus 45 s for in-flight requests), so the old code's writes can't land after the rebuild marks the table ready. Nothing waits on the rebuild: if it fails, lists stay on the slower live path and the PR summary comment shows a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CD summary
|
| service | url | fqdn |
|---|---|---|
| api | open | pr-0335-demo-read-stat-ea7c-api.salmonsea-0e166cd2.westus2.azurecontainerapps.io |
| etl | open | pr-0335-demo-read-stat-ea7c-etl.salmonsea-0e166cd2.westus2.azurecontainerapps.io |
| frontend | https://brave-cliff-09493391e-335.westus2.7.azurestaticapps.net | |
| stitch-llm | open | pr-0335-demo-read-stat-ea7c-llm.salmonsea-0e166cd2.westus2.azurecontainerapps.io |
Database (1)
| db_name | postgres_host | postgres_port | postgres_db |
|---|---|---|---|
| pr_0335_demo_read_stat_ea7c | stitch-staging.postgres.database.azure.com |
5432 |
pr_0335_demo_read_stat_ea7c |
Jobs (1)
| job | image | postgres_db |
|---|---|---|
| db-migrations | ghcr.io/rmi/stitch-api:pr-0335-demo-read-stat-ea7c@sha256:ee0151af9fc637d58fd4c68d51a97bf584a33dffb3839c911f4f19bd3da87904 |
pr_0335_demo_read_stat_ea7c |
Images (2)
| build_time | commit_time | git_sha | image | image_digest |
|---|---|---|---|---|
| 2026-10-16T09:21:11Z | 2026-10-16T09:20:49Z | 3585a10 | ghcr.io/rmi/stitch-api:pr-0335-demo-read-stat-ea7c |
ghcr.io/rmi/stitch-api:pr-0335-demo-read-stat-ea7c@sha256:ee0151af9fc637d58fd4c68d51a97bf584a33dffb3839c911f4f19bd3da87904 |
| 2026-10-16T09:21:08Z | 2026-10-16T09:20:49Z | 3585a10 | ghcr.io/rmi/stitch-stitch-llm:pr-0335-demo-read-stat-ea7c |
ghcr.io/rmi/stitch-stitch-llm:pr-0335-demo-read-stat-ea7c@sha256:96066d437b7125d5dca2db03c775ad51a42b121456fb790606feb5cb2df8eedd |
A switched-off table built by commit A accepted a repair from commit B, leaving B's rows in a table still marked ready as built by A. --if-stale from A then saw nothing to redo, and switching the table back on served B's rows under A indefinitely. Apply the version guard whether or not the table is switched off: repair it from the image that built it, or rebuild it from the new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An API process that cached "ready" in the last 5 seconds keeps reading the table, so a rebuild by other code during that window can hand it rows the new code just rewrote. Deploys already wait for the previous revision to stop serving first; say so where rebuilds are documented and where the cache is defined. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CD summary
|
| service | url | fqdn |
|---|---|---|
| api | open | pr-0335-demo-read-stat-ea7c-api.salmonsea-0e166cd2.westus2.azurecontainerapps.io |
| etl | open | pr-0335-demo-read-stat-ea7c-etl.salmonsea-0e166cd2.westus2.azurecontainerapps.io |
| frontend | https://brave-cliff-09493391e-335.westus2.7.azurestaticapps.net | |
| stitch-llm | open | pr-0335-demo-read-stat-ea7c-llm.salmonsea-0e166cd2.westus2.azurecontainerapps.io |
Database (1)
| db_name | postgres_host | postgres_port | postgres_db |
|---|---|---|---|
| pr_0335_demo_read_stat_ea7c | stitch-staging.postgres.database.azure.com |
5432 |
pr_0335_demo_read_stat_ea7c |
Jobs (1)
| job | image | postgres_db |
|---|---|---|
| db-migrations | ghcr.io/rmi/stitch-api:pr-0335-demo-read-stat-ea7c@sha256:16e7a084cca5d564716c8902ea6efb855aed6ddae4fad8482b9d2740e1e2cc44 |
pr_0335_demo_read_stat_ea7c |
Images (2)
| build_time | commit_time | git_sha | image | image_digest |
|---|---|---|---|---|
| 2026-10-16T10:11:32Z | 2026-10-16T10:11:16Z | 04e7023 | ghcr.io/rmi/stitch-api:pr-0335-demo-read-stat-ea7c |
ghcr.io/rmi/stitch-api:pr-0335-demo-read-stat-ea7c@sha256:16e7a084cca5d564716c8902ea6efb855aed6ddae4fad8482b9d2740e1e2cc44 |
| 2026-10-16T10:11:35Z | 2026-10-16T10:11:16Z | 04e7023 | ghcr.io/rmi/stitch-stitch-llm:pr-0335-demo-read-stat-ea7c |
ghcr.io/rmi/stitch-stitch-llm:pr-0335-demo-read-stat-ea7c@sha256:ebfca9d47241d24bbe53fa20909fed308e3a9550e5884cd527c9e896811995f5 |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Demo for stack of #330, #331, #332, #333, #334