Problem
NPUCodeSearchAgent writes — index_codebase rebuilds a Redis-backed code
index — and under #15950 every write-capable agent must declare the scopes its
run will touch, so a second agent indexing the same tree is refused rather than
racing it.
It cannot. autobot-backend/agents/npu_code_search_agent.py is 1455 lines and
its recorded ceiling is 1455. A declared_scopes override needs roughly ten
lines, and the file-size ratchet refuses all of them:
npu_code_search_agent.py: 1479 lines, over its recorded ceiling of 1455.
A grandfathered file may not grow (#14236) — the exemption freezes the size it
was granted for, it does not license more.
The ratchet is right. This issue is the extraction that makes room.
What the declaration should be, once there is room
Written out here because it was designed and verified before being reverted, and
the reasoning should not have to be rediscovered:
def declared_scopes(self, request: AgentRequest) -> List[str]:
if request.action != "index_directory":
return []
directory = (request.payload or {}).get("directory")
if not directory:
return []
digest = hashlib.md5(str(directory).encode(), usedforsecurity=False).hexdigest()[:16]
return [f"project:code-index-{digest}"]
Two properties that matter and are easy to lose:
Only index_directory declares. search_code and get_capabilities are
reads; a read taking an exclusive claim would serialise every search behind one
indexer.
The scope is a hash of the directory, never the directory. A raw path would
put an internal filesystem location into the claim table and into the
work_claim_acquired events #15949 publishes, which reach an operator's browser
— against the "nothing internal in outward artifacts" rule. The hash still
collides for two runs indexing the same tree, which is the only collision that
matters, and the agent already keys its own Redis index by
md5(root_path) in _get_index_key, so the two agree by construction rather
than by coincidence.
Extraction candidates
Not yet chosen — the file needs reading before a cohesive unit is picked, and
picking an arbitrary N lines to get under a number is the failure mode
RATCHET_BASELINES.md warns about. _get_language_patterns (a large static
table of per-language regexes) looks like the same shape as the
blue_green.py → purge_playbook.py and base_agent.py →
base_agent_types.py extractions, but that is an impression from a grep, not a
verdict from reading it.
Acceptance criteria
Notes
Blocking nothing today — the agent's writes are unclaimed exactly as they were
before #15950, so this is a gap in coverage, not a regression. It is recorded in
the guard as a named exemption rather than left silent.
Problem
NPUCodeSearchAgentwrites —index_codebaserebuilds a Redis-backed codeindex — and under #15950 every write-capable agent must declare the scopes its
run will touch, so a second agent indexing the same tree is refused rather than
racing it.
It cannot.
autobot-backend/agents/npu_code_search_agent.pyis 1455 lines andits recorded ceiling is 1455. A
declared_scopesoverride needs roughly tenlines, and the file-size ratchet refuses all of them:
The ratchet is right. This issue is the extraction that makes room.
What the declaration should be, once there is room
Written out here because it was designed and verified before being reverted, and
the reasoning should not have to be rediscovered:
Two properties that matter and are easy to lose:
Only
index_directorydeclares.search_codeandget_capabilitiesarereads; a read taking an exclusive claim would serialise every search behind one
indexer.
The scope is a hash of the directory, never the directory. A raw path would
put an internal filesystem location into the claim table and into the
work_claim_acquiredevents #15949 publishes, which reach an operator's browser— against the "nothing internal in outward artifacts" rule. The hash still
collides for two runs indexing the same tree, which is the only collision that
matters, and the agent already keys its own Redis index by
md5(root_path)in_get_index_key, so the two agree by construction ratherthan by coincidence.
Extraction candidates
Not yet chosen — the file needs reading before a cohesive unit is picked, and
picking an arbitrary N lines to get under a number is the failure mode
RATCHET_BASELINES.mdwarns about._get_language_patterns(a large statictable of per-language regexes) looks like the same shape as the
blue_green.py→purge_playbook.pyandbase_agent.py→base_agent_types.pyextractions, but that is an impression from a grep, not averdict from reading it.
Acceptance criteria
npu_code_search_agent.py, leaving the file under its ceiling withheadroom — not at it
this the same code in a different file"
600-line limit) in both
scripts/python_file_size_known_large.pyandrepo_tests/python_file_size_ratchet_baseline.pyNPUCodeSearchAgent.declared_scopesis implemented as above, with a testasserting
index_directorydeclares andsearch_codedeclares nothingsubstring of the input directory — the leak this design avoids is the
one a later "make the claim table readable" change would reintroduce
_CEILING_BLOCKEDentry inautobot-backend/tests/agents/test_declared_scopes_guard.pyis deleted;that guard already fails if the entry outlives its reason
Notes
Blocking nothing today — the agent's writes are unclaimed exactly as they were
before #15950, so this is a gap in coverage, not a regression. It is recorded in
the guard as a named exemption rather than left silent.