Repository navigation
Conversation
A conversion reads every co-filer's filing_document rows by accession alone; the primary key leads with cik, so that read scanned the whole table on every conversion. Add an accession_number index. InitApplyTask set process.env from the new wizard answers but never removed owned keys the answers left unset, so a SEC_PG_URL from an earlier run in the same process outranked the host/port/user just chosen. process.env now mirrors envEntriesFor exactly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015q4aqYR4rAGcnHCooSqJ4s
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
Two fixes on top of
claude/elegant-fermi-brwjz1.filing_documentread by accession was a full table scan.ConvertFilingDocumentTasknow reads every row of its submission byaccession_numberalone, before it replaces its own rows. It has to read across CIKs, because the co-filer check (factsAlreadyCurrent) looks at rows filed under other CIKs, so narrowing the query to{cik, accession_number}isn't an option. The primary key(cik, accession_number, doc_file)starts withcik, and none of the existing indexes starts withaccession_number. So every conversion scanned the whole table, and a re-conversion sweep cost grew quadratically. This PR adds an["accession_number"]index.sec setupleft old wizard keys inprocess.env.InitApplyTaskset the keys for the new answers but never removed old ones. Say a first setup in a process usedSEC_PG_URLand a second one switched to host/port/user. The old URL stayed set and took precedence, sosetupAllDatabasesbuilt the tables in the old database. The newapplyEnvConfig(env, config)inenvFile.tssets each key inWIZARD_ENV_KEYSfromenvEntriesFor(config)and deletes any key that has no entry.process.envnow matches what.env.localholds.Tests
src/task/document/filingDocumentByAccession.sqlite.test.ts:SEARCH ... USING INDEX). This fails without the index and passes with it.src/cli/groups/init.test.ts: newapplyEnvConfigcases:SEC_PG_URLSEC_PG_*keysbunx vitest run src/config src/cli/groups src/task/kb src/task/document: 229 passed, 6 skipped.bun run typecheck,bun run lintandbun run format-checkpass.Generated by Claude Code