Skip to content

Nothing detects drift between lib/constants/agents.ts and the agents table #53

Description

@royalpinto007

lib/constants/agents.ts exports a hardcoded AGENTS array, and the agents table in Supabase holds its own copy. Nothing keeps them in sync, and several parts of the site read different sides of that split:

  • app/(public)/agent/page.tsx renders the index from the constant and prints {AGENTS.length} agents tracked across {companies.length} companies, so the headline count is whatever the file says.
  • app/sitemap.ts emits one /agent/[slug] URL per entry in the constant.
  • app/api/posts/route.ts resolves agentSlug to an agent_id by querying the table, and app/api/agents/route.ts serves the submit form from the table.

So an agent present in the database but not the constant is submittable and has real cases but never appears on the agent index or in the sitemap. An agent present in the constant but not the database gets an index card, a sitemap entry and an indexable page, and is rejected with "Unknown agent." the moment someone tries to submit against it. CONTRIBUTING.md already tells contributors to update both places by hand, which is exactly the kind of instruction that decays.

Same argument applies to lib/constants/tags.ts and the tags table.

Ideas, any of which would be an improvement:

  • A script under scripts/ that diffs the constant against the table and exits non-zero on drift, runnable by a maintainer against production.
  • A test that loads both and asserts slug-set equality, skipped when Supabase credentials are absent so it does not break CI or outside contributors.
  • Or remove the duplication: make the table the single source of truth and have the agent index and sitemap read from it, keeping the constant only as seed data for scripts/.

Worth opening with a comment on which of these you want to do before writing much code, since the third option touches several pages.

If you would like to take this on, comment here to claim it. Contributors can hold two open claims at a time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions