Skip to content

Implement Layer 3 business guardrails: DSL parser and evaluator (RFC-0003) - #5

Merged
emmanuel-a-otchere merged 1 commit into
mainfrom
vibe/rfc0003-layer3-8eb746
Oct 31, 2026
Merged

emmanuel-a-otchere merged 1 commit into
mainfrom
vibe/rfc0003-layer3-8eb746

Conversation

@emmanuel-a-otchere

Copy link
Copy Markdown
Contributor

Summary

  • Implement the Layer 3 (Business Guardrails) module src/layer3/layer3.ts per RFC-0003 and the v0.4 contract:
    • parseRules: the guardrail DSL parser (rule <id> { when <condition> then <reject|annotate|escalate> with rationale "..." }). Malformed rules throw guardrail-rules-malformed
    • Condition language (v0.4): constraint(<scope>) == / != "<value>", flag(<flag_type>), source_expired(), decision_type == "<suffix>"
    • Layer3.evaluate: evaluates rules against a post-Layer-2 COTS, attaches a GuardrailDecision to every decision (accepted / rejected / annotated / escalated), applies the normative status updates (rejected -> superseded, escalated -> appealed), and returns the rejected/escalated lists. No silent rejection: rejected decisions remain in the COTS with their rule and rationale
    • Empty/missing rule sets throw domain-rules-missing per the contract's failure modes
  • Add the GuardrailDecision types to src/cots.ts (COTS schema v1.3.0; optional field)
  • 9 new tests: parser (well-formed, malformed, unknown condition) and evaluator (binding rejection with status update, advisory annotation, escalation, acceptance with recorded rationale, empty rules, no-silent-rejection)

Verification

  • npx vitest run: 30/30 tests pass
  • npx tsc --noEmit: clean

…03 and the v0.4 contract

Co-authored-by: emmanuel-a-otchere <emmanuel-a-otchere@users.noreply.github.com>
@emmanuel-a-otchere emmanuel-a-otchere self-assigned this Oct 31, 2026
@emmanuel-a-otchere
emmanuel-a-otchere marked this pull request as ready for review October 31, 2026 01:06
@emmanuel-a-otchere
emmanuel-a-otchere merged commit e39f5b9 into main Oct 31, 2026
1 check passed
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