Skip to content

ops(registry): convert stale-type backfill from script to migration#3797

Closed
EmmaLouise2018 wants to merge 2 commits into
mainfrom
EmmaLouise2018/backfill-migration
Closed

ops(registry): convert stale-type backfill from script to migration#3797
EmmaLouise2018 wants to merge 2 commits into
mainfrom
EmmaLouise2018/backfill-migration

Conversation

@EmmaLouise2018

Copy link
Copy Markdown
Contributor

Summary

  • Replaces server/scripts/backfill-member-agent-types.ts (ops(registry): backfill stale member_profiles.agents types + crawler reclassify-on-disagreement #3541) with migration 463_backfill_member_agent_types_from_snapshot.sql.
  • The TS script lived under server/scripts/ — outside server/src/ — so tsc skipped it and it never shipped to the production container. Running it via fly ssh console failed with ERR_MODULE_NOT_FOUND.
  • The migration applies the same resolveAgentTypes() logic in SQL, runs automatically on the next deploy in every env, and writes its audit trail to type_reclassification_log with run_id='migration-463' in one transaction with the data update.

What it does

For every row in member_profiles.agents whose URL has a row in agent_capabilities_snapshot:

  • snapshot inferred_type is valid → set agent's type to it
  • snapshot exists but inferred_type is null/invalid → set 'unknown' (anti type-smuggling, matches resolveAgentTypes)
  • no snapshot → leave the agent untouched

Audit query post-deploy:

SELECT * FROM type_reclassification_log WHERE run_id = 'migration-463';

Test plan

  • npm run typecheck clean
  • npm run build clean
  • npm run test:migrations clean (filename pattern, no duplicate version, no gap)
  • Pre-commit hooks (test:unit + test:test-dynamic-imports + test:callapi-state-change + typecheck) passed
  • On staging: confirm migration applies cleanly, verify run_id='migration-463' rows match the JSONB diff
  • On prod: same verification after deploy

Refs #3538, #3541, #3550.

Migration 463 replaces server/scripts/backfill-member-agent-types.ts.
The TS script lived under server/scripts/ (outside server/src/), so tsc
skipped it and the file never shipped to the production container —
running it required a fly ssh dance that failed with ERR_MODULE_NOT_FOUND.

The migration applies the same resolveAgentTypes() logic in SQL, runs
automatically on the next deploy in every env, and writes its audit
trail to type_reclassification_log with run_id='migration-463' in one
transaction.
@EmmaLouise2018 EmmaLouise2018 requested a review from bokelley as a code owner May 1, 2026 23:14
Changesets are append-only history. The previous commit on this branch
deleted this file when removing the script — that's wrong. The original
changeset describes what landed in #3541 and stays as historical record;
the new migration changeset (backfill-member-agent-types-migration.md)
describes the follow-up.
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