fix(selfhost): reconcile a stale AMS reporting export's schema on preserve-last-good - #5757
Merged
Merged
Conversation
…serve-last-good An instance whose ams-attempt-log source has never existed (an engine-only deployment with no co-located miner) creates its one-and-only export under whichever DDL was current at that moment, then export_ledger's "source missing, output already exists" fail-open path preserves it forever -- the fingerprint/SCRIPT_VERSION rebuild check is unreachable while the source stays absent, so a later DDL widening (PR #5637 added provider/cost_usd/tokens_used to attempt_log_events a day after PR #5471 first shipped this script) was previously invisible to such an instance permanently. Every miner-usage.json panel selecting those columns then hard-fails with "no such column" instead of just showing empty. Fixed by reconciling the preserved output's schema against the current DDL's declared columns (ALTER TABLE ADD COLUMN, mirroring packages/gittensory-miner/lib/attempt-log.js's own ensureOutcomeColumns pattern) whenever a preserve-last-good path fires -- additive only, so existing rows and their data are never touched.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5757 +/- ##
=======================================
Coverage 95.07% 95.07%
=======================================
Files 581 581
Lines 46181 46181
Branches 14811 14811
=======================================
Hits 43905 43905
Misses 1516 1516
Partials 760 760
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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
scripts/export-ams-reporting-db.sh, confirmed via git history -- PR fix(observability): avoid exposing live AMS ledgers #5471 first shipped this script withattempt_log_events' DDL missingprovider/cost_usd/tokens_used; PR feat(miner): persist coding-agent provider + real cost on the attempt log #5637 added those columns to the DDL one day later.export_ledger's "source missing, output already exists" fail-open path then preserves that output forever -- the fingerprint/SCRIPT_VERSIONrebuild check is unreachable while the source stays absent, so the later DDL widening was invisible to such an instance permanently.ALTER TABLE ... ADD COLUMN) whenever a preserve-last-good path fires, mirroringpackages/gittensory-miner/lib/attempt-log.js's ownensureOutcomeColumnspattern. Additive only -- existing rows and data are never touched; a genuinely-never-collected column is simplyNULLfor pre-existing rows.Test plan
npx tsc --noEmitnpx tsx scripts/check-docs-drift.mjsshellcheck scripts/export-ams-reporting-db.shNULLfor the pre-existing row) rather than staying frozen -- verified this test fails without the fix (reverted the fix locally, confirmed the exact failure), and passes with itselfhost-ams-reporting.test.tssuite green (10/10)