feat(aqs): land focused AQS ingest recovery for BUY-12919 - #168
Open
BuyWhere wants to merge 1 commit into
Open
Conversation
…riter (BUY-33907) The 2026-05-12 AQS feature branch commit (e0aff70) shipped only app/services/aqs_calculator.py + scripts/aqs_calculator.py. The rest of the BUY-12919 scope — scheduled workflow, /v1/aqs/* routes, aqs_cycles Postgres table, AQS_TEST_CYCLE_URL contract, and Railway-aware deploy — was never merged to main. This commit re-delivers the missing surface so BUY-16518 has a real (workflow → writer → table → API verify) path to dispatch against. Additions - .github/workflows/aqs-ingest.yml Every 15 min (off the :00/:15/:30/:45 marks, see comment). Fetches the test-cycle JSON from $AQS_TEST_CYCLE_URL, falls back to /tmp/aqs-cycles/ on first-run, runs scripts/aqs_calculator.py --store, then verifies via GET /v1/aqs/health. - api/src/aqs/repository.ts Read-side helper: listRecentCycles, getCycleById, getLatestCycle, getHealth. Idempotent; all queries are parameterised. - api/src/routes/aqs.ts GET /v1/aqs/{health,latest,cycles,cycles/:cycle_id}. Public, no auth — AQS is a public-facing quality signal. - api/src/migrate.ts → AQS_MIGRATION Adds aqs_cycles (BIGSERIAL PK, UNIQUE cycle_id, JSONB columns for dimensions / sub_metrics / escalations / raw_payload, three indexes on computed_at / grade / aqs). Non-fatal: missing table falls back to file-based JSONL history. - app/services/aqs_storage.py Python writer. Uses psycopg (v3) with psycopg2 fallback. Upsert on cycle_id so retries don't duplicate. Non-blocking on failure (file history is the source of truth for offline replay). - scripts/aqs_calculator.py --store / --source / --database-url Extends the existing 15-min runner with a Postgres persist step. - docs/AQS_INGEST.md Operating manual: pipeline diagram, secret table, AQS_TEST_CYCLE_URL data contract (BUY-12885 §4.1), local-usage examples, and acceptance checklist tying BUY-33907 to BUY-16518. Changes - api/src/server.ts: mount /v1/aqs - .github/workflows/deploy-api-production.yml: rewrite for the Railway target (BUY-15318). Same service id (945e8a6d-...) and env id (ebcb2ca2-...) as deploy-railway.yml. Keeps the regression + smoke gates; drops the GCP/SSH path. Acceptance - aqs-ingest.yml is on main (Path A) — once this PR is merged. - A real path exists for BUY-16518 to dispatch + verify a write. Refs BUY-12919, BUY-16518, BUY-15318, BUY-33837, BUY-12885, BUY-12892. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 5c82d4d)
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.
Summary
Re-lands the AQS ingest pipeline from BUY-12919 as a focused single-commit recovery on top of current
main.This strips out the unrelated commits that accumulated on PR #128 and keeps only the AQS surface:
.github/workflows/aqs-ingest.ymlapi/src/aqs/repository.tsapi/src/routes/aqs.tsapi/src/migrate.tsapi/src/server.tsapp/services/aqs_storage.pyscripts/aqs_calculator.pydocs/AQS_INGEST.md.github/workflows/deploy-api-production.ymlVerification
origin/mainasae2397aepublic.aqs_cycleswith the expected columns and indexespublic.aqs_cyclescurrently contains 1 backfill row (cycle_id=2026-06-07T15:00:00Z,aqs=86.73,grade=Good,source=backfill)Remaining runtime requirement
GitHub Actions still needs the runtime secrets/envs used by
aqs-ingest.yml(notably the test-cycle source URL and DB connection path) to produce new scheduled rows after merge.