Skip to content

"Every Postgres identifier is schema-qualified" describes 4 DDL files, not the 5 raw-SQL DML sites — and the call-site list is short by 3 #336

Description

@sroussey

CLAUDE.md states this as an absolute:

Every Postgres identifier is schema-qualified to current_schema() (quote / currentSchemaName in src/util/pgIdentifiers.ts). Unqualified names resolve through search_path and would reach a same-named table in another schema — the hazard applies to DDL, drops, catalog probes and row-count estimates alike.

Measured in the tree, pgIdentifiers is imported by exactly four files, all DDL/catalog:

  • src/config/resetAllDatabases.ts
  • src/config/alignPostgresColumnTypes.ts
  • src/config/addMissingColumns.ts
  • src/config/dropStaleCheckConstraints.ts

Every raw-SQL DML site uses bare identifiers:

  • src/task/bootstrap/feedFilings.ts:92SELECT DISTINCT "filing_date" FROM "filings"…
  • src/task/bootstrap/feedFilings.ts:129… FROM "filings" WHERE "filing_date" = $1
  • src/storage/spac/SpacDealReplace.ts:154DELETE FROM "spac_deal" …
  • src/storage/form-8k-event/Form8KEventReplace.ts:83DELETE FROM "form_8k_events" …
  • src/storage/entity/cikNameBulkWriter.ts:110INSERT INTO "cik_names" …
  • src/task/document/selectFilingsToConvert.ts:250-262FROM "filings" f LEFT JOIN "filing_document" d …, plus FROM "spac" s at :246. Added this window.

Nothing is broken today — sec's own deployments run in one schema — but the rule as written is not the rule the code follows, and a new call site landed under it without anyone noticing, which is exactly how a stated-but-unenforced contract stops being useful.

Ask: pick one and make them agree.

  1. Qualify the DML sites through quote / currentSchemaName like the DDL tier already does; or
  2. Scope the CLAUDE.md rule explicitly to DDL, drops and catalog access, and say why DML is exempt (a single-schema search_path is the deployment assumption).

Second, smaller item in the same paragraph. CLAUDE.md:238-240 enumerates the raw-SQL call sites as:

Call sites: cikNameBulkWriter.ts, Form8KEventReplace.ts, SpacDealReplace.ts (writes); feedFilings.ts (reads).

grep -rn "resolveSqlBackend(" src --include=*.ts | grep -v test returns seven non-test files — the four above plus src/task/spac/spacCandidateScan.ts:230, src/cli/queries/DbStatus.ts:187, and src/task/document/selectFilingsToConvert.ts:177-181. The list should either be complete or be replaced by the grep that produces it.

(For the record, the new site is otherwise careful: selectFilingsToConvert.ts:175-181 gates the fast path on every table the query reads, so one non-durable repo demotes the whole query to the repository path.)

Found during the 2026-08-31 review. Snapshot: workglow-dev/prdanalysis/grades/2026-08-31/sec-detailed.md §4.2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions