get2knowio / get2knowio/maverick

refactor: replace raw string search for '## Scope' in flight-plan validator (V9)

Open
#79 0 comments 0 reactions 0 assignees View on GitHub
tech-debt
Dominant language
Python
Stars
4
Forks
0
Avg merge
17h 37m
Merged PRs (30d)
7

Description

## Context

The V9 validation rule in `src/maverick/flight/validator.py` checks for the presence of the `## Scope` section using a raw string search:

```python
# validator.py line 185
if "## Scope" not in body:
```

The comment in the code explains _why_: `parse_flight_plan_sections()` always returns a `scope` dict even when the section is absent from the source file (the parser synthesises an empty one). So the parsed sections dict cannot be used for V9.

## Problem

The raw `in body` check is fragile:
- A false negative if `## Scope` appears inside a code block or blockquote within another section
- Inconsistent with how V7 and V8 check sections (via the `sections` dict)

## Suggested fix

Option A: Use `_split_h2_sections(body)` directly and check for the `"Scope"` key there (bypassing the higher-level parser that synthesises missing sections).

Option B: Update `parse_flight_plan_sections()` to return a sentinel flag (`scope_present: bool`) alongside the `scope` dict, so callers can distinguish "section existed" from "section was synthesised".

Option A is simpler and doesn't require changing the public API.

## Origin

Flagged during code review of branch `040-flight-plan-cli` (both Python and spec reviews, severity LOW).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.