Skip to content

fix(review): reference extraction checks the disk once per directory, not once per token #750

Closed as not planned

Description

@dan-petty

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_filenames already 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

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.

Activity

  1. added
    type/bug
    scope/review
    priority/p2-medium
    on Sep 30, 2026
  2. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    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_domain and _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.

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

    priority/p2-mediumscope/reviewtype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions