Skip to content

feat(contracts): tiered execution — TierDefinition + TierSelector + DegradationPolicy (#201)#210

Merged
stackbilt-admin merged 3 commits into
mainfrom
feat/tiered-execution-contract
Jun 11, 2026
Merged

feat(contracts): tiered execution — TierDefinition + TierSelector + DegradationPolicy (#201)#210
stackbilt-admin merged 3 commits into
mainfrom
feat/tiered-execution-contract

Conversation

@stackbilt-admin

Copy link
Copy Markdown
Member

Summary

  • Adds 4 new generic interfaces to @stackbilt/types: TierConstraint, TierDefinition<T>, TierSelector<T, Input>, DegradationPolicy<T> — names and contracts the tier-system pattern that had fragmented across 6 independent implementations in charter and two external repos with no shared shape
  • Adds 5 TierDefinition constants in @stackbilt/types (AppMode, Urgency, Complexity, ChangeClass, CommitRiskLevel) — zero behavior change, interface alignment only
  • Adds ONTOLOGY_SENSITIVITY_TIERS constant to @stackbilt/validate using the new TierDefinition<OntologySensitivityTier> shape (6 tiers: public→secrets)

Test plan

  • pnpm run build — clean build across all packages
  • pnpm test — 679/679 passing (20 new assertions across tiers.test.ts and ontology.test.ts)
  • Structural completeness: every constant has non-empty tiers[], descriptions, constraints; no duplicates; ascending severity order verified
  • Key constraint semantics spot-checked: escalation (CRITICAL), architecture review (EPIC), human review (HIGH), committee review (CROSS_CUTTING), secrets boundary (INTERNAL_ONLY)

Closes #201

🤖 Generated with Claude Code

Kurt Overmier and others added 3 commits June 11, 2026 18:15
…egradationPolicy (#201)

Names and contracts the tier-system pattern that had fragmented across 6
independent implementations in charter (AppMode, Urgency, Complexity,
ChangeClass, CommitRiskLevel, OntologySensitivityTier) and two external
repos (colonyos cognitive-law, llm-providers model-catalog) with no
shared shape.

Interfaces in @stackbilt/types (zero-dep, generic):
  - TierConstraint — what a tier constrains, with description
  - TierDefinition<T> — ordered tiers[], descriptions, constraints, mode
  - TierSelector<T, Input> — deterministic select(input, hint?) + onTransition
  - DegradationPolicy<T> — opt-in extension for health-signal-driven tiers:
    degrade(), recoveryTicks, ceiling, floor; reference impl: colonyos

TierDefinition constants (no behavior change — interface alignment only):
  - APP_MODE_TIERS          (@stackbilt/types)
  - URGENCY_TIERS           (@stackbilt/types)
  - COMPLEXITY_TIERS        (@stackbilt/types)
  - CHANGE_CLASS_TIERS      (@stackbilt/types)
  - COMMIT_RISK_TIERS       (@stackbilt/types)
  - ONTOLOGY_SENSITIVITY_TIERS (@stackbilt/validate — 6 tiers, public→secrets)

Tests (20 new assertions across 2 files):
  - Structural completeness: tiers[], descriptions, constraints all populated
  - No dead tiers (no duplicates in tiers[])
  - Ascending severity ordering verified for ordered systems
  - Key constraint semantics spot-checked (escalation, human review, committee)

Closes #201

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…an on compiled files

charter adf compile emits a COMPILE_BANNER_MARKER in every generated file
(AGENTS.md, .cursorrules, GEMINI.md etc.) but POINTER_MARKERS did not include
that string, so doctor flagged compiled outputs as "stack rules that should
live in .ai/" — the opposite of what they are.

Also fix a second false positive: compiled files contain ADF section content
by design (they ARE the rendered .ai/ modules), so running the vendor bloat
overlap and keyword-density checks against them was guaranteed to fire.

Changes:
  adf.ts: prepend COMPILE_BANNER_MARKER to POINTER_MARKERS so compile output
    is recognized as an authoritative pointer, not a hand-written rule file.
  doctor.ts: import COMPILE_BANNER_MARKER; skip bloat loop for any file whose
    content includes the compile banner.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rom bloat (#198)

Two bugs in vendor-file handling that caused operational protocol blocks to
be misrouted or silently dropped:

Bug 1 — Routing: The retained-heading list in extractBeyondPointer() was a
fixed enumeration (Session Start, Session Protocol, Session Setup). Headings
like "Session Registration", "AEGIS Task Provenance", "Receipt", and generic
"## *Protocol" blocks were treated as bloat and routed to core.adf. Fix:
  - Extract isRetainedHeading() helper shared across extractBeyondPointer() and
    restorePointer(); matches ## Environment, ## Module Index, any ## Session *,
    and any heading containing Protocol | Receipt | Provenance | Registration.
  - Add STAY_HEADING_PATTERNS in content-classifier.ts so classifyElement()
    returns STAY for items under operational headings even if extracted.

Bug 2 — Structure: restorePointer() completely rewrote the vendor file and
only re-appended ## Environment items, silently dropping all other retained
sections (Session *, Protocol, etc.) that extractBeyondPointer() had skipped.
Fix: add readRetainedSections() that re-reads and verbatim-appends all retained
sections from the current file content before overwriting.

Tests: 6 new assertions
  - 5 in content-classifier.test.ts (heading-level STAY for Session/Protocol/
    Provenance/Receipt headings; confirm domain headings still migrate normally)
  - 1 integration test in vendor-bloat.test.ts: tidy preserves ## Session
    Registration / ## Session Protocol verbatim while still extracting
    ## Architecture bloat to ADF modules

Closes #198

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@stackbilt-admin stackbilt-admin merged commit 4875444 into main Jun 11, 2026
5 checks passed
@stackbilt-admin stackbilt-admin deleted the feat/tiered-execution-contract branch June 11, 2026 23:36
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.

[contract] Tiered execution — TierDefinition + TierSelector + DegradationPolicy

1 participant