Skip to content

feat(ops,report,detector,plans): doctrine Slices 2-4 (RCA blocks + Methodology-of-Safety + benchmark evolution) - #232

Merged
FabioLeitao merged 4 commits into
mainfrom
cursor/sre-agent-protocol-c70a
Apr 27, 2026
Merged

FabioLeitao merged 4 commits into
mainfrom
cursor/sre-agent-protocol-c70a

Conversation

@cursor

@cursor cursor Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Operator handoff (Slack, 2026-04-27) flagged that Slice 1 of PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md shipped (manifestos + hub wiring) but Slices 2, 3, and 4 were still pending. Constraint: preserve sample caps and statement timeouts (the non-negotiable defensive-scanning relief valves) and integrate the 200k A/B 0.574x figure in the BENCHMARK_EVOLUTION.md refresh.

This PR delivers all three remaining slices without touching the customer-DB-protecting clamps in connectors/sql_sampling.py.

Slice 2 — RCA blocks (feat(ops,report))

Mark Russinovich would not accept a one-line failed. Each failure path now writes a Sysinternals-style block (phase, exit, narrowed hypotheses, next concrete step) and a structured event so completão logs are greppable.

  • scripts/lab-completao-orchestrate.ps1 — new Write-CompletaoRcaBlock helper, wired into the failure paths for inventory_preflight, lab_git_ensure_ref, data_contract_preflight, image_preflight, host_smoke, grc_executive_report, and grc_export_artifacts. Each writes a structured rca_<phase> JSONL event under docs/private/homelab/reports/completao_*_orchestrate_events.jsonl.
  • cli/reporter.py — new _emit_rca_block helper, wired into the empty --session-id guard, the output-path-escapes-cfg-dir guard, and a generic except around manifest + report generation. Re-raises so existing pytest / CI behaviour stays the same.
  • report/executive_report.py — new Methodology-of-Safety proof block under section 3 narrating why the existing sample caps and timeouts protect the customer DB. Pure narrative around values already on the manifest. No behaviour change.

Slice 3 — Doctrinal docstrings (refactor(detector,report))

Behaviour-preserving comments so future refactors cannot silently drop the contract:

  • connectors/sql_sampling.py — module note + per-function docstrings on resolve_sql_sample_limit (cap clamp = relief valve) and resolve_statement_timeout_ms_for_sampling (timeout clamp = relief valve); _COMPLIANCE_SCAN_LEADING constant gains a comment recording the DBA-grep contract from DEFENSIVE_SCANNING_MANIFESTO.md §4.
  • core/scan_audit_log.py — module note ties the JSON to DEFENSIVE_SCANNING_MANIFESTO.md (echoes of relief valves) and ACTIONABLE_GOVERNANCE_AND_TRUST.md (the disclaimer field is the system explains itself discipline).
  • report/executive_report.py — module note ties sections 3-4 to ACTIONABLE_GOVERNANCE_AND_TRUST.md (trust triangle), the Methodology-of-Safety block to DEFENSIVE_SCANNING_MANIFESTO.md, and graceful degradation when manifest fields are missing to THE_ART_OF_THE_FALLBACK.md.

Slice 4 — BENCHMARK_EVOLUTION.md v1.7.3 → HEAD (docs(plans))

  • New header "Last refreshed: 2026-04-27" bridge to the plan.
  • New §3.1 — Pinned 200k A/B (OpenCore vs Pro path): OpenCore/Pro/speedup table, a Julia-Evans reading guide so speedup_vs_opencore = 0.574 (= OpenCore/Pro time) and the operator chat phrasing "0.574x mais lento" agree on direction without double-inversion, the regression guard reference (tests/test_official_benchmark_200k_evidence.py), and a doctrinal reading tied to DEFENSIVE_SCANNING_MANIFESTO, THE_ART_OF_THE_FALLBACK, ACTIONABLE_GOVERNANCE_AND_TRUST.
  • New §8 — v1.7.3 → HEAD narrative separating resilience gains (RCA blocks, Methodology-of-Safety, doctrinal docstrings) from coverage gains (200k A/B parity guard, audit log echoes of relief valves, strategy labels) and a pinned-constraints table that names where the non-negotiable caps and timeouts live in code.
  • PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md — Status line: Slices 1-4 delivered; sequential to-do steps 9-12 marked ✅ Done with file pointers.

The frozen 2026-04-25 JSON artifact and the dated archive at docs/ops/lab_lessons_learned/LAB_LESSONS_LEARNED_2026_04_27.md are untouched per ADR 0042.

Defensive Architecture posture (constraints honoured)

Constraint Where it lives Honoured by this PR
_HARD_MAX_SAMPLE = 10_000 connectors/sql_sampling.py::_HARD_MAX_SAMPLE ✅ Untouched.
Statement timeout 250..60_000 ms resolve_statement_timeout_ms_for_sampling ✅ Untouched.
Leading -- Data Boar Compliance Scan _COMPLIANCE_SCAN_LEADING ✅ Untouched (now also documented in a comment).
No ORDER BY in auto-sampling connectors/sql_sampling.py composition layer ✅ Untouched.
Findings parity asserted before performance tests/test_official_benchmark_200k_evidence.py ✅ Untouched.
Zero impact on customer database locks All slices ✅ No connector code path changed.

Doctrine references (Council of Mentors)

Tests run locally

uv run pytest tests/test_executive_report.py tests/test_scan_audit_log.py \
              tests/test_sql_sampling.py tests/test_official_benchmark_200k_evidence.py \
              tests/test_scan_evidence.py tests/test_docs_external_no_plan_links.py \
              tests/test_docs_markdown.py tests/test_plans_hub_sync.py tests/test_plans_stats.py
# 186 passed

Pre-commit hooks ran on each commit (markdown lint, pt-BR locale, plans-stats freshness, external-tier-no-plan-links, uv lock parity, PII guards, commercial guard, ruff format).

Files

Path Slice Change
scripts/lab-completao-orchestrate.ps1 2 Write-CompletaoRcaBlock helper + wiring across seven failure paths.
cli/reporter.py 2 _emit_rca_block helper + three guard blocks; re-raise preserves CI behaviour.
report/executive_report.py 2/3 Methodology-of-Safety proof block under §3; doctrinal docstring at module head.
connectors/sql_sampling.py 3 Doctrinal docstrings; _COMPLIANCE_SCAN_LEADING comment.
core/scan_audit_log.py 3 Doctrinal module-head note.
docs/plans/BENCHMARK_EVOLUTION.md 4 New §3.1 (200k A/B reading guide) + §8 (v1.7.3 → HEAD narrative + pinned constraints).
docs/plans/PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md 4 Status + sequential to-dos marked done.

Inspired in form by linuxmint/live-installer#177 / #178 (clear symptom → root cause → fix → evidence → defensive constraints → next steps). No invented metrics or dates.

Open in Web View Automation 

cursoragent and others added 3 commits April 27, 2026 16:04
Slice 2 of PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION:

- scripts/lab-completao-orchestrate.ps1: add Write-CompletaoRcaBlock helper
  and wire it into the failure paths for inventory_preflight,
  lab_git_ensure_ref, data_contract_preflight, image_preflight, host_smoke,
  grc_executive_report, grc_export_artifacts. Each block names the phase,
  message, narrowed hypotheses, next concrete step, and emits a structured
  rca_<phase> JSONL event so future tooling can grep completao outcomes.

- cli/reporter.py: add _emit_rca_block helper for data-boar-report and wire
  it into (a) the empty --session-id guard, (b) the output-path-escapes-cfg
  guard, and (c) a generic except wrapper around manifest+report generation.
  Re-raise after the block to preserve current pytest / CI behaviour.

- report/executive_report.py: add a Methodology-of-Safety proof block under
  section 3 narrating why the existing sample caps and statement timeouts
  protect the customer DB. Pure narrative around values already on the
  manifest -- no behavior change. Sample caps and timeouts remain enforced
  in connectors/sql_sampling.py (_HARD_MAX_SAMPLE = 10_000, timeout clamp
  <= 60_000 ms) per DEFENSIVE_SCANNING_MANIFESTO.md.

Doctrine references: THE_ART_OF_THE_FALLBACK.md (no silent fall-through),
INTERNAL_DIAGNOSTIC_AESTHETICS.md (Sysinternals-grade narrative),
ACTIONABLE_GOVERNANCE_AND_TRUST.md (the trust triangle: Markdown + manifest
YAML + reproducible CLI).

