Skip to content

Reject compound directives and strengthen grammar validation#181

Merged
rlippmann merged 4 commits into
mainfrom
compound-directive-rejection
Jul 11, 2026
Merged

Reject compound directives and strengthen grammar validation#181
rlippmann merged 4 commits into
mainfrom
compound-directive-rejection

Conversation

@rlippmann

Copy link
Copy Markdown
Owner

Summary

Strengthen the directive grammar by enforcing the single-directive invariant.

Inputs containing more than one canonical directive are now rejected through the existing public clarify decision contract. No authoritative state is mutated and no pending clarification/replacement state is created.

This PR also adds comprehensive regression coverage, conformance fixtures, property-based testing, and documentation updates.

Changes

Grammar

  • Reject inputs containing multiple canonical directive starts.
  • Apply the rule uniformly across all canonical directive families.
  • Base detection on canonical directive starts rather than conjunctions or separators.
  • Preserve current quote semantics (quotes do not create protected parsing regions).

Implementation

  • Route compound directives through the existing recognized-invalid directive path.
  • Preserve pending-confirmation precedence.
  • Preserve existing single-directive behavior.
  • Centralize canonical directive-start definitions to reduce parser/scanner drift.

Tests

  • Add regression coverage across directive families, separators, quoting, pending confirmation, transcript replay, and parser/scanner alignment.
  • Add focused Hypothesis property tests for lexical boundary handling.
  • Update existing property tests to reflect the tightened grammar.

Conformance

  • Add canonical compound-directive conformance fixtures.
  • Add transcript replay conformance coverage for compound directives.

Documentation

  • Document the single-directive grammar invariant.
  • Document compound directives as invalid grammar reported through the existing clarify contract.
  • Document current quote behavior.
  • Add concise grammar examples.

Validation

  • uv run pytest
  • uv run pytest --cov=context_compiler --cov-report=term-missing
  • uv run pre-commit run --all-files

All passed.

Closes #179

@rlippmann rlippmann merged commit 2fd9d5a into main Jul 11, 2026
14 checks passed
@rlippmann rlippmann deleted the compound-directive-rejection branch July 11, 2026 03:26
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.

Clarify on compound directive payloads containing multiple canonical directives

1 participant