Repository navigation
feat(report) + refactor(detector): Slices 2-4 of engineering doctrine cycle (RCA + single-pass + 0.574x baseline) - #236
Merged
Conversation
Surface a Sysinternals-style RCA block on stderr when 'data-boar-report' fails so an operator can tell which step of the regen pipeline broke without paging the maintainer for a traceback. Pipeline steps named explicitly: load_config, open_sqlite, fetch_findings, build_manifest, render_markdown, write_output. Each step maps to a narrowed hypothesis (config schema, sqlite path, sandbox guard, write permission) plus the smallest deterministic command an operator can paste to reproduce the failure on the same SQLite. Stdout stays reserved for stakeholder Markdown so piped captures are never poisoned; optional --debug-traceback appends the full traceback for lab use. No customer database is touched - the regen path is read-only against the local SQLite, per docs/ops/inspirations/DEFENSIVE_SCANNING_MANIFESTO.md section 1. Diagnostic shape follows docs/ops/inspirations/INTERNAL_DIAGNOSTIC_AESTHETICS.md sections 2.2-3 (short, factual, no invented numbers, one concept per line). tests/test_cli_reporter_rca.py pins the contract: missing config returns exit code 3 with the labelled RCA on stderr only, debug flag appends the traceback, and harmless inputs still return zero so the RCA path stays reserved for real failures. Co-authored-by: Fabio Tavares Leitão <[email protected]>
…opy (Slice 3)
Address the algorithmic side of the recorded 0.574x latency baseline in
the Pro Python fallback path (tests/benchmarks/official_benchmark_200k.json):
the previous shape walked each chunk twice and held three intermediate
collections in memory at the same time. The fused single-pass shape
preserves the exact acceptance contract (CPF regex, email regex, Luhn
card validator) so the precision invariant promised in the doctrine
manifestos is unchanged.
pro/worker_logic.py::basic_python_scan
- was: OpenCorePreFilter().filter_candidates(payloads) -> list,
list(candidates) copy, set(candidates) hash set, then a second
loop over the full payload list with membership probing for the
Luhn check.
- now: a single list comprehension over payloads with hoisted
bound-method references, evaluating CPF or email or Luhn-valid
card via short-circuit 'or'. No regex was widened or narrowed.
Empty / falsy rows are skipped explicitly to save three regex
calls per empty cell (sparse customer columns are common).
pro/engine.py::process_chunk_worker
- was: always materialized data_batch = [str(item) for item in chunk],
even when the orchestrator already produced list[str] (the hot
path documented in ProOrchestrator._row_to_payload).
- now: O(1) probe (isinstance(chunk, list) and isinstance(chunk[0], str))
reuses the input directly on the hot path; tuples, generators,
and mixed-type inputs still get the defensive str-coercion copy
so the downstream contract is unchanged.
tests/test_basic_python_scan_single_pass_parity.py pins the parity:
OpenCore-accepted CPF/email rows must remain a strict subset of the new
output, Luhn-valid cards must still be admitted while invalid cards must
not, rows hitting multiple predicates must appear at most once per input
(no de-duplication regression), and a 5_000-row clean corpus must yield
zero survivors.
Safety rail explicitly respected per Slack mission brief: no sample
caps, statement timeouts, isolation, or precision logic were changed.
The 200k JSON evidence artifact is left untouched so the operator's
next lab run can measure the algorithmic delta against the recorded
baseline. Doctrine references inline:
docs/ops/inspirations/DEFENSIVE_SCANNING_MANIFESTO.md sections 1-2,
docs/ops/inspirations/THE_ART_OF_THE_FALLBACK.md section 2,
docs/ops/inspirations/INTERNAL_DIAGNOSTIC_AESTHETICS.md section 3.
Co-authored-by: Fabio Tavares Leitão <[email protected]>
…ne (Slice 4)
Update governance docs after the Slice 2 (RCA) and Slice 3 (single-pass
fallback) commits land:
docs/plans/PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md
- Status line: Slices 1-3 complete on main; Slice 4 in flight.
- Sequential to-do table: rows 9-11 marked done with file pointers
(cli/reporter.py + tests/test_cli_reporter_rca.py for the RCA block,
pro/worker_logic.py + pro/engine.py + the parity test for the
single-pass refactor); row 12 in progress in this commit window.
docs/plans/BENCHMARK_EVOLUTION.md
- New section 8 'Pro path - current technical debt baseline'
explains the recorded speedup_vs_opencore = 0.574 from
tests/benchmarks/official_benchmark_200k.json in plain English:
Pro is ~1.74x slower than OpenCore in this profile because the
lab host runs the Python fallback (no Rust extension yet). Names
the precision invariant pro_hits == opencore_hits (Luhn + CPF +
email parity) and the test that fails first if it is ever lost
(test_benchmark_findings_parity).
- Header Status block: lists which slices are doc-only vs code,
points to the two parity test files.
- Revision log: 2026-04-27 row that summarizes the cycle.
docs/plans/PLANS_TODO.md
- Integration thread bullet rewritten so testers and contributors
see Slices 1-3 as done and Slice 4 governance refresh as the only
remaining piece, with file paths to both pin tests.
No code changes. The 200k JSON evidence artifact is intentionally left
untouched so the operator's next lab run can record the algorithmic
delta against the recorded baseline (publication truthfulness rule:
do not invent benchmark numbers from the agent VM, where wall-time is
not comparable to lab hardware).
Co-authored-by: Fabio Tavares Leitão <[email protected]>
| out.parent.mkdir(parents=True, exist_ok=True) | ||
| out.write_text(md, encoding="utf-8") | ||
| return 0 | ||
| except BaseException as exc: # noqa: BLE001 — RCA must observe every failure mode |
Fixes Lint (pre-commit) ruff-format check after conflict resolution on PR #236. Co-authored-by: Fabio Tavares Leitão <[email protected]>
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.
Description
Closes the original engineering-doctrine execution plan after PRs #230 / #231 (Slice 1: doctrine manifestos + 200k benchmark evidence baseline). Three coherent commits, one per slice, each with its own pin test:
Slice 2 —
feat(report): RCA block indata-boar-reportfailure pathcli/reporter.py: every failure now emits a Sysinternals-style RCA block on stderr so an operator can see which step of the regen pipeline broke without paging the maintainer for a traceback.load_config,open_sqlite,fetch_findings,build_manifest,render_markdown,write_output. Each step maps to a narrowed hypothesis + the smallest deterministic command an operator can paste to reproduce the failure on the same SQLite.--debug-tracebackflag appends the full traceback on top of the RCA for lab use.docs/ops/inspirations/INTERNAL_DIAGNOSTIC_AESTHETICS.md§2.2-3 andDEFENSIVE_SCANNING_MANIFESTO.md§1 (read-only against customer SQLite — no DDL, no temp objects, no live connector).tests/test_cli_reporter_rca.pypins the contract (5 tests).Slice 3 —
refactor(detector): single-pass Pro fallback + skip redundant chunk copypro/worker_logic.py::basic_python_scan: was two passes overpayloads(OpenCore prefilter then Luhn loop with asetmembership probe); now a single list comprehension with hoisted bound-method references and a short-circuitorchain over the same three predicates (CPF regex, email regex, Luhn-valid card).pro/engine.py::process_chunk_worker: O(1) probe (isinstance(chunk, list) and isinstance(chunk[0], str)) reuses the input on the documented hot path so the[str(item) for item in chunk]allocation is skipped when the orchestrator already produced alist[str]. Cold path (tuples, generators, mixed types) still gets the defensive coercion.tests/test_basic_python_scan_single_pass_parity.pypins acceptance set: OpenCore-accepted CPF/email rows must remain a strict subset of the new output, Luhn-valid cards must still be admitted while invalid cards must not, rows hitting multiple predicates appear at most once per input, and a 5_000-row clean corpus must yield zero survivors.Slice 4 —
docs(plans): close the loop, record 0.574x as technical debt baselinedocs/plans/PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md: status line + sequential to-do table now show Slices 1–3 ✅ with file pointers; Slice 4 marks itself in flight.docs/plans/BENCHMARK_EVOLUTION.md: new §8 explains the recordedspeedup_vs_opencore = 0.574fromtests/benchmarks/official_benchmark_200k.jsonin plain English (Pro is ~1.74x slower than OpenCore in this profile because the lab host runs the Python fallback — no Rust extension yet). Names the precision invariantpro_hits == opencore_hitsand the existing test that fails first if it is ever broken.docs/plans/PLANS_TODO.mdintegration thread rewritten so testers see Slices 1–3 done and Slice 4 governance refresh as the only remaining piece.The 200k JSON evidence artifact is intentionally left untouched: the agent VM wall-time is not comparable to lab hardware, and inventing a "Pro faster" number here would violate
INTERNAL_DIAGNOSTIC_AESTHETICS.md§4 (no invented numbers). The nextscripts/benchmark-ab.ps1run on the lab will measure the algorithmic delta against the recorded baseline.Type of change
Checklist
uv run pytest) — 913 passed, 5 skipped (pre-existing PowerShell parse failures on Linux runner withoutpwshare environment-only, unrelated to this PR).ruff+ruff formatclean on every commit).Related
docs/plans/PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md.tests/test_cli_reporter_rca.py,tests/test_basic_python_scan_single_pass_parity.py,tests/test_official_benchmark_200k_evidence.py(parity + speedup direction).Operational notes