feat(contracts): tiered execution — TierDefinition + TierSelector + DegradationPolicy (#201)#210
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@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 shapeTierDefinitionconstants in@stackbilt/types(AppMode, Urgency, Complexity, ChangeClass, CommitRiskLevel) — zero behavior change, interface alignment onlyONTOLOGY_SENSITIVITY_TIERSconstant to@stackbilt/validateusing the newTierDefinition<OntologySensitivityTier>shape (6 tiers: public→secrets)Test plan
pnpm run build— clean build across all packagespnpm test— 679/679 passing (20 new assertions acrosstiers.test.tsandontology.test.ts)tiers[],descriptions,constraints; no duplicates; ascending severity order verifiedCloses #201
🤖 Generated with Claude Code