Repository navigation
Description
Context & Rationale
is_file_reference (security/reference_extractor.py:530) lists the source file's sibling directories and checks each one on disk for every domain-like token (:552-556). Profiling tests/test_review_pipeline.py::test_review_pipeline_stages showed 461 calls making 45,089 stat calls: 10.7s of a 13.2s test, at 0.24ms each on the 9p workspace mount. Real devops ai review runs pay the same cost for every token.
Scope & Deliverables
- Deliverable: cache each directory's child listing once per process, as
_get_workspace_filenamesalready does for the workspace walk, so checking a token becomes a set lookup. - Constraint: keep the exact-case matching of the current
is_file()check.
Strategic Alignment
- Milestone: backlog (no release)
- Related: fix(ci): devops ci quality gate finishes within five minutes #748, where the profile was taken
Scope added 2026-10-02: #431 (v0.2.26, p1) deletes is_file_reference, is_code_or_config_reference, _get_workspace_filenames and their only callers, is_network_domain and _extract_domain_reference (its Proposed Solution). That removes both the per-token disk checks this item targets and a larger cost found since. At 38517a8 on the ext4 workspace, step 4 of is_file_reference, the loop over every workspace path (security/reference_extractor.py:565-570), took 73% of a miss in two measurements (0.91 of 1.25 ms, and 3.0 of 4.2 ms on a loaded machine; 2,000 domain-like tokens, source file ai/review/pipeline.py). The list holds 3,280 entries, because _get_workspace_filenames (:283-330) adds each file's name and its relative path. is_code_or_config_reference repeats a substring scan over the same list (:666-670, about 0.45 ms per miss). The release review evaluation measured reference extraction at 39-94 s of sequential CPU per branch review, 48-63% of it in is_file_reference. So this item closes as not planned when #431 merges, as #431's key question "What happens to #750?" already says, and needs no PR of its own.
- If fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 is descoped instead, this item also replaces step 4 of
is_file_referenceand the scan inis_code_or_config_referencewith lookups built once per workspace listing. A table test runs the old and new code on a fixture tree over segment,/-suffix, bare-suffix and dotted-module matches and misses, and gets the same answer for each. It runs offline in under 1 s.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Closing as not planned, as this item's 2026-10-02 note planned. #431 (PR #1168, v0.2.26) deleted
is_file_reference,is_code_or_config_reference,_get_workspace_filenames,is_network_domainand_extract_domain_reference, so the per-token disk checks and the workspace-list scan are gone. Reference extraction now reads only URL and IP syntax (security/reference_extractor.py:469,:504).Found by the 2026-10-08 backlog review.