Tests: 27 passed across executive_report, scan_audit_log, sql_sampling,
and the 200k benchmark guard.

Co-authored-by: Fabio Tavares Leitão <[email protected]>
…s (Slice 3)

Slice 3 of PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION -- behaviour-preserving:

- connectors/sql_sampling.py: top-of-module note + per-function docstrings
  for resolve_sql_sample_limit and resolve_statement_timeout_ms_for_sampling
  cite DEFENSIVE_SCANNING_MANIFESTO.md (relief-valve clamps) and
  THE_ART_OF_THE_FALLBACK.md (strategy labels never silently fall through).
  The _COMPLIANCE_SCAN_LEADING constant gains a comment recording the
  DBA-grep contract from manifesto section 4 so future refactors do not
  drop it.

- core/scan_audit_log.py: top-of-module note ties the audit log JSON to
  DEFENSIVE_SCANNING_MANIFESTO.md (echoes of the relief valves) and
  ACTIONABLE_GOVERNANCE_AND_TRUST.md (the disclaimer field is the
  'system explains itself' discipline).

- report/executive_report.py: top-of-module note ties sections 3-4 to
  ACTIONABLE_GOVERNANCE_AND_TRUST.md (trust triangle), the Methodology-of-
  Safety block to DEFENSIVE_SCANNING_MANIFESTO.md, and the graceful
  degradation when manifest fields are missing to THE_ART_OF_THE_FALLBACK.md.

No code paths changed. Sample caps (_HARD_MAX_SAMPLE = 10_000) and
statement timeout clamp (250..60_000 ms) remain enforced in
connectors/sql_sampling.py exactly as before. Tests covering those clamps
remain green (31 passed across executive_report, scan_audit_log,
sql_sampling, scan_evidence, and the 200k benchmark guard).

Co-authored-by: Fabio Tavares Leitão <[email protected]>
… (Slice 4)

Slice 4 of PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION:

- docs/plans/BENCHMARK_EVOLUTION.md gains:
  - Header 'Last refreshed: 2026-04-27' bridge to PLAN doctrine.
  - Section 3.1 'Pinned 200k A/B (OpenCore vs Pro path) -- direction-only
    evidence' with the OpenCore/Pro/speedup table, a Julia-Evans reading
    guide so the JSON value (0.574 = OpenCore/Pro time) and the operator
    chat phrasing ('0.574x mais lento') agree on direction without
    double-inversion, the regression guard reference
    (tests/test_official_benchmark_200k_evidence.py), and a doctrinal
    interpretation tied to DEFENSIVE_SCANNING_MANIFESTO,
    THE_ART_OF_THE_FALLBACK, and ACTIONABLE_GOVERNANCE_AND_TRUST.
  - Section 8 'v1.7.3 -> HEAD narrative' separating resilience gains
    (RCA blocks in completao + data-boar-report, Methodology-of-Safety
    proof block, doctrinal docstrings) from coverage gains (200k A/B
    parity guard, audit log echoes of relief valves, strategy labels)
    and a pinned-constraints table that names where the
    non-negotiable sample caps and statement timeouts live in code.
  - Revision log row dated 2026-04-27.

- docs/plans/PLAN_ENGINEERING_DOCTRINE_CONSOLIDATION.md:
  - Status line: Slices 1-4 delivered.
  - Sequential to-do steps 9-12 marked Done with file pointers.

The 0.574x lab number is integrated as a reading guide and cross-link, not
as a re-run; the immutable JSON artifact and the dated archive at
docs/ops/lab_lessons_learned/LAB_LESSONS_LEARNED_2026_04_27.md remain
untouched per ADR 0042.

No code change in this commit; tests for executive_report, scan_audit_log,
sql_sampling, the 200k benchmark guard, plans-hub-sync, and docs-markdown
remain green (186 passed).

Co-authored-by: Fabio Tavares Leitão <[email protected]>
@FabioLeitao
FabioLeitao marked this pull request as ready for review April 27, 2026 18:11
@FabioLeitao
FabioLeitao merged commit af1602f into main Apr 27, 2026
1 check passed
@FabioLeitao
FabioLeitao deleted the cursor/sre-agent-protocol-c70a branch April 27, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants