Repository navigation
chore: run detection as the first step of the Rewrite invocation - #346
Merged
binaryaaron merged 3 commits intoOct 30, 2026
Conversation
The detect operation, its position resolution, accepted-mention extraction and missing-text check move out of the Replace route as module-level names so the Rewrite invocation can share them. The Replace route imports them and behaves as before. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
RewriteWorkflow and CombinedRewriteWorkflow gain run_with_detection: one graph invocation with the detect step first, then rewrite and assess-final over every input row. The entity split moves inside rewrite, which reads the detection frame; rows without entities take the passthrough default entry. Results the detector cannot tie to input rows fail at detect and are rewritten by the stock run over the detection frame. RewriteResult carries the detection and its elapsed time so the facade's log block is unchanged. The facade calls run_with_detection unless the runner overrides run(), in which case it keeps detect() followed by that run(). Interface tests that stub the Rewrite runners now stub run_with_detection through the shared helper. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
…in SP-16 Adds E16.14-E16.18: failure ordering when detection and rewrite both drop rows, failure ordering on the reroute path, resolve_positions text verification, source positions covering rows without entities, and the combined workflow's measurement stage name. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aaron Gonzales <aagonzales@nvidia.com>
This was referenced Oct 29, 2026
binaryaaron
changed the base branch from
aagonzales/chore/graph-sdk-rewrite-lowered
to
aagonzales/graph-sdk/feat/main
October 30, 2026 16:04
binaryaaron
deleted the
aagonzales/chore/graph-sdk-rewrite-detect-step
branch
October 30, 2026 16:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Rewrite mode, detection is now the first step of the same graph invocation as the rewrite. One
protect()call runsdetect, thenrewriteandassess-final, over every input row. The Replace route and the Rewrite runners share one detect step. Output columns, row sets and DataDesigner calls match the base, andanonymizer.graph.__all__is unchanged.This branch stacks on the Rewrite per-target operation PR (#345) and lands on #319's branch by fast-forward after it, without rewriting history.
What changes
Shared detect step (
engine/detection/detect_step.py). Thedetectoperation moves out ofengine/replace/route.py, together with position resolution, accepted-mention extraction and the missing-text check. They become module-level names inengine/detection, and the Replace route imports them and behaves as before.run_with_detectionon both Rewrite runners.RewriteWorkflowandCombinedRewriteWorkflowbuild one target per input row and rundetectfirst. The split on detected entities now happens inside therewritestep:run(staged or combined);detectand is absent from the output, as before;detect, and the stockrunrewrites the detection frame as returned.RewriteResultcarries the detection result and its elapsed time, so the run log is unchanged.Facade. The Rewrite branch of
Anonymizer.runandpreviewcallsrun_with_detectionwhen the runner'srunis the stock one. A runner that overridesrunkeeps detection followed by thatrun, as the Replace branch does. The "Running rewrite pipeline" log line now comes after detection.Tests and docs. The shared
stub_run_with_detectionhelper now covers the Rewrite runners. The interface tests that stub a Rewrite runner stubrun_with_detectionthrough it, and no assertion changed.AGENTS.mdanddocs/concepts/graph-sdk.mddescribe detection as the first step of the Rewrite invocation.Spec program SP-16, five new checks (E16.14-E16.18):
failed_records, on the direct path and on the fallback;source_positionsinclude rows without entities;evaluate(), the judges, the kernel and the DataDesigner column configs are unchanged.Net non-blank, non-comment, non-docstring code lines under
src/: +169 (detect_step.py+66,route.py−44,rewrite_workflow.py+102,combined_rewrite_workflow.py+31,anonymizer.py+14).Known differences
"error". The Replace route already behaves this way.preview_num_recordsset, input rows past the limit fail atdetectin the graph record and do not appear infailed_records. Output andfailed_recordsare as before.Checks
make checkpasses.make test: 1,593 passed, withtest_wandb_snapshot_rejects_fifo_socket_and_devicedeselected as on the base.uv run --group dev python -m tests.spec_programs.run_all: 102 pass, 8 retired, 0 fail.protect()call when the detector reports positions, and two when an unresolvable result takes the fallback.runafter detection) and the new one gave identical output frames, failed records and source positions in each of these cases:f294dc1e) on pandas 2 and 3, over all cases: no blocking difference. Against the base branch, case by case: no blocking difference. The only informational differences are trace-column order, at the level main shows against itself.🤖 Generated with Claude Code