Documentation Index
Fetch the complete documentation index at: https://grantmaster.dev/llms.txt
Use this file to discover all available pages before exploring further.
Architecture Consistency Guardrails
This document defines CI guardrails that keep module boundaries and architectural ownership consistent over time.Goals
- Prevent reintroduction of cyclic and forbidden dependencies.
- Prevent cross-feature coupling through non-public feature internals.
- Ensure every source area is explicitly owned.
- Enforce semver-governed feature public contracts.
- Surface architecture risk trend signals directly in PRs.
- Keep rollout safe with no-regression baselines where full cleanup is still in progress.
Guardrails
1. Dependency Architecture Gate
- Command:
npm run check:architecture - Backed by
dependency-cruiser(.dependency-cruiser.cjs) - Baseline file:
config/architecture-violations-baseline.json - Report:
artifacts/architecture-report.json
2. Feature Public API Gate
- Command:
npm run check:feature-public-api - Rule: Imports to
@/features/<feature>/...from outside that feature must go through the feature public API (@/features/<feature>or@/features/<feature>/index). - Extension: Stable sub-entrypoints can be explicitly declared as public in
config/feature-public-api-allowlist.json(for example context or service facades that are part of the supported feature contract). - Baseline file:
config/feature-public-api-violations-baseline.json - Report:
artifacts/feature-public-api-report.json
2.1 Feature Hook Contract Gate
- Command:
npm run check:feature-hook-contracts - Rule:
- Feature hooks exported from
src/features/*/public.tsmust be documented indocs/engineering/api-reference/hooks-reference.md. - Public feature hook source files must not import Firebase directly; server-backed hooks must delegate to services.
- Feature hooks exported from
- Report:
artifacts/feature-hook-contract-report.json
3. Layer Ownership Coverage Gate
- Command:
npm run check:layer-ownership - Rule: Every source file under
src/must match an ownership mapping entry. - Ownership mapping:
config/layer-ownership.json - Report:
artifacts/layer-ownership-report.json
4. Review Routing with CODEOWNERS
- File:
.github/CODEOWNERS - Rule: Architectural ownership paths in
config/layer-ownership.jsonare mirrored in CODEOWNERS so PR review assignment follows the same boundaries.
5. Public Contract Semver + Changelog Gate
- Command:
npm run check:public-api-contracts - Rule:
- Every
src/features/*/public.tsmust declarePUBLIC_API_VERSIONin semver format. - Removing exports from a feature public contract is treated as breaking.
- Breaking changes must include a major
PUBLIC_API_VERSIONbump. - Breaking changes must include a changelog entry in
docs/engineering/api-reference/changelog-public-api.md.
- Every
- Baseline file:
config/public-api-contract-baseline.json - Report:
artifacts/public-api-contract-report.json
6. Auto-Generated Public API Contract Docs
- Generate:
npm run docs:public-api:generate - CI sync check:
npm run docs:public-api:check - Output directory:
docs/engineering/api-reference/public-api/ - Source of truth:
src/features/*/public.ts
7. Runtime Architecture Guard Assertions (Dev/Test)
- Generator command:
npm run architecture:runtime-guards:generate - Runtime assertion modules:
- App bootstrap:
src/index.tsx - Test bootstrap:
tests/setup.ts
- App bootstrap:
- Behavior:
- Dev/test throws early when new architecture violations or new cross-feature private-import violations are detected against baselines.
- Production runtime is unaffected.
8. Architecture Risk Scoring + PR Summary
- Command:
npm run check:architecture:risk - Signals:
- cycle violations
- cross-feature dependency edges
- cross-feature private edges
- baseline debt trend vs base branch
- Outputs:
artifacts/architecture-risk-report.jsonartifacts/architecture-risk-summary.md- Appends summary to
GITHUB_STEP_SUMMARYin CI
- Branch budgets:
- Config file:
config/architecture-risk-budget.json develop: warning when score exceeds configured threshold.main: fail when score exceeds configured threshold.
- Config file:
9. Architecture Risk History Artifact
- Command:
npm run check:architecture:risk:history - Output:
artifacts/architecture-risk-history.jsonartifacts/architecture-risk-history.csvartifacts/architecture-risk-history.md
- Window: last
Ncommits (--limit, default20) with score + debt baseline trend.
10. BaseService Adoption Gate
- Command:
npm run check:base-service-adoption - Rule: Service files that import Firestore CRUD/query helpers directly must extend
BaseServiceorExtensionBaseServiceso they inherit standardized error handling, EventBus emission, audit logging, tenant scoping, and quota enforcement. - Detection includes:
- static imports from
firebase/firestore - dynamic
import('firebase/firestore')usage of CRUD/query helpers - imports from internal Firestore helper entrypoints such as
@/core/firestore*
- static imports from
- Scope:
src/core/**src/shared/**src/features/**src/extensions/**
- Baseline file:
config/base-service-adoption-baseline.json - Report:
artifacts/base-service-adoption-report.json - Companion gates:
npm run check:base-service-adoption:budgetnpm run check:base-service-adoption:approval
11. Extension EventBus Subscription Gate
- Command:
npm run check:extension-eventbus-subscriptions - Rule: Source files under
src/extensions/**must not subscribe with rawEventBus.on()oronAny()on the global bus or injectedIEventBusreferences. - Required patterns:
createExtensionEventBus(extensionId).on(...)ExtensionBaseService.subscribeToEvent(...)
- Goal: prevent orphaned listeners that survive extension deactivation.
12. TypeScript No-Regression Gates
- Commands:
npm run check:types-baselinenpm run check:types:baseline:approvalnpm run check:types:libcheck-baseline
- Rule:
check:types-baselinetracks the broader core/shared/services TypeScript surface fromtsconfig.ci.json.check:types:baseline:approvalforces explicit PR acknowledgement when either TypeScript baseline file changes.check:types:libcheck-baselinetracks the same surface withskipLibCheck: falseviatsconfig.libcheck.json.- Both are no-regression gates: existing debt is baselined, but new errors fail CI.
- Baseline files:
config/typescript-errors-baseline.jsonconfig/typescript-libcheck-baseline.json
Baseline Management
- Use
--update-baselineonly when intentionally accepting the current state as migration debt. - Any baseline update should be reviewed alongside a rationale in the PR description.
- TypeScript baseline changes must be explicitly approved in CI before merge.
- BaseService baseline changes must be explicitly approved in CI before merge.
- Priority is to burn down baseline entries over time, not keep them static.
13. Agent Service Attribution Gate
- Command:
npm run check:agent-service-attribution - Rule:
- Built-in agent tool callbacks and extension agent handlers must pass
context.agentContextwhen they call write-capable service methods. - The check is intentionally conservative and targets likely mutation verbs on
*Servicereceivers.
- Built-in agent tool callbacks and extension agent handlers must pass
- Goal: prevent agent-triggered writes from being attributed to system/service identities instead of the originating human.
CI Integration
The lint/type-check job enforces architecture guardrails and uploads reports as artifacts:architecture-reportfeature-public-api-reportfeature-hook-contract-reportpublic-api-contract-reportlayer-ownership-reportarchitecture-risk-reportbase-service-adoption-report- TypeScript no-regression gates for both the broad core slice and the
skipLibCheck: falseslice
Debt Budget Policy
- Command:
npm run check:feature-public-api-budget - Rule:
- Fail if
config/feature-public-api-violations-baseline.jsoncount increases vs base branch. - Emit CI warning if the count does not decrease.
- Fail if
- Goal: ensure cross-feature internal import debt trends downward release-over-release.
- Command:
npm run check:base-service-adoption:budget - Rule:
- Fail if
config/base-service-adoption-baseline.jsonadds any entries vs base branch. - Emit CI warning if the baseline does not decrease.
- Fail if
- Goal: ensure BaseService bypass debt only moves downward.
Migration Strategy
- Freeze regressions with current baselines.
- Reduce violations feature-by-feature.
- Regenerate baselines only after deliberate debt-reduction milestones.
- Remove baselines once each guardrail reaches and sustains zero violations.