fix(pre-merge): scan every marker occurrence in contains_todo_marker #4

Merged
jwilger merged 9 commits from dogfood/test-review into main 2026-05-01 14:27:44 -07:00
Owner

Summary

  • pre_merge::contains_todo_marker used line.find(marker) which only returns the first occurrence. When that first hit lived inside a longer identifier (failing the word-boundary check), the function gave up on that marker — missing real later occurrences on the same line.
  • Switched to match_indices so every candidate occurrence is boundary-checked.
  • Added two regression tests covering both prefix collisions (TODOmarker, then TODO again) and suffix collisions (suppressFIXME … FIXME).

Test plan

  • cargo test -p ar-review --lib pre_merge (27 passed, including the two new regression tests)
  • cargo clippy -p ar-review --all-targets -- -D warnings
  • cargo fmt --all -- --check
## Summary - `pre_merge::contains_todo_marker` used `line.find(marker)` which only returns the first occurrence. When that first hit lived inside a longer identifier (failing the word-boundary check), the function gave up on that marker — missing real later occurrences on the same line. - Switched to `match_indices` so every candidate occurrence is boundary-checked. - Added two regression tests covering both prefix collisions (`TODOmarker, then TODO again`) and suffix collisions (`suppressFIXME … FIXME`). ## Test plan - [x] `cargo test -p ar-review --lib pre_merge` (27 passed, including the two new regression tests) - [x] `cargo clippy -p ar-review --all-targets -- -D warnings` - [x] `cargo fmt --all -- --check`
fix(pre-merge): scan every marker occurrence in contains_todo_marker
Some checks failed
CI / Nix flake check (pull_request) Failing after 4s
auto_review auto_review failed: LLM error: provider error 400: { "error": { "message": "Invalid schema for response_format 'Review': In context=('properties', 'findings', 'items'), 'required' is required to be supplied and to be an array inclu…
690e78abe1
`find()` only returns the first match, so a real `FIXME` later on
the same line was silently missed when the first hit was inside a
longer identifier (e.g. `suppressFIXME ... FIXME`). Switch to
`match_indices` so each candidate is boundary-checked.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix(prompts): satisfy OpenAI strict-mode response_format schema
Some checks failed
CI / Nix flake check (pull_request) Failing after 3s
f3c5f69340
OpenAI's `response_format: json_schema` runs in strict mode
(openai.rs:180 hardcodes `strict: true`), which rejects any
schema where a property is in `properties` but absent from
`required`. The Review schema violated this on `walkthrough`,
`mermaid`, and `findings.items.line_end`, so every review hit
HTTP 400.

Fix: list every property in `required`. Encode the genuinely
optional `line_end` as a nullable union (`["integer", "null"]`)
— the parser's `Option<u32>` already deserializes JSON null as
`None`, so no Rust-side change is needed.

Add a recursive schema test that walks every object level and
asserts the required-superset-of-properties invariant, so a
future schema edit can't silently regress this again.

Discovered by dogfooding against PR #4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chore: re-fire pull_request webhook with corrected event subscription
Some checks failed
CI / Nix flake check (pull_request) Failing after 4s
auto_review auto_review: 6 notes
1fcef34c18
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR fixes the pre_merge::contains_todo_marker function to correctly scan all occurrences of markers on a line, preventing missed markers due to substring collisions. It also updates the JSON schema to comply with OpenAI's strict mode and adds regression tests to ensure robustness. The changes appear well-tested and safe to merge.

Walkthrough

  • CHANGELOG.md:
    • Added an entry describing the fix for scanning every occurrence of markers in pre_merge::contains_todo_marker.
  • crates/ar-prompts/schemas/review.json:
    • Updated the required fields to include walkthrough and mermaid.
    • Made line_end a nullable type to comply with OpenAI's strict mode.
  • crates/ar-prompts/src/schema.rs:
    • Added a test to ensure the schema satisfies OpenAI's strict mode requirements.
  • crates/ar-review/src/pre_merge.rs:
    • Replaced find with match_indices to check all occurrences of markers.
    • Added regression tests to cover scenarios of prefix and suffix collisions.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR fixes the `pre_merge::contains_todo_marker` function to correctly scan all occurrences of markers on a line, preventing missed markers due to substring collisions. It also updates the JSON schema to comply with OpenAI's strict mode and adds regression tests to ensure robustness. The changes appear well-tested and safe to merge. ## Walkthrough - **CHANGELOG.md**: - Added an entry describing the fix for scanning every occurrence of markers in `pre_merge::contains_todo_marker`. - **crates/ar-prompts/schemas/review.json**: - Updated the `required` fields to include `walkthrough` and `mermaid`. - Made `line_end` a nullable type to comply with OpenAI's strict mode. - **crates/ar-prompts/src/schema.rs**: - Added a test to ensure the schema satisfies OpenAI's strict mode requirements. - **crates/ar-review/src/pre_merge.rs**: - Replaced `find` with `match_indices` to check all occurrences of markers. - Added regression tests to cover scenarios of prefix and suffix collisions. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
Collaborator

💡 Note: Ensure that the changelog entry for the pre_merge::contains_todo_marker fix is clear and concise. Consider adding a brief explanation of why scanning every occurrence is important for clarity.

💡 **Note:** Ensure that the changelog entry for the `pre_merge::contains_todo_marker` fix is clear and concise. Consider adding a brief explanation of why scanning every occurrence is important for clarity.
jwilger marked this conversation as resolved
@ -5,3 +5,3 @@
"additionalProperties": false,
"required": ["summary", "findings"],
"required": ["summary", "walkthrough", "mermaid", "findings"],
"properties": {
Collaborator

💡 Note: The required field now includes walkthrough and mermaid. Ensure that these fields are always provided in the JSON response, even if empty, to maintain compatibility with the schema.

💡 **Note:** The `required` field now includes `walkthrough` and `mermaid`. Ensure that these fields are always provided in the JSON response, even if empty, to maintain compatibility with the schema.
jwilger marked this conversation as resolved
@ -7,3 +6,4 @@
"required": ["summary", "walkthrough", "mermaid", "findings"],
"properties": {
"summary": {
"type": "string",
Collaborator

💡 Note: The line_end property is now nullable. Ensure that any code generating JSON responses adheres to this change to prevent schema validation errors.

💡 **Note:** The `line_end` property is now nullable. Ensure that any code generating JSON responses adheres to this change to prevent schema validation errors.
jwilger marked this conversation as resolved
Collaborator

💡 Note: The new test schema_satisfies_openai_strict_mode_at_every_object_level ensures compliance with OpenAI's strict mode. This is a crucial addition to prevent runtime errors during API interactions.

💡 **Note:** The new test `schema_satisfies_openai_strict_mode_at_every_object_level` ensures compliance with OpenAI's strict mode. This is a crucial addition to prevent runtime errors during API interactions.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Switching from find to match_indices ensures that all occurrences of markers are checked for word boundaries. This change is crucial for correctly identifying markers that might be missed due to substring collisions.

💡 **Note:** Switching from `find` to `match_indices` ensures that all occurrences of markers are checked for word boundaries. This change is crucial for correctly identifying markers that might be missed due to substring collisions.
jwilger marked this conversation as resolved
Collaborator

💡 Note: The new regression tests effectively cover scenarios where markers might be missed due to prefix or suffix collisions. These tests are essential for ensuring the robustness of the contains_todo_marker function.

💡 **Note:** The new regression tests effectively cover scenarios where markers might be missed due to prefix or suffix collisions. These tests are essential for ensuring the robustness of the `contains_todo_marker` function.
jwilger marked this conversation as resolved
fix(review): three OpenAI-strict & Forgejo-API regressions found dogfooding
Some checks failed
auto_review auto_review: 5 notes
CI / Nix flake check (pull_request) Failing after 4s
9547319f96
* Verification schema (crates/ar-prompts/schemas/verification.json):
  `reasoning` was in `properties` but missing from `required`. OpenAI
  strict mode rejects this with HTTP 400, so the verifier failed on
  every review and no findings were filtered. Add to `required`; the
  parser already coerces missing/empty via `#[serde(default)]`.

* Embed input cap (crates/ar-index/src/embed.rs): a single oversized
  symbol (>8192 tokens, ~32 KiB English) failed the whole embed batch
  with HTTP 400, taking the entire RAG pass with it. Truncate each
  per-symbol snippet at 24 KiB at a UTF-8 char boundary before send.

* Forgejo poller URL (crates/ar-forgejo/src/client.rs): `pulls/{n}/comments`
  does not exist in Forgejo (verified against 15.0.0 — the chat poller
  was 404'ing every cycle). Switched to `issues/{n}/comments` which is
  where top-level @-mentions live. Updated all wiremock paths to match.

The strict-mode invariant test in crates/ar-prompts/src/schema.rs now
walks all four response schemas (review, triage, verification,
pre_merge_custom) so a future drift gets caught at `cargo test` not
in production.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR fixes the contains_todo_marker function to correctly scan all occurrences of markers on a line, ensuring accurate detection. It also updates API paths for Forgejo compatibility and improves JSON schema compliance with OpenAI's strict mode. The changes appear well-tested and safe to merge.

Walkthrough

  • pre_merge.rs:
    • Replaced find() with match_indices() to ensure all occurrences of markers are checked for word boundaries, fixing missed detections.
  • client.rs:
    • Corrected API endpoint paths to use /issues/{n}/comments for Forgejo compatibility, preventing 404 errors.
  • embed.rs:
    • Introduced EMBED_INPUT_CAP_BYTES to truncate oversized symbols, preventing HTTP 400 errors during embedding.
  • schemas:
    • Updated JSON schemas to include all properties in required, ensuring compatibility with OpenAI's strict mode and preventing HTTP 400 errors.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR fixes the `contains_todo_marker` function to correctly scan all occurrences of markers on a line, ensuring accurate detection. It also updates API paths for Forgejo compatibility and improves JSON schema compliance with OpenAI's strict mode. The changes appear well-tested and safe to merge. ## Walkthrough - **pre_merge.rs**: - Replaced `find()` with `match_indices()` to ensure all occurrences of markers are checked for word boundaries, fixing missed detections. - **client.rs**: - Corrected API endpoint paths to use `/issues/{n}/comments` for Forgejo compatibility, preventing 404 errors. - **embed.rs**: - Introduced `EMBED_INPUT_CAP_BYTES` to truncate oversized symbols, preventing HTTP 400 errors during embedding. - **schemas**: - Updated JSON schemas to include all properties in `required`, ensuring compatibility with OpenAI's strict mode and preventing HTTP 400 errors. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
@ -316,7 +321,7 @@ impl Client {
let mut all = Vec::new();
Collaborator

💡 Note: The endpoint path has been corrected to use /issues/{n}/comments instead of /pulls/{n}/comments, which does not exist in Forgejo. This change ensures compatibility with Forgejo's API and prevents 404 errors.

💡 **Note:** The endpoint path has been corrected to use `/issues/{n}/comments` instead of `/pulls/{n}/comments`, which does not exist in Forgejo. This change ensures compatibility with Forgejo's API and prevents 404 errors.
jwilger marked this conversation as resolved
@ -58,13 +81,16 @@ pub async fn embed_symbols(
return Ok(Vec::new());
Collaborator

💡 Note: The introduction of EMBED_INPUT_CAP_BYTES and the truncation logic prevents oversized symbols from causing HTTP 400 errors during embedding. This change improves robustness by ensuring that large symbols do not disrupt the entire embedding process.

💡 **Note:** The introduction of `EMBED_INPUT_CAP_BYTES` and the truncation logic prevents oversized symbols from causing HTTP 400 errors during embedding. This change improves robustness by ensuring that large symbols do not disrupt the entire embedding process.
jwilger marked this conversation as resolved
@ -5,3 +5,3 @@
"additionalProperties": false,
"required": ["summary", "findings"],
"required": ["summary", "walkthrough", "mermaid", "findings"],
"properties": {
Collaborator

💡 Note: The required fields in the JSON schema have been updated to include all properties, ensuring compatibility with OpenAI's strict mode. This prevents HTTP 400 errors due to missing required fields in the schema.

💡 **Note:** The `required` fields in the JSON schema have been updated to include all properties, ensuring compatibility with OpenAI's strict mode. This prevents HTTP 400 errors due to missing required fields in the schema.
jwilger marked this conversation as resolved
Collaborator

💡 Note: The required fields in the JSON schema have been updated to include reasoning, ensuring compatibility with OpenAI's strict mode. This prevents HTTP 400 errors due to missing required fields in the schema.

💡 **Note:** The `required` fields in the JSON schema have been updated to include `reasoning`, ensuring compatibility with OpenAI's strict mode. This prevents HTTP 400 errors due to missing required fields in the schema.
jwilger marked this conversation as resolved
Collaborator

💡 Note: The change from find() to match_indices() ensures that all occurrences of markers are checked for word boundaries, fixing the issue where only the first occurrence was considered. This is a crucial fix for accurately detecting markers like TODO or FIXME in lines with multiple occurrences.

💡 **Note:** The change from `find()` to `match_indices()` ensures that all occurrences of markers are checked for word boundaries, fixing the issue where only the first occurrence was considered. This is a crucial fix for accurately detecting markers like `TODO` or `FIXME` in lines with multiple occurrences.
jwilger marked this conversation as resolved
chore: re-trigger review against rebuilt gateway
Some checks failed
CI / Nix flake check (pull_request) Failing after 4s
auto_review auto_review: 5 notes
fb19499289
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR fixes several issues, including ensuring all occurrences of TODO markers are checked, updating API endpoints for Forgejo compatibility, and enforcing schema compliance with OpenAI's strict mode. The changes are well-tested and appear safe to merge.

Walkthrough

  • pre_merge.rs:
    • Replaced find() with match_indices() to ensure all occurrences of markers are checked for word boundaries, fixing missed markers.
    • Added regression tests to cover cases of prefix and suffix collisions.
  • client.rs:
    • Updated API endpoint paths to use issues/{n}/comments instead of pulls/{n}/comments for Forgejo compatibility.
  • embed.rs:
    • Introduced EMBED_INPUT_CAP_BYTES to truncate oversized inputs, preventing HTTP 400 errors from OpenAI.
  • schemas:
    • Updated JSON schemas to comply with OpenAI's strict mode by ensuring all properties are listed in required arrays, preventing HTTP 400 errors.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR fixes several issues, including ensuring all occurrences of TODO markers are checked, updating API endpoints for Forgejo compatibility, and enforcing schema compliance with OpenAI's strict mode. The changes are well-tested and appear safe to merge. ## Walkthrough - **pre_merge.rs**: - Replaced `find()` with `match_indices()` to ensure all occurrences of markers are checked for word boundaries, fixing missed markers. - Added regression tests to cover cases of prefix and suffix collisions. - **client.rs**: - Updated API endpoint paths to use `issues/{n}/comments` instead of `pulls/{n}/comments` for Forgejo compatibility. - **embed.rs**: - Introduced `EMBED_INPUT_CAP_BYTES` to truncate oversized inputs, preventing HTTP 400 errors from OpenAI. - **schemas**: - Updated JSON schemas to comply with OpenAI's strict mode by ensuring all properties are listed in `required` arrays, preventing HTTP 400 errors. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
@ -316,7 +321,7 @@ impl Client {
let mut all = Vec::new();
Collaborator

💡 Note: The change from pulls/{n}/comments to issues/{n}/comments is correct for Forgejo compatibility, as the previous endpoint does not exist and would result in a 404 error.

💡 **Note:** The change from `pulls/{n}/comments` to `issues/{n}/comments` is correct for Forgejo compatibility, as the previous endpoint does not exist and would result in a 404 error.
jwilger marked this conversation as resolved
@ -58,13 +81,16 @@ pub async fn embed_symbols(
return Ok(Vec::new());
Collaborator

💡 Note: The introduction of EMBED_INPUT_CAP_BYTES and truncation logic is a good safeguard against oversized inputs that could cause HTTP 400 errors from OpenAI. This ensures that the RAG pass is not disrupted by a single large symbol.

💡 **Note:** The introduction of `EMBED_INPUT_CAP_BYTES` and truncation logic is a good safeguard against oversized inputs that could cause HTTP 400 errors from OpenAI. This ensures that the RAG pass is not disrupted by a single large symbol.
jwilger marked this conversation as resolved
@ -5,3 +5,3 @@
"additionalProperties": false,
"required": ["summary", "findings"],
"required": ["summary", "walkthrough", "mermaid", "findings"],
"properties": {
Collaborator

💡 Note: Ensure that all required properties are listed in the required array to comply with OpenAI's strict mode. This change prevents HTTP 400 errors during schema validation.

💡 **Note:** Ensure that all required properties are listed in the `required` array to comply with OpenAI's strict mode. This change prevents HTTP 400 errors during schema validation.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Adding reasoning to the required array ensures compliance with OpenAI's strict mode, preventing HTTP 400 errors during schema validation.

💡 **Note:** Adding `reasoning` to the `required` array ensures compliance with OpenAI's strict mode, preventing HTTP 400 errors during schema validation.
jwilger marked this conversation as resolved
@ -184,2 +185,2 @@
if let Some(idx) = line.find(marker) {
let before_ok = idx == 0 || !line.as_bytes()[idx - 1].is_ascii_alphanumeric();
for (idx, _) in line.match_indices(marker) {
let before_ok = idx == 0 || !bytes[idx - 1].is_ascii_alphanumeric();
Collaborator

💡 Note: Switching from find() to match_indices() ensures that all occurrences of markers are checked for word boundaries, fixing the issue where markers could be missed if they appeared after a non-boundary match.

💡 **Note:** Switching from `find()` to `match_indices()` ensures that all occurrences of markers are checked for word boundaries, fixing the issue where markers could be missed if they appeared after a non-boundary match.
jwilger marked this conversation as resolved
Collaborator

Acking all three reviews in one place — every comment was an LGTM-style note confirming the fix in the same commit, so nothing is left to change.

Review 709 (head 690e78a, fix(pre-merge): contains_todo_marker):

  • crates/ar-review/src/pre_merge.rs × 2 — confirmed: find()match_indices() is the bug fix; regression tests cover prefix + suffix collisions.

Review 710 (head f3c5f69, fix(prompts): OpenAI strict-mode review schema):

  • crates/ar-prompts/schemas/review.json × 2 — confirmed: walkthrough/mermaid added to required; line_end is nullable so Option<u32> still deserializes JSON null.
  • crates/ar-prompts/src/schema.rs — confirmed: the recursive walker locks the strict-mode invariant for every object level.
  • CHANGELOG.md — noted; entry is intentionally short since the rationale is in the commit message.
  • crates/ar-review/src/pre_merge.rs × 2 — same as 709.

Review 711 (head fb19499, three regressions found dogfooding):

  • crates/ar-forgejo/src/client.rs — confirmed: pulls/{n}/comments returns 404 on Forgejo 15.0.0; switched to issues/{n}/comments.
  • crates/ar-index/src/embed.rs — confirmed: 24 KiB per-snippet cap stops one oversized symbol from killing the whole RAG pass.
  • crates/ar-prompts/schemas/review.json and verification.json — confirmed: required is now a superset of properties in both, satisfying OpenAI strict mode.
  • crates/ar-review/src/pre_merge.rs — same as 709/710.

Dismissing 709-711 since each is now superseded by HEAD.

Acking all three reviews in one place — every comment was an LGTM-style note confirming the fix in the same commit, so nothing is left to change. **Review 709** (head 690e78a, fix(pre-merge): contains_todo_marker): - `crates/ar-review/src/pre_merge.rs` × 2 — confirmed: `find()` → `match_indices()` is the bug fix; regression tests cover prefix + suffix collisions. **Review 710** (head f3c5f69, fix(prompts): OpenAI strict-mode review schema): - `crates/ar-prompts/schemas/review.json` × 2 — confirmed: `walkthrough`/`mermaid` added to `required`; `line_end` is nullable so `Option<u32>` still deserializes JSON `null`. - `crates/ar-prompts/src/schema.rs` — confirmed: the recursive walker locks the strict-mode invariant for every object level. - `CHANGELOG.md` — noted; entry is intentionally short since the rationale is in the commit message. - `crates/ar-review/src/pre_merge.rs` × 2 — same as 709. **Review 711** (head fb19499, three regressions found dogfooding): - `crates/ar-forgejo/src/client.rs` — confirmed: `pulls/{n}/comments` returns 404 on Forgejo 15.0.0; switched to `issues/{n}/comments`. - `crates/ar-index/src/embed.rs` — confirmed: 24 KiB per-snippet cap stops one oversized symbol from killing the whole RAG pass. - `crates/ar-prompts/schemas/review.json` and `verification.json` — confirmed: `required` is now a superset of `properties` in both, satisfying OpenAI strict mode. - `crates/ar-review/src/pre_merge.rs` — same as 709/710. Dismissing 709-711 since each is now superseded by HEAD.
style: rustfmt fixups for nix flake check
Some checks failed
CI / Nix flake check (pull_request) Failing after 4s
auto_review auto_review: 5 notes
490fe602bd
Local `cargo fmt --all -- --check` passed but `nix flake check`
wraps these to a stricter width. Apply the formatter so the CI
gate is green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR addresses several critical issues, including fixing the contains_todo_marker function to check all occurrences of markers, updating API endpoints for Forgejo compatibility, and ensuring JSON schema compliance with OpenAI's strict mode. The changes appear well-tested and should improve robustness.

Walkthrough

  • pre_merge.rs:
    • The contains_todo_marker function now uses match_indices to ensure all occurrences of markers are checked, fixing a bug where markers could be missed if they were not the first occurrence on a line.
    • Added regression tests to cover scenarios where markers were previously missed.
  • client.rs:
    • Updated the API endpoint from pulls/{n}/comments to issues/{n}/comments to align with Forgejo's API, preventing 404 errors.
  • embed.rs:
    • Introduced a byte cap for embedding inputs to prevent oversized inputs from causing batch failures.
  • schemas:
    • Updated JSON schemas to comply with OpenAI's strict mode by ensuring all properties are listed in required and using nullable types for optional fields.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR addresses several critical issues, including fixing the `contains_todo_marker` function to check all occurrences of markers, updating API endpoints for Forgejo compatibility, and ensuring JSON schema compliance with OpenAI's strict mode. The changes appear well-tested and should improve robustness. ## Walkthrough - **pre_merge.rs**: - The `contains_todo_marker` function now uses `match_indices` to ensure all occurrences of markers are checked, fixing a bug where markers could be missed if they were not the first occurrence on a line. - Added regression tests to cover scenarios where markers were previously missed. - **client.rs**: - Updated the API endpoint from `pulls/{n}/comments` to `issues/{n}/comments` to align with Forgejo's API, preventing 404 errors. - **embed.rs**: - Introduced a byte cap for embedding inputs to prevent oversized inputs from causing batch failures. - **schemas**: - Updated JSON schemas to comply with OpenAI's strict mode by ensuring all properties are listed in `required` and using nullable types for optional fields. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
@ -316,7 +321,7 @@ impl Client {
let mut all = Vec::new();
Collaborator

💡 Note: The change from pulls/{n}/comments to issues/{n}/comments is crucial for compatibility with Forgejo, as the former endpoint does not exist. Ensure that this change is thoroughly tested to prevent any issues with comment retrieval.

💡 **Note:** The change from `pulls/{n}/comments` to `issues/{n}/comments` is crucial for compatibility with Forgejo, as the former endpoint does not exist. Ensure that this change is thoroughly tested to prevent any issues with comment retrieval.
jwilger marked this conversation as resolved
@ -58,13 +81,16 @@ pub async fn embed_symbols(
return Ok(Vec::new());
Collaborator

💡 Note: The introduction of EMBED_INPUT_CAP_BYTES is a good safeguard against oversized inputs causing failures. Ensure that this truncation does not affect the quality of the embeddings significantly.

💡 **Note:** The introduction of `EMBED_INPUT_CAP_BYTES` is a good safeguard against oversized inputs causing failures. Ensure that this truncation does not affect the quality of the embeddings significantly.
jwilger marked this conversation as resolved
@ -35,9 +35,9 @@
"description": "1-based line number in the new file content."
Collaborator

💡 Note: The addition of line_end as a nullable type in the schema ensures compatibility with OpenAI's strict mode. Verify that all other optional fields are similarly handled to prevent API errors.

💡 **Note:** The addition of `line_end` as a nullable type in the schema ensures compatibility with OpenAI's strict mode. Verify that all other optional fields are similarly handled to prevent API errors.
jwilger marked this conversation as resolved
Collaborator

💡 Note: The change to required fields in the verification schema addresses a critical issue with API compatibility. Ensure that all necessary fields are included to avoid HTTP 400 errors.

💡 **Note:** The change to `required` fields in the verification schema addresses a critical issue with API compatibility. Ensure that all necessary fields are included to avoid HTTP 400 errors.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Switching from find to match_indices ensures that all occurrences of markers are checked for word boundaries, fixing the issue where markers could be missed. This change should be validated with comprehensive tests to ensure no regressions.

💡 **Note:** Switching from `find` to `match_indices` ensures that all occurrences of markers are checked for word boundaries, fixing the issue where markers could be missed. This change should be validated with comprehensive tests to ensure no regressions.
jwilger marked this conversation as resolved
fix(ci): export PATH inline so nix flake check finds nix
Some checks failed
CI / Nix flake check (pull_request) Failing after 4s
auto_review auto_review: 4 notes
9867e84f61
Six consecutive runs (#15–#20) failed in 2s on the "Run all checks"
step despite "Install or reuse Nix" succeeding. The previous step
appended NIX_BIN_DIR to $GITHUB_PATH, but the act_runner version on
this Forgejo instance appears not to honour that propagation
between steps, so the next shell saw `nix` off-PATH and exited fast
with no recorded log.

Set PATH inline at the start of the step so the gate doesn't rely
on cross-step env propagation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR addresses a bug in pre_merge::contains_todo_marker by ensuring all occurrences of markers are checked, not just the first. It also updates API endpoints to align with Forgejo's structure, preventing errors. The changes are well-tested and documented, making the PR safe to merge.

Walkthrough

  • .forgejo/workflows/ci.yml:

    • Added an inline PATH setting to ensure nix is available, addressing potential issues with GITHUB_PATH propagation.
  • CHANGELOG.md:

    • Updated to reflect the fix in contains_todo_marker and other improvements, providing clear documentation of changes.
  • crates/ar-forgejo/src/client.rs:

    • Changed API endpoint paths to match Forgejo's structure, preventing 404 errors.
  • crates/ar-review/src/pre_merge.rs:

    • Replaced find with match_indices to ensure all marker occurrences are checked, fixing the bug where markers could be missed.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR addresses a bug in `pre_merge::contains_todo_marker` by ensuring all occurrences of markers are checked, not just the first. It also updates API endpoints to align with Forgejo's structure, preventing errors. The changes are well-tested and documented, making the PR safe to merge. ## Walkthrough - **.forgejo/workflows/ci.yml**: - Added an inline PATH setting to ensure `nix` is available, addressing potential issues with GITHUB_PATH propagation. - **CHANGELOG.md**: - Updated to reflect the fix in `contains_todo_marker` and other improvements, providing clear documentation of changes. - **crates/ar-forgejo/src/client.rs**: - Changed API endpoint paths to match Forgejo's structure, preventing 404 errors. - **crates/ar-review/src/pre_merge.rs**: - Replaced `find` with `match_indices` to ensure all marker occurrences are checked, fixing the bug where markers could be missed. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
Collaborator

💡 Note: Lines 4–11: The inline PATH setting is a good defensive measure against potential issues with GITHUB_PATH propagation. This change ensures that the nix command is available in this step, improving robustness.

💡 **Note:** **Lines 4–11:** The inline PATH setting is a good defensive measure against potential issues with GITHUB_PATH propagation. This change ensures that the `nix` command is available in this step, improving robustness.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 6–35: The changelog entry accurately describes the fix for scanning every occurrence of markers in contains_todo_marker. This provides clarity on the issue and the solution implemented.

💡 **Note:** **Lines 6–35:** The changelog entry accurately describes the fix for scanning every occurrence of markers in `contains_todo_marker`. This provides clarity on the issue and the solution implemented.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 6–11: Switching the endpoint from /pulls/{n}/comments to /issues/{n}/comments aligns with Forgejo's API structure, preventing 404 errors and ensuring the correct retrieval of comments.

💡 **Note:** **Lines 6–11:** Switching the endpoint from `/pulls/{n}/comments` to `/issues/{n}/comments` aligns with Forgejo's API structure, preventing 404 errors and ensuring the correct retrieval of comments.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 6–11: The change to use match_indices instead of find ensures that all occurrences of markers are checked for word boundaries, fixing the issue where markers could be missed if they were not the first occurrence on a line.

💡 **Note:** **Lines 6–11:** The change to use `match_indices` instead of `find` ensures that all occurrences of markers are checked for word boundaries, fixing the issue where markers could be missed if they were not the first occurrence on a line.
jwilger marked this conversation as resolved
ci(debug): surface nix presence/version before flake check
Some checks failed
CI / Nix flake check (pull_request) Failing after 4s
auto_review auto_review: 9 notes
aa3bb99f0f
Previous PATH-fix didn't change the 2s failure, so nix is on PATH
but failing immediately. Add diagnostic output (set -x, which nix,
nix --version, /nix/store sample) to capture what's wrong before
nix flake check even starts.

Will revert once we have signal.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR addresses a critical bug in pre_merge::contains_todo_marker by ensuring all occurrences of markers are checked, not just the first. It also updates several schemas for stricter validation and fixes API endpoint paths for Forgejo compatibility. The changes are well-tested and appear safe to merge.

Walkthrough

  • CI Workflow: Added debug commands to diagnose Nix environment issues. Ensure these are removed if not needed.
  • CHANGELOG: Updated to reflect the fix for scanning all marker occurrences.
  • Forgejo Client: Corrected API endpoint paths to align with Forgejo's structure.
  • Embedding Logic: Introduced a byte cap for input truncation to prevent oversized inputs from failing the batch.
  • JSON Schemas: Updated schemas to comply with OpenAI's strict mode, ensuring all properties are listed in required fields.
  • Tests: Added comprehensive tests for the new logic and schema compliance, ensuring robustness and preventing regressions.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR addresses a critical bug in `pre_merge::contains_todo_marker` by ensuring all occurrences of markers are checked, not just the first. It also updates several schemas for stricter validation and fixes API endpoint paths for Forgejo compatibility. The changes are well-tested and appear safe to merge. ## Walkthrough - **CI Workflow**: Added debug commands to diagnose Nix environment issues. Ensure these are removed if not needed. - **CHANGELOG**: Updated to reflect the fix for scanning all marker occurrences. - **Forgejo Client**: Corrected API endpoint paths to align with Forgejo's structure. - **Embedding Logic**: Introduced a byte cap for input truncation to prevent oversized inputs from failing the batch. - **JSON Schemas**: Updated schemas to comply with OpenAI's strict mode, ensuring all properties are listed in `required` fields. - **Tests**: Added comprehensive tests for the new logic and schema compliance, ensuring robustness and preventing regressions. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
Collaborator

💡 Note: Lines 4–11: The added debug commands in the CI workflow are useful for diagnosing issues with the Nix environment. Ensure these are removed or commented out before merging if they are not intended for production use.

💡 **Note:** **Lines 4–11:** The added debug commands in the CI workflow are useful for diagnosing issues with the Nix environment. Ensure these are removed or commented out before merging if they are not intended for production use.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 6–35: The changelog entry accurately describes the fix for scanning all occurrences of markers. Ensure this entry is updated if further changes are made to the implementation.

💡 **Note:** **Lines 6–35:** The changelog entry accurately describes the fix for scanning all occurrences of markers. Ensure this entry is updated if further changes are made to the implementation.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 7–11: The change from pulls/{n}/comments to issues/{n}/comments aligns with Forgejo's API structure. Ensure this change is tested against the latest Forgejo version to confirm compatibility.

💡 **Note:** **Lines 7–11:** The change from `pulls/{n}/comments` to `issues/{n}/comments` aligns with Forgejo's API structure. Ensure this change is tested against the latest Forgejo version to confirm compatibility.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 6–29: The introduction of EMBED_INPUT_CAP_BYTES and the truncation logic is a good safeguard against oversized inputs. Ensure this limit is appropriate for all expected use cases.

💡 **Note:** **Lines 6–29:** The introduction of `EMBED_INPUT_CAP_BYTES` and the truncation logic is a good safeguard against oversized inputs. Ensure this limit is appropriate for all expected use cases.
jwilger marked this conversation as resolved
@ -41,6 +41,29 @@ pub enum EmbedError {
/// for not failing the whole RAG pass.
pub const EMBED_BATCH_SIZE: usize = 32;
/// Per-input byte cap. OpenAI's `text-embedding-3-*` rejects any
Collaborator

💡 Note: Lines 44–53: The test oversized_symbol_snippet_is_truncated_before_embed_call effectively verifies the truncation logic. Consider adding edge cases with symbols just below and above the limit to ensure robustness.

💡 **Note:** **Lines 44–53:** The test `oversized_symbol_snippet_is_truncated_before_embed_call` effectively verifies the truncation logic. Consider adding edge cases with symbols just below and above the limit to ensure robustness.
jwilger marked this conversation as resolved
@ -3,7 +3,7 @@
"title": "Review",
Collaborator

💡 Note: Lines 3–7: The addition of walkthrough, mermaid, and line_end to the required fields in the JSON schema ensures stricter validation. Verify that all existing JSON data adheres to this updated schema.

💡 **Note:** **Lines 3–7:** The addition of `walkthrough`, `mermaid`, and `line_end` to the `required` fields in the JSON schema ensures stricter validation. Verify that all existing JSON data adheres to this updated schema.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 3–7: Adding reasoning to the required fields in the verification schema ensures compliance with OpenAI's strict mode. Ensure that all verification logic provides this field to avoid errors.

💡 **Note:** **Lines 3–7:** Adding `reasoning` to the `required` fields in the verification schema ensures compliance with OpenAI's strict mode. Ensure that all verification logic provides this field to avoid errors.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 4–53: The test every_response_schema_satisfies_openai_strict_mode is a comprehensive check for schema compliance. Ensure this test is run regularly to catch any future schema drift.

💡 **Note:** **Lines 4–53:** The test `every_response_schema_satisfies_openai_strict_mode` is a comprehensive check for schema compliance. Ensure this test is run regularly to catch any future schema drift.
jwilger marked this conversation as resolved
Collaborator

💡 Note: Lines 8–12: Switching from find to match_indices in contains_todo_marker ensures all occurrences are checked. This change is well-tested by the added regression tests.

💡 **Note:** **Lines 8–12:** Switching from `find` to `match_indices` in `contains_todo_marker` ensures all occurrences are checked. This change is well-tested by the added regression tests.
jwilger marked this conversation as resolved
fix(ci): recreate nixbld group/users on every container start
All checks were successful
auto_review auto_review: 2 warnings, 4 notes
CI / Nix flake check (pull_request) Successful in 1m43s
1d197a5e10
The persistent /nix volume survives between runs, but each runner
container starts with a fresh /etc/{group,passwd}. The Determinate
Systems installer creates `nixbld` group + 32 build users on first
install; on subsequent runs only /nix is reused, leaving nix.conf
pointing at a non-existent group. Result:

    error: the group 'nixbld' specified in 'build-users-group'
           does not exist

— failing the step in 2 seconds with no useful output unless you
chase the runner's per-attempt log.

Recreate the group and users idempotently after the install/reuse
check. Drop the diagnostic shimmery from the previous commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
auto-review left a comment

This PR fixes the contains_todo_marker function to correctly scan all occurrences of markers on a line, preventing missed markers due to substring collisions. It also updates several schemas to comply with OpenAI's strict mode and adjusts API endpoints for Forgejo compatibility. The changes are well-tested and appear safe to merge.

Walkthrough

  • ci.yml:
    • Added logic to recreate nixbld users if missing, ensuring nix flake check runs without errors.
    • Updated PATH for nix flake check.
  • CHANGELOG.md:
    • Documented fixes and improvements, including schema updates and API endpoint corrections.
  • client.rs:
    • Changed API endpoint from /pulls/{n}/comments to /issues/{n}/comments for Forgejo compatibility.
  • embed.rs:
    • Introduced truncate_at_char_boundary to handle oversized input for embedding, preventing batch failures.
  • schemas:
    • Updated review.json and verification.json to comply with OpenAI's strict mode by listing all properties in required.
  • pre_merge.rs:
    • Replaced find() with match_indices() to ensure all marker occurrences are checked, fixing a critical bug.

Pre-merge checks

  • CHANGELOG updated — CHANGELOG.md is in the diff
  • Tests touched — source changed but no test file appears in the diff
  • No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
This PR fixes the `contains_todo_marker` function to correctly scan all occurrences of markers on a line, preventing missed markers due to substring collisions. It also updates several schemas to comply with OpenAI's strict mode and adjusts API endpoints for Forgejo compatibility. The changes are well-tested and appear safe to merge. ## Walkthrough - **ci.yml**: - Added logic to recreate `nixbld` users if missing, ensuring `nix flake check` runs without errors. - Updated `PATH` for `nix flake check`. - **CHANGELOG.md**: - Documented fixes and improvements, including schema updates and API endpoint corrections. - **client.rs**: - Changed API endpoint from `/pulls/{n}/comments` to `/issues/{n}/comments` for Forgejo compatibility. - **embed.rs**: - Introduced `truncate_at_char_boundary` to handle oversized input for embedding, preventing batch failures. - **schemas**: - Updated `review.json` and `verification.json` to comply with OpenAI's strict mode by listing all properties in `required`. - **pre_merge.rs**: - Replaced `find()` with `match_indices()` to ensure all marker occurrences are checked, fixing a critical bug. ## Pre-merge checks - [x] CHANGELOG updated — CHANGELOG.md is in the diff - [ ] Tests touched — source changed but no test file appears in the diff - [ ] No new TODO/FIXME comments — 6 new TODO/FIXME markers in the diff
@ -316,7 +321,7 @@ impl Client {
let mut all = Vec::new();
Collaborator

💡 Note: The comment accurately describes the change in endpoint from /pulls/{n}/comments to /issues/{n}/comments. Ensure that this change is compatible with all intended Forgejo versions.

💡 **Note:** The comment accurately describes the change in endpoint from `/pulls/{n}/comments` to `/issues/{n}/comments`. Ensure that this change is compatible with all intended Forgejo versions.
jwilger marked this conversation as resolved
@ -58,13 +81,16 @@ pub async fn embed_symbols(
return Ok(Vec::new());
Collaborator

💡 Note: The truncate_at_char_boundary function is a good addition to prevent oversized input errors. Ensure that truncating at 24 KiB is sufficient for your use case and doesn't omit critical information.

💡 **Note:** The `truncate_at_char_boundary` function is a good addition to prevent oversized input errors. Ensure that truncating at 24 KiB is sufficient for your use case and doesn't omit critical information.
jwilger marked this conversation as resolved
@ -243,6 +269,35 @@ mod tests {
assert!(matches!(err, EmbedError::MissingFile(p) if p == "does/not/exist.rs"));
Collaborator

💡 Note: The test oversized_symbol_snippet_is_truncated_before_embed_call effectively checks for oversized input handling. Consider adding more edge cases to ensure robustness.

💡 **Note:** The test `oversized_symbol_snippet_is_truncated_before_embed_call` effectively checks for oversized input handling. Consider adding more edge cases to ensure robustness.
jwilger marked this conversation as resolved
@ -5,3 +5,3 @@
"additionalProperties": false,
"required": ["summary", "findings"],
"required": ["summary", "walkthrough", "mermaid", "findings"],
"properties": {
Collaborator

🟡 Warning: The addition of walkthrough and mermaid to the required list in the schema might cause issues if these fields are not always provided. Ensure that all code paths provide these fields or handle their absence gracefully.

🟡 **Warning:** The addition of `walkthrough` and `mermaid` to the `required` list in the schema might cause issues if these fields are not always provided. Ensure that all code paths provide these fields or handle their absence gracefully.
jwilger marked this conversation as resolved
Collaborator

🟡 Warning: Adding reasoning to the required list in the verification schema is a breaking change. Ensure that all clients provide this field to avoid runtime errors.

🟡 **Warning:** Adding `reasoning` to the `required` list in the verification schema is a breaking change. Ensure that all clients provide this field to avoid runtime errors.
jwilger marked this conversation as resolved
Collaborator

💡 Note: The switch from find() to match_indices() ensures all occurrences of markers are checked. This is a crucial fix for detecting all TODO markers correctly.

💡 **Note:** The switch from `find()` to `match_indices()` ensures all occurrences of markers are checked. This is a crucial fix for detecting all TODO markers correctly.
jwilger marked this conversation as resolved
jwilger deleted branch dogfood/test-review 2026-05-01 14:27:44 -07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jwilger/auto_review!4
No description provided.