Skip to content

AI jobs B and C: packets, voting, cache, simulation wiring (codexray judge) #8

Done

Description

@Pranav-Mathad

Owner: Pranav · Priority: P1 · Blocked by: #5, #19, #23, #24, #25

Parallel work: Parallel with #7, #9, #10.

1. Goal

Write checked AI text for the findings the report will show (job B) and two-sentence module descriptions (job C), simulate fixes, and keep the report complete when every AI call fails (spec §8).

2. Scope & File Boundaries

Create or edit

  • src/codexray/judge/__init__.py, new packet.py, jobs.py, prompts.py
  • src/codexray/settings/judge.yaml
  • New tests/judge/test_packet.py, test_jobs.py; remove the judge line from STUBS

Do not touch

3. Contracts / Inputs & Outputs

Reads: candidate_findings, nodes, edges, blob contents. Writes: judgements/ (cache files from #24 plus one Judgement per judged finding), usage.json, simulation_batch.json, module descriptions.

from codexray.judge.types import Packet, Slice                       # #23
from codexray.judge.checks import check_response, CheckFailure       # #23
from codexray.judge.client import Gateway                            # #24
from codexray.judge.simulation import simulate_move, simulate_remove_link, simulate_batch   # #25
from codexray.report.ranking import rank                             # #19, to know which findings are shown

Packet (spec §8.2): about 5,000 tokens, facts first, 2 to 4 numbered code slices, at most about 250 lines, never a whole file over 300 lines. Repository text is data; the system instruction says so. Output schema: spec §8.3.

4. Implementation Steps

  1. packet.py: build a Packet per finding from facts, neighbourhood, history and slices (file outline, offending lines with 5 either side, imported declaration).
  2. jobs.py: job B with 3 votes per shown finding; verdict by majority; claim and fix from the majority sample passing the most checks; one retry with the failing check's message; a second failure stores insufficient_evidence and the template. Each finding is judged alone.
  3. Simulation: for move_symbol and link-removing fixes call Module: fix simulation on a copy of the map (judge/simulation.py) #25 with the module link matrix; then the batch of all cheap-loop fixes in finding-id order.
  4. Job C per module; re-run only when its evidence changes.
  5. No sampling settings, no prefill, no forced tool choice (spec §8.8). The shared instruction prefix stays above 512 tokens so it caches.

5. Acceptance Criteria & Verification

  • uv run pytest tests/judge -q passes with a fake transport, including: a response whose number is not a fact is rejected; a prompt-injection comment in a slice does not change the verdict path; with the transport failing, every finding still gets a template judgement.
  • A second codexray judge makes zero network calls (all cache hits) and leaves the outputs byte-identical.
  • On Artemis: about 20-25 judged findings, three calls each; total cost in usage.json is a few dollars.

Branch: pranav/8-ai-jobs-b-and-c. Open a pull request whose description says Closes #8. The specification is spec.md; the working rules are in AGENTS.md and CONTRIBUTING.md.

Activity

  1. added
    owner:pranav
    P1
    on Nov 28, 2026
  2. added
    owner:aryan
    and removed
    owner:pranav
    on Nov 28, 2026
  3. Pranav-Mathad commented on Nov 28, 2026

    @Pranav-Mathad
    OwnerAuthor

    Handing this one to Aryan: it wires together judge/types.py, checks.py, client.py and simulation.py. The "Do not touch" list above no longer applies to those files for you.

    Where things stand:

    • Findings to judge: candidate_findings comes from Stage 5: decisions, decision checks and structural findings (codexray analyze) #5 (yours). Until it produces rows, the two synthetic bundles in web/public/bundles/ have findings of all seven types with evidence and code files (fixture-wide has 11).
    • Contracts already in main (Settle the web bundle contract, fixtures and screen seams #48): Simulation.cell_changes and BatchSimulation.cell_changes (list of CellChange { src, dst, before, after }) are what the grid's "Try the fix" reads; NodeDescription { node_id, text, source } is where job C's text goes in map.json; UsageRow is the per-job ledger row in report.json.
    • Blob contents for the code slices: read them from the bare clone in repos/<repo_id> through codexray.repository.git.cat_file, by the blob_sha on the evidence record.
    • Tests: TEAM_RULES.md rule 3 replaces the test files listed above. Run it with a fake transport, then for real on one repository, then a second time to show zero network calls and identical output; put what came out in the PR. Do remove the judge line from STUBS.

    #6 (report and bundle) picks up judgements/, usage.json and simulation_batch.json if they are present, so the report stays complete without this.

  4. Pranav-Mathad commented on Nov 28, 2026

    @Pranav-Mathad
    OwnerAuthor

    PR #68 (closes #10) adds what the pull-request-goal label needs from Stage 1, for when job B is in:

    • prs is now filled by codexray ingest for the commits in structural_events (title, description, linked issues, review count, checks, AI footer), cached in pr-cache/ in the run folder. Artemis: 37 asked for, 37 stored. Set the token named in settings/repository.yaml (prs.token_env) on the ingest, otherwise the table is empty and the manifest says how many are missing.
    • report/before_after.py builds the labelled changes in before_after.json. It tries the bases of spec §12.3 in order and skips the fourth (pr_goal, source="ai"); the place to add it is the held mapping passed to add(...), after decision_document. Changes with a commit carry it as evidence of kind commits, so the pull request is commits.pr_number of that commit.
    • A report limit currently says the pull-request goal is not evaluated; it should go when the basis is wired.

    One thing seen in prs.py while checking rows: a pull request whose head commit lists no check runs gets checks = 'none', which is every Artemis pull request stored before #12699, so for those the field does not mean the checks passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1owner:aryan

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions