Repository navigation
Conversation
…er-only Bun's .env loader expands $NAME inside single and double quotes alike, honours only \$ as an escape, and keeps \" and \\ literally, so the old writer turned a password like pa$$w0rd$HOME into pa$/root on the next command. Values are now quoted with whichever quote they lack and every $ is written \$; a line break, both quote kinds, or a trailing backslash has no spelling and is refused with the key named. Setup no longer replaces .env.local: it rewrites the keys it owns (removing owned keys the new answers leave unset) and keeps API keys, fetch limits and comments. The file is written and chmod'ed 0600, the password and connection string are read without echo, and --dry-run prints them masked. The new test spawns bun to load the written file and compares. Fixes #404 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015q4aqYG7aoVFafwF8YprdM
…on removed The index selection anti-joined on kb_document existence, so a filing re-converted after a FILING_CONVERTER_VERSION bump kept its old knowledge-base row and was never re-embedded; `ask` went on citing the previous converter's text, and a member the new pass no longer emits stayed citable forever since nothing deleted knowledge-base documents. - A re-conversion now retires what the knowledge base holds for the members it replaces: it clears kb_indexed_at on every row naming them (co-filers included) and then purges their kb_document and kb_chunk rows (purgeKbDocuments, a no-op wherever the index cannot exist). - Once db setup has backfilled the stamp, the selection reads it alone: null means "not embedded from the conversion on disk". Before that (no partial index) it keeps the anti-join. - db setup backfills stamps only in the pass that creates the partial index, so a later setup no longer re-stamps a re-converted document. - countAlreadyIndexed counts the stamped complement. Fixes #401 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015q4aqYG7aoVFafwF8YprdM
…irst xbrl_fact is keyed by accession, but conversion runs once per (cik, accession). Each co-filer's conversion deleted the accession's facts and rewrote them under its own CIK, so `sec show xbrl --cik` went empty for every filer but the last; the delete-then-put order was also the one XbrlFactRepo documents as losing every fact on a rejected row. - Facts belong to the submission. A conversion skips extraction when a co-filer's conversion at the current converter version already wrote them, and otherwise writes through XbrlFactRepo.replaceForAccession (write first, then trim the stale tail; an empty extraction clears). replaceForAccession now batches its putBulk calls. - queryXbrlFacts by CIK reads the accessions that CIK has converted documents under, in ascending `in` chunks paged in order, falling back to the cik column when it has none. Existing databases need no migration: their facts already answer for every filer this way. - Remove XbrlFactRepo.getByCikConcept, unused outside its test and wrong for co-filed submissions. Fixes #402 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015q4aqYG7aoVFafwF8YprdM
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
This PR refactors environment file handling to properly quote values for Bun's
.envloader, implements knowledge base document purging on re-conversion, and improves XBRL fact querying for co-filed submissions.Key Changes
Environment File Handling (
src/task/init/envFile.ts)InitApplyTaskwith proper.env.localquoting logicencodeEnvValue()that quotes values with single or double quotes and escapes$signs, ensuring Bun's loader reads back exactly what was writtenmergeEnvConfig()to fold wizard answers into existing.env.localfiles, preserving non-wizard lines and removing stale keyswriteEnvFile()with owner-only file permissions (0o600) for securityredactInitConfig()to mask credentials in printed outputKnowledge Base Document Lifecycle
purgeKbDocuments()function (src/kb/purgeKbDocuments.ts) removes documents and chunks from the knowledge base before re-conversionretireIndexedDocuments()inConvertFilingDocumentTaskclearskb_indexed_atstamps before purging, ensuring interrupted operations don't permanently hide documentsKnowledge Base Indexing Stamp (
src/config/kbIndexedStamp.ts)kb_indexed_atmeans "embedded from the conversion on disk", not just "has a kb_document row"db setup; subsequent passes clear stamps for documents the knowledge base no longer backsXBRL Fact Querying for Co-filed Submissions (
src/cli/queries/XbrlQuery.ts)accessionsConvertedFor()function queries which accessions a CIK has converted documents underfactCriteria()function builds search criteria covering accessions in chunks (500 perinlist) to respect SQLite/Postgres parameter limitspageAcross()andstreamAcross()functions paginate and stream facts across multiple criteria in(accession, fact_index)orderCLI Initialization (
src/cli/groups/init.ts)Prompterinterface withask()andaskSecret()methodsaskSecret()mutes stdout while reading passwords/URLs to prevent echoing credentialsenvFilemodule.env.localis merged, not overwrittenTest Coverage
reconversionIndex.sqlite.test.tstests knowledge base behavior during re-conversionConvertFilingDocumentTask.coFiled.test.tsverifies co-filed submission facts remain accessible to all filersinit.test.tswith round-trip tests through Bun's.envloader, testing special characters, quotes, backslashes, and file mergingXbrlQuery.test.tswith pagination tests across 501+ accessionsNotable Implementation Details
.envloader quirks: Values are quoted with whichever quote character they don't contain;$is escaped as\$; line breaks, both quote types, and trailing backslashes are rejectedfiling_documenttable