@ryuenn3123/agentic-senior-core 3.0.50 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.agent-context/review-checklists/pr-checklist.md +1 -0
  2. package/.agent-context/rules/api-docs.md +63 -47
  3. package/.agent-context/rules/architecture.md +133 -120
  4. package/.agent-context/rules/database-design.md +36 -18
  5. package/.agent-context/rules/docker-runtime.md +66 -43
  6. package/.agent-context/rules/efficiency-vs-hype.md +38 -17
  7. package/.agent-context/rules/error-handling.md +35 -16
  8. package/.agent-context/rules/event-driven.md +35 -18
  9. package/.agent-context/rules/frontend-architecture.md +103 -76
  10. package/.agent-context/rules/git-workflow.md +81 -197
  11. package/.agent-context/rules/microservices.md +42 -41
  12. package/.agent-context/rules/naming-conv.md +27 -8
  13. package/.agent-context/rules/performance.md +32 -12
  14. package/.agent-context/rules/realtime.md +26 -9
  15. package/.agent-context/rules/security.md +39 -20
  16. package/.agent-context/rules/testing.md +36 -16
  17. package/AGENTS.md +9 -9
  18. package/README.md +10 -1
  19. package/lib/cli/commands/init.mjs +1 -0
  20. package/lib/cli/compiler.mjs +1 -0
  21. package/lib/cli/detector/constants.mjs +135 -0
  22. package/lib/cli/detector/design-evidence/collector.mjs +256 -0
  23. package/lib/cli/detector/design-evidence/constants.mjs +39 -0
  24. package/lib/cli/detector/design-evidence/file-traversal.mjs +83 -0
  25. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +117 -0
  26. package/lib/cli/detector/design-evidence/summary.mjs +109 -0
  27. package/lib/cli/detector/design-evidence/utility-helpers.mjs +122 -0
  28. package/lib/cli/detector/design-evidence.mjs +25 -610
  29. package/lib/cli/detector/stack-detection.mjs +243 -0
  30. package/lib/cli/detector/ui-signals.mjs +150 -0
  31. package/lib/cli/detector/workspace-scan.mjs +177 -0
  32. package/lib/cli/detector.mjs +20 -688
  33. package/lib/cli/memory-continuity.mjs +1 -0
  34. package/lib/cli/project-scaffolder/design-contract/sections/audits.mjs +96 -0
  35. package/lib/cli/project-scaffolder/design-contract/sections/conceptual-anchor.mjs +116 -0
  36. package/lib/cli/project-scaffolder/design-contract/sections/execution-handoff.mjs +211 -0
  37. package/lib/cli/project-scaffolder/design-contract/seed-signals.mjs +79 -0
  38. package/lib/cli/project-scaffolder/design-contract/signal-vocab.mjs +64 -0
  39. package/lib/cli/project-scaffolder/design-contract/validation/anchor-validators.mjs +222 -0
  40. package/lib/cli/project-scaffolder/design-contract/validation/audit-validators.mjs +117 -0
  41. package/lib/cli/project-scaffolder/design-contract/validation/completeness.mjs +83 -0
  42. package/lib/cli/project-scaffolder/design-contract/validation/execution-validators.mjs +328 -0
  43. package/lib/cli/project-scaffolder/design-contract/validation/helpers.mjs +8 -0
  44. package/lib/cli/project-scaffolder/design-contract/validation/structural-validators.mjs +79 -0
  45. package/lib/cli/project-scaffolder/design-contract/validation/system-validators.mjs +256 -0
  46. package/lib/cli/project-scaffolder/design-contract/validation.mjs +59 -896
  47. package/lib/cli/project-scaffolder/design-contract.mjs +147 -557
  48. package/mcp.json +30 -9
  49. package/package.json +17 -2
  50. package/scripts/audit-cache-layer-contract.mjs +258 -0
  51. package/scripts/audit-caching-scope-hygiene.mjs +263 -0
  52. package/scripts/audit-file-size.mjs +219 -0
  53. package/scripts/audit-reflection-citations.mjs +163 -0
  54. package/scripts/audit-release-bundle.mjs +170 -0
  55. package/scripts/audit-rule-id-uniqueness.mjs +313 -0
  56. package/scripts/benchmark-evidence-bundle.mjs +1 -0
  57. package/scripts/build-release-benchmark-bundle.mjs +204 -0
  58. package/scripts/context-triggered-audit.mjs +1 -0
  59. package/scripts/documentation-boundary-audit.mjs +1 -0
  60. package/scripts/explain-on-demand-audit.mjs +2 -1
  61. package/scripts/frontend-usability-audit.mjs +10 -10
  62. package/scripts/llm-judge/checklist-loader.mjs +45 -0
  63. package/scripts/llm-judge/constants.mjs +66 -0
  64. package/scripts/llm-judge/diff-collection.mjs +74 -0
  65. package/scripts/llm-judge/prompting.mjs +78 -0
  66. package/scripts/llm-judge/providers.mjs +111 -0
  67. package/scripts/llm-judge/verdict.mjs +134 -0
  68. package/scripts/llm-judge.mjs +21 -482
  69. package/scripts/mcp-server/tool-registry.mjs +55 -0
  70. package/scripts/mcp-server/tools.mjs +137 -1
  71. package/scripts/migrate-rule-format/id-prefix-table.mjs +37 -0
  72. package/scripts/migrate-rule-format/parse-legacy.mjs +180 -0
  73. package/scripts/migrate-rule-format/render-new.mjs +169 -0
  74. package/scripts/migrate-rule-format/roundtrip-validate.mjs +89 -0
  75. package/scripts/migrate-rule-format.mjs +192 -0
  76. package/scripts/release-gate/constants.mjs +1 -1
  77. package/scripts/release-gate/static-checks.mjs +1 -1
  78. package/scripts/rules-guardian-audit.mjs +5 -2
  79. package/scripts/single-source-lazy-loading-audit.mjs +2 -1
  80. package/scripts/ui-design-judge/git-input.mjs +3 -0
  81. package/scripts/validate/config.mjs +3 -2
  82. package/scripts/validate/coverage-checks.mjs +1 -1
  83. package/scripts/validate.mjs +93 -1
@@ -6,6 +6,7 @@ Run this before declaring a task done. Apply only the sections relevant to the c
6
6
 
7
7
  - [ ] The agent read `AGENTS.md` and the smallest relevant rule set.
8
8
  - [ ] For non-trivial coding, review, planning, or governance work, the agent produced a Bootstrap Receipt with loaded files, selected rules, skipped rules, unreachable files, and validation plan before implementation output.
9
+ - [ ] Risky actions used the AGENTS.md Bounded Reflection block with valid rule IDs, one-line rationale, and no copied rule prose or hidden chain-of-thought.
9
10
  - [ ] Existing project context came from real files, docs, package metadata, and changed code, not folder name alone.
10
11
  - [ ] Runtime, framework, library, topology, and design choices are explicit user constraints or agent recommendations from current evidence.
11
12
  - [ ] No offline default stack, blueprint, vendor, or visual style was treated as authoritative.
@@ -1,56 +1,75 @@
1
- # API and Public Contract Boundary
2
-
3
- ## Documentation as Hard Rule (Boundary-Aware)
4
-
5
- If a change affects an API, CLI command, exported library behavior, schema, event, or integration contract, update the matching docs in the same change.
6
-
7
- ## Public README Boundary
8
-
9
- Root `README.md` is required for every fresh or existing project. This includes private projects, because a future maintainer still needs a clear public and developer entrypoint.
1
+ ---
2
+ id_prefix: API
3
+ domain: api-docs
4
+ priority: high
5
+ scope: backend
6
+ applies_to:
7
+ - backend
8
+ - fullstack
9
+ keywords:
10
+ - api-docs
11
+ - api
12
+ - contract
13
+ - documentation
14
+ - readme
15
+ - writing
16
+ ---
10
17
 
11
- README content must be safe for outside readers and useful for developers. It must explain what the project is, who it is for, how to set it up, how to run the main workflow, how to configure it, and where deeper docs live when those topics apply.
12
-
13
- Keep README overview-level. Do not make it the canonical governance source. Do not put secrets, private agent notes, hidden reasoning, backlog chatter, raw architecture debate, or internal policy dumps in it.
18
+ # API and Public Contract Boundary
14
19
 
15
- Choose README sections from project evidence. Do not force a fixed template when a section does not apply. For private/internal projects, keep the same clear style but omit private URLs, credentials, customer names, and internal-only operational details that do not belong in repo docs.
20
+ ## API-001: Documentation as Hard Rule (Boundary-Aware)
16
21
 
17
- ## Documentation Growth Model
22
+ 1. If a change affects an API, CLI command, exported library behavior, schema, event, or integration contract, update the matching docs in the same change.
18
23
 
19
- Documentation must evolve with the project. When behavior, setup, architecture, public contracts, data shape, deployment, or validation changes, update README and the matching docs in the same change.
24
+ ## API-002: Public README Boundary
20
25
 
21
- When `docs/` exists, keep `docs/doc-index.md` as the compact routing map for humans and agents. It should list active docs, their purpose, read triggers, status, and last update. It must not duplicate requirements, architecture, or API contracts.
26
+ 1. Root `README.md` is required for every fresh or existing project, including private projects, because a future maintainer still needs a clear public and developer entrypoint.
27
+ 2. README content must be safe for outside readers and useful for developers.
28
+ 3. README content must explain what the project is, who it is for, how to set it up, how to run the main workflow, how to configure it, and where deeper docs live when those topics apply.
29
+ 4. Keep README overview-level. Do not make it the canonical governance source. Do not put secrets, private agent notes, hidden reasoning, backlog chatter, raw architecture debate, or internal policy dumps in it.
30
+ 5. Choose README sections from project evidence. Do not force a fixed template when a section does not apply.
31
+ 6. For private/internal projects, keep the same clear style but omit private URLs, credentials, customer names, and internal-only operational details that do not belong in repo docs.
22
32
 
23
- Start compact, then split only when a topic earns its own file. Good split signals are: the section is long, the workflow is owned separately, the content is referenced often, or the topic needs step-by-step care such as hardware setup, deployment, testing validation, operations, or troubleshooting.
33
+ ## API-003: Documentation Growth Model
24
34
 
25
- Use PRD, SRS, technical design, and ERD as conditional docs, not default boilerplate. PRD covers product intent and roadmap ownership. SRS covers contractual or complex acceptance criteria. Technical design covers architecture under pressure. ERD stays inside `docs/database-schema.md` unless the data model is large or relationship-heavy.
35
+ 1. Documentation must evolve with the project.
36
+ 2. When behavior, setup, architecture, public contracts, data shape, deployment, or validation changes, update README and the matching docs in the same change.
37
+ 3. When `docs/` exists, keep `docs/doc-index.md` as the compact routing map for humans and agents. It should list active docs, their purpose, read triggers, status, and last update.
38
+ 4. `docs/doc-index.md` must not duplicate requirements, architecture, or API contracts.
39
+ 5. Start compact, then split only when a topic earns its own file.
40
+ 6. Good split signals are: the section is long, the workflow is owned separately, the content is referenced often, or the topic needs step-by-step care such as hardware setup, deployment, testing validation, operations, or troubleshooting.
41
+ 7. Use PRD, SRS, technical design, and ERD as conditional docs, not default boilerplate. PRD covers product intent and roadmap ownership; SRS covers contractual or complex acceptance criteria; technical design covers architecture under pressure; ERD stays inside `docs/database-schema.md` unless the data model is large or relationship-heavy.
26
42
 
27
- ## Contract Rules
43
+ ## API-004: Public Contract Rules
28
44
 
29
- - Document the public surface before or alongside implementation.
30
- - Machine-readable API contracts should use the current project standard. If unresolved, the LLM must recommend a current maintained option from official docs.
31
- - HTTP APIs should prefer OpenAPI 3.1 when no stronger project standard exists.
32
- - Choose transport (REST, GraphQL, tRPC, gRPC, SSE, WebSocket) and shape (resource-oriented vs action/command-oriented) from domain evidence, not by habit. When the domain has verbs such as cancel, refund, dispatch, approve, or retry, prefer command endpoints over awkward `PATCH` shoehorns and record at least one alternative transport considered.
33
- - Treat HTTP as a behavioral contract, not just a shape. Document `ETag` and conditional requests for cacheable reads, `Cache-Control` and `Vary` when shared caches apply, rate-limit headers (`RateLimit-*` or `X-RateLimit-*`) with `Retry-After` when rate limiting exists, and require an `Idempotency-Key` request header on unsafe non-idempotent mutations.
34
- - List endpoints must document pagination, limits, filtering, sorting, and empty-state behavior.
35
- - Sensitive mutation endpoints must document idempotency behavior, retry safety, duplicate-submit handling, and any required idempotency key or request fingerprint.
36
- - Public error contracts must document stable machine-readable codes and any RFC 9457 Problem Details-style fields the project exposes, including safe trace or correlation identifiers when present.
37
- - Async, webhook, and event contracts must document idempotency, retry, ordering, dead-letter or recovery behavior, and duplicate-message handling.
38
- - Event APIs should define producer, consumer, payload, versioning, retry, and failure behavior.
39
- - CLI/library public behavior must update README, help text, changelog, or docs as appropriate.
40
- - Do not write "see code" as the contract.
41
- - Do not expose generic `object` or `any` contract shapes when the boundary can be typed.
42
- - Public error shapes must be safe, stable, and documented.
45
+ 1. Document the public surface before or alongside implementation.
46
+ 2. Machine-readable API contracts should use the current project standard. If unresolved, the LLM must recommend a current maintained option from official docs.
47
+ 3. HTTP APIs should prefer OpenAPI 3.1 when no stronger project standard exists.
48
+ 4. Choose transport (REST, GraphQL, tRPC, gRPC, SSE, WebSocket) and shape (resource-oriented vs action/command-oriented) from domain evidence, not by habit.
49
+ 5. When the domain has verbs such as cancel, refund, dispatch, approve, or retry, prefer command endpoints over awkward `PATCH` shoehorns and record at least one alternative transport considered.
50
+ 6. Treat HTTP as a behavioral contract, not just a shape.
51
+ 7. Document `ETag` and conditional requests for cacheable reads, `Cache-Control` and `Vary` when shared caches apply, rate-limit headers (`RateLimit-*` or `X-RateLimit-*`) with `Retry-After` when rate limiting exists, and require an `Idempotency-Key` request header on unsafe non-idempotent mutations.
52
+ 8. List endpoints must document pagination, limits, filtering, sorting, and empty-state behavior.
43
53
 
44
- ## Human Writing Standard (Mandatory)
54
+ ## API-005: Boundary Contract Details
45
55
 
46
- This applies to documentation, release notes, onboarding text, review summaries, and agent-facing explanations.
47
- API docs and README updates are included in this scope.
56
+ 1. Sensitive mutation endpoints must document idempotency behavior, retry safety, duplicate-submit handling, and any required idempotency key or request fingerprint.
57
+ 2. Public error contracts must document stable machine-readable codes and any RFC 9457 Problem Details-style fields the project exposes, including safe trace or correlation identifiers when present.
58
+ 3. Async, webhook, and event contracts must document idempotency, retry, ordering, dead-letter or recovery behavior, and duplicate-message handling.
59
+ 4. Event APIs should define producer, consumer, payload, versioning, retry, and failure behavior.
60
+ 5. CLI/library public behavior must update README, help text, changelog, or docs as appropriate.
61
+ 6. Do not write "see code" as the contract.
62
+ 7. Do not expose generic `object` or `any` contract shapes when the boundary can be typed.
63
+ 8. Public error shapes must be safe, stable, and documented.
48
64
 
49
- ### Language Default
65
+ ## API-006: Human Writing Standard (Mandatory)
50
66
 
51
- Write formal project docs in English by default, even when the user prompt is in another language. Use another documentation language only when the user explicitly asks for it or when existing project docs already establish that language.
67
+ 1. This applies to documentation, release notes, onboarding text, review summaries, and agent-facing explanations.
68
+ 2. API docs and README updates are included in this scope.
69
+ 3. Write formal project docs in English by default, even when the user prompt is in another language.
70
+ 4. Use another documentation language only when the user explicitly asks for it or when existing project docs already establish that language.
52
71
 
53
- ### Style Baseline
72
+ ## API-007: Style Baseline
54
73
 
55
74
  1. Write for native English speakers.
56
75
  2. Target an 8th-grade reading level.
@@ -59,7 +78,7 @@ Write formal project docs in English by default, even when the user prompt is in
59
78
  5. Sound confident, practical, and conversational.
60
79
  6. State the main point first, then supporting detail.
61
80
 
62
- ### Required Behavior
81
+ ## API-008: Required Writing Behavior
63
82
 
64
83
  1. Explain decisions the way a competent coworker would explain them out loud.
65
84
  2. Cut unnecessary words and remove filler.
@@ -67,27 +86,24 @@ Write formal project docs in English by default, even when the user prompt is in
67
86
  4. Rewrite and reorder content when flow is weak.
68
87
  5. Keep explanations short by default; expand only when complexity requires it.
69
88
 
70
- ### Scope Severity and Merge Behavior
89
+ ## API-009: Scope Severity and Merge Behavior
71
90
 
72
91
  1. Scope style guidance controls readability and consistency.
73
92
  2. Style baseline findings are advisory by default and must not block endpoint-change commits that already include accurate docs/spec updates.
74
93
  3. Hard blockers remain contract failures: missing same-commit docs sync, incorrect schema, missing required responses, or factual inaccuracies.
75
94
  4. If style polish is still needed, open a follow-up task instead of delaying the contract update.
76
95
 
77
- ### Non-Negotiables
96
+ ## API-010: Non-Negotiables
78
97
 
79
98
  1. No emoji in formal artifacts.
80
99
  2. Avoid AI cliches and buzzwords: delve, leverage, robust, utilize, seamless.
81
100
  3. Avoid inflated, academic, or performative language.
82
101
  4. Avoid padding, hedging, and redundant phrasing.
83
102
 
84
- ### Critical Controls
103
+ ## API-011: Critical Controls and Final Check
85
104
 
86
105
  1. Any claim about quality, performance, or reliability must include a measurable source and timestamp.
87
106
  2. Expand acronyms on first use, then use terms consistently.
88
107
  3. Separate facts from assumptions explicitly.
89
108
  4. End major explanations with a clear next action.
90
-
91
- ### Final Check
92
-
93
- Read the text out loud before shipping. If it sounds robotic, rewrite it.
109
+ 5. Read the text out loud before shipping. If it sounds robotic, rewrite it.
@@ -1,39 +1,54 @@
1
+ ---
2
+ id_prefix: ARCH
3
+ domain: architecture
4
+ priority: critical
5
+ scope: all-tasks
6
+ applies_to:
7
+ - backend
8
+ - frontend
9
+ - fullstack
10
+ keywords:
11
+ - architecture
12
+ - arch
13
+ - separation
14
+ - concerns
15
+ - structure
16
+ - universal
17
+ ---
18
+
1
19
  # Architecture - Separation of Concerns and Structure
2
20
 
3
21
  > If a service imports transport concerns or raw persistence concerns directly, the architecture is already drifting.
4
22
 
5
- ## Universal Backend Principles (Mandatory)
6
-
7
- These principles are mandatory for backend and shared core modules.
8
-
9
- - No clever hacks.
10
- - No premature abstraction.
11
- - Readability over brevity.
12
- - Keep transport, application, domain, and infrastructure concerns separated.
13
- - Favor explicit module boundaries over hidden cross-layer shortcuts.
14
- - Health endpoints distinguish liveness (the process is alive), readiness (the process can serve traffic), and startup (initialization complete) where the runtime supports it. A `200 OK` that does not check critical dependencies is not a readiness signal.
15
-
16
- ## Complexity Budget (Mandatory)
17
-
18
- Prefer the smallest clear implementation that fully preserves behavior, safety, and maintainability.
19
-
20
- - If two implementations are equivalent in behavior and quality, choose the one with fewer moving parts.
21
- - Remove code that does not carry behavior, safety, clarity, maintainability, or test value.
22
- - Prefer direct logic over extra wrappers, layers, classes, config, or state when the abstraction does not reduce real complexity.
23
- - Keep validation, error handling, fallback paths, accessibility, tests, security boundaries, and observability when they protect real behavior.
24
- - Run a final simplification pass before completion.
25
- - Run a domain-fit pass on public contracts before completion: if endpoint names, payload fields, error codes, table names, or event types could be renamed to another domain without changing shape, the contract is too generic; revise to express the actual domain verbs and invariants. This is the backend equivalent of the design rename test.
26
- - Do not optimize for line count alone.
27
- - Do not replace clear code with clever, dense, or surprising code.
28
- - Do not remove safeguards just because the happy path works.
29
-
30
- ## Universal SOP Baseline (Mandatory)
31
-
32
- The `.agent-context/rules/` directory is the default guidance source for implementation and review.
33
-
34
- - Backend and frontend mindset checks are both required when a task spans API and UI boundaries.
35
- - Security and testing are non-negotiable baseline requirements.
36
- - Hard block before coding:
23
+ ## ARCH-001: Universal Backend Principles (Mandatory)
24
+
25
+ 1. These principles are mandatory for backend and shared core modules.
26
+ 2. No clever hacks.
27
+ 3. No premature abstraction.
28
+ 4. Readability over brevity.
29
+ 5. Keep transport, application, domain, and infrastructure concerns separated.
30
+ 6. Favor explicit module boundaries over hidden cross-layer shortcuts.
31
+ 7. Health endpoints distinguish liveness (the process is alive), readiness (the process can serve traffic), and startup (initialization complete) where the runtime supports it. A `200 OK` that does not check critical dependencies is not a readiness signal.
32
+
33
+ ## ARCH-002: Complexity Budget (Mandatory)
34
+
35
+ 1. Prefer the smallest clear implementation that fully preserves behavior, safety, and maintainability.
36
+ 2. If two implementations are equivalent in behavior and quality, choose the one with fewer moving parts.
37
+ 3. Remove code that does not carry behavior, safety, clarity, maintainability, or test value.
38
+ 4. Prefer direct logic over extra wrappers, layers, classes, config, or state when the abstraction does not reduce real complexity.
39
+ 5. Keep validation, error handling, fallback paths, accessibility, tests, security boundaries, and observability when they protect real behavior.
40
+ 6. Run a final simplification pass before completion.
41
+ 7. Run a domain-fit pass on public contracts before completion: if endpoint names, payload fields, error codes, table names, or event types could be renamed to another domain without changing shape, the contract is too generic; revise to express the actual domain verbs and invariants. This is the backend equivalent of the design rename test (see [REF:FE-004]).
42
+ 8. Do not optimize for line count alone.
43
+ 9. Do not replace clear code with clever, dense, or surprising code.
44
+ 10. Do not remove safeguards just because the happy path works.
45
+
46
+ ## ARCH-003: Universal SOP Baseline (Mandatory)
47
+
48
+ 1. The `.agent-context/rules/` directory is the default guidance source for implementation and review.
49
+ 2. Backend and frontend mindset checks are both required when a task spans API and UI boundaries.
50
+ 3. Security and testing are non-negotiable baseline requirements.
51
+ 4. Hard block before coding:
37
52
  - Root `README.md` must exist for every fresh or existing project and read as a public and developer entrypoint, not an internal agent note.
38
53
  - `docs/doc-index.md` must exist whenever `docs/` exists. It is a compact read-routing map, not a replacement for project docs.
39
54
  - `docs/project-brief.md` must exist.
@@ -42,91 +57,89 @@ The `.agent-context/rules/` directory is the default guidance source for impleme
42
57
  - If the project uses persistent data, `docs/database-schema.md` must exist.
43
58
  - If the project exposes API or web application flows, `docs/api-contract.md` must exist.
44
59
  - For UI scope, `docs/DESIGN.md` and `docs/design-intent.json` must exist.
45
- - Required docs coverage must include a public and developer README entrypoint, feature plan, architecture rationale, public contracts, data model when relevant, UI/design when relevant, security assumptions, testing strategy, delivery flow, and next validation actions.
46
- - If required project context docs are missing, stop implementation and bootstrap docs before writing application code.
47
- - Bootstrap flow: analyze the real repo plus the latest user prompt before authoring those docs.
48
- - Bootstrap docs must be adaptive and project-specific. Do not create generic placeholder templates.
49
- - When context is incomplete, separate confirmed facts from assumptions, add an `Assumptions to Validate` section, and end with the next validation action.
50
- - Keep docs current with project changes. Update README and the matching docs whenever setup, runtime, architecture, public contracts, data shape, UI scope, deployment, or validation flow changes.
51
- - Control docs file count. Keep the baseline compact, then add topic files only when a subject is stable, too long for README/core docs, or belongs to a distinct workflow such as hardware setup, deployment, testing validation, operations, or troubleshooting.
52
-
53
- ## Documentation Read Routing and Conditional Specs
54
-
55
- Use `README.md` for human orientation, then use `docs/doc-index.md` to choose the smallest relevant read set. Do not broad-read every Markdown file in `docs/` by default.
56
-
57
- - Read `docs/project-brief.md`, `docs/architecture-decision-record.md`, and `docs/flow-overview.md` for broad planning, new features, or architecture changes.
58
- - Read `docs/api-contract.md` only when API, CLI, firmware endpoint, web flow, event, or library contract behavior is in scope.
59
- - Read `docs/database-schema.md` only when persistence, migrations, data shape, or query behavior is in scope.
60
- - Read `docs/DESIGN.md` and `docs/design-intent.json` only for UI, UX, frontend, layout, component, or visual work.
61
- - Add `docs/prd.md` only when there is product-roadmap, user-story, metrics, product-owner, or feature-flag ownership that would otherwise bloat the project brief.
62
- - Add `docs/srs.md` only for contractual, regulated, multi-stakeholder, or acceptance-criteria-heavy projects. Do not create both PRD and SRS unless those owners and purposes are distinct.
63
- - Add `docs/technical-design.md` only for non-trivial architecture decisions, major refactors, cross-cutting behavior, or system interactions that outgrow the ADR and flow overview.
64
- - Keep ERD inside `docs/database-schema.md` for small and medium schemas. Add a separate ERD file only when relationship complexity makes the schema doc hard to scan.
65
-
66
- ## Rules as Guardian (Cross-Session Consistency)
67
-
68
- - Session handoff must include active architecture contract summary.
69
- - Contract summary must include explicit user constraints, runtime/architecture decision status, active project docs, and the core patterns currently evidenced by the repo.
70
- - Detect drift before changing runtime choices, topology, public contracts, or core patterns.
71
- - Direction changes require explicit user confirmation before applying changes.
72
- - When confirmation is provided, record the rationale in session notes or PR context.
73
-
74
- ## Invisible State Management with Explain-on-Demand
75
-
76
- - Default responses must avoid unnecessary state-file internals.
77
- - State internals are exposed only on explicit user request.
78
- - Diagnostic mode explains relevant state decisions when needed.
79
- - Keep default explanations concise and outcome-first.
80
-
81
- ## Single Source of Truth and Lazy Rule Loading
82
-
83
- - Canonical rule source is AGENTS.md.
84
- - Native adapter entry files stay thin and must import the canonical source.
85
- - Load global domain rules lazily based on touched scope.
86
- - Do not create or load stack-specific governance adapters as the baseline.
87
- - Runtime or framework evidence can clarify implementation details, but it must not replace the global architecture, security, data, API, error, event, and testing boundaries.
88
- - Keep rule-loading output deterministic for init and release validation.
89
-
90
- ## Architecture Decision Boundary
91
-
92
- Do not force a default architecture label before the repo, delivery model, and boundary evidence are clear.
93
-
94
- Do not split into distributed services without evidence. Do not keep everything in one process by habit either.
95
-
96
- Service separation only makes sense when multiple signals are true, such as:
97
-
98
- - frequent deploy conflicts across domains
99
- - clear scale mismatch between domains
100
- - separate team ownership causing repeated coupling pain
101
- - hard fault-isolation requirements
102
- - already-stable contracts and data boundaries
103
-
104
- ## Layer Boundaries (Mandatory)
105
-
106
- - Transport or controller layer: parse input, validate shape, enforce auth at the edge, return protocol responses. No business policy, no raw SQL, no external workflow orchestration.
107
- - Application or service layer: business rules, orchestration, transactions, and use-case flow. No request or response objects, no UI formatting, no raw transport dependencies.
108
- - Domain layer: pure business invariants, calculations, value objects, and policies. No framework, network, database, or file-system coupling.
109
- - Infrastructure or repository layer: database, queue, cache, file system, and external API adapters. No business policy hidden in queries or adapters.
110
-
111
- ## Dependency Direction
112
-
113
- - Dependencies flow inward: transport to application to domain.
114
- - Infrastructure depends inward through interfaces or well-defined ports.
115
- - Domain must not depend on infrastructure.
116
- - Application must not depend on transport details.
117
-
118
- ## Project Structure and File Size Discipline
119
-
120
- - Group code by feature or domain, not by one giant technical folder per type.
121
- - Backend feature modules use `src/modules/<feature>/...` when the repo has no stronger existing convention.
122
- - Frontend feature modules use `src/features/<feature>/...` when the repo has no stronger existing convention.
123
- - Cross-cutting utilities belong in explicit shared locations, not scattered feature internals.
124
- - Files above roughly 1000 lines are a refactor trigger, not a success signal.
125
- - Preserve one clear public entrypoint per module when helpful, but move implementation into smaller focused files.
126
- - Keep code compact because the design is understood, not because safeguards were removed.
127
-
128
- ## Module Communication
129
-
130
- - Import through a module's public API instead of reaching into internal files.
131
- - Keep contracts explicit at boundaries between modules.
132
- - If a new developer cannot find the full flow of a feature in one clear area, the structure is too diffuse.
60
+ 5. Required docs coverage must include a public and developer README entrypoint, feature plan, architecture rationale, public contracts, data model when relevant, UI/design when relevant, security assumptions, testing strategy, delivery flow, and next validation actions.
61
+ 6. If required project context docs are missing, stop implementation and bootstrap docs before writing application code.
62
+ 7. Bootstrap flow: analyze the real repo plus the latest user prompt before authoring those docs.
63
+ 8. Bootstrap docs must be adaptive and project-specific. Do not create generic placeholder templates.
64
+ 9. When context is incomplete, separate confirmed facts from assumptions, add an `Assumptions to Validate` section, and end with the next validation action.
65
+ 10. Keep docs current with project changes. Update README and the matching docs whenever setup, runtime, architecture, public contracts, data shape, UI scope, deployment, or validation flow changes.
66
+ 11. Control docs file count. Keep the baseline compact, then add topic files only when a subject is stable, too long for README/core docs, or belongs to a distinct workflow such as hardware setup, deployment, testing validation, operations, or troubleshooting.
67
+
68
+ ## ARCH-004: Documentation Read Routing and Conditional Specs
69
+
70
+ 1. Use `README.md` for human orientation, then use `docs/doc-index.md` to choose the smallest relevant read set.
71
+ 2. Do not broad-read every Markdown file in `docs/` by default.
72
+ 3. Read `docs/project-brief.md`, `docs/architecture-decision-record.md`, and `docs/flow-overview.md` for broad planning, new features, or architecture changes.
73
+ 4. Read `docs/api-contract.md` only when API, CLI, firmware endpoint, web flow, event, or library contract behavior is in scope.
74
+ 5. Read `docs/database-schema.md` only when persistence, migrations, data shape, or query behavior is in scope.
75
+ 6. Read `docs/DESIGN.md` and `docs/design-intent.json` only for UI, UX, frontend, layout, component, or visual work.
76
+ 7. Add `docs/prd.md` only when there is product-roadmap, user-story, metrics, product-owner, or feature-flag ownership that would otherwise bloat the project brief.
77
+ 8. Add `docs/srs.md` only for contractual, regulated, multi-stakeholder, or acceptance-criteria-heavy projects. Do not create both PRD and SRS unless those owners and purposes are distinct.
78
+ 9. Add `docs/technical-design.md` only for non-trivial architecture decisions, major refactors, cross-cutting behavior, or system interactions that outgrow the ADR and flow overview.
79
+ 10. Keep ERD inside `docs/database-schema.md` for small and medium schemas. Add a separate ERD file only when relationship complexity makes the schema doc hard to scan.
80
+
81
+ ## ARCH-005: Rules as Guardian (Cross-Session Consistency)
82
+
83
+ 1. Session handoff must include active architecture contract summary.
84
+ 2. Contract summary must include explicit user constraints, runtime/architecture decision status, active project docs, and the core patterns currently evidenced by the repo.
85
+ 3. Detect drift before changing runtime choices, topology, public contracts, or core patterns.
86
+ 4. Direction changes require explicit user confirmation before applying changes.
87
+ 5. When confirmation is provided, record the rationale in session notes or PR context.
88
+
89
+ ## ARCH-006: Invisible State Management with Explain-on-Demand
90
+
91
+ 1. Default responses must avoid unnecessary state-file internals.
92
+ 2. State internals are exposed only on explicit user request.
93
+ 3. Diagnostic mode explains relevant state decisions when needed.
94
+ 4. Keep default explanations concise and outcome-first.
95
+
96
+ ## ARCH-007: Single Source of Truth and Lazy Rule Loading
97
+
98
+ 1. Canonical rule source is AGENTS.md.
99
+ 2. Native adapter entry files stay thin and must import the canonical source.
100
+ 3. Load global domain rules lazily based on touched scope.
101
+ 4. Do not create or load stack-specific governance adapters as the baseline.
102
+ 5. Runtime or framework evidence can clarify implementation details, but it must not replace the global architecture, security, data, API, error, event, and testing boundaries.
103
+ 6. Keep rule-loading output deterministic for init and release validation.
104
+
105
+ ## ARCH-008: Architecture Decision Boundary
106
+
107
+ 1. Do not force a default architecture label before the repo, delivery model, and boundary evidence are clear.
108
+ 2. Do not split into distributed services without evidence.
109
+ 3. Do not keep everything in one process by habit either.
110
+ 4. Service separation only makes sense when multiple signals are true, such as:
111
+ 5. frequent deploy conflicts across domains
112
+ 6. clear scale mismatch between domains
113
+ 7. separate team ownership causing repeated coupling pain
114
+ 8. hard fault-isolation requirements
115
+ 9. already-stable contracts and data boundaries
116
+
117
+ ## ARCH-009: Layer Boundaries (Mandatory)
118
+
119
+ 1. Transport or controller layer: parse input, validate shape, enforce auth at the edge, return protocol responses. No business policy, no raw SQL, no external workflow orchestration.
120
+ 2. Application or service layer: business rules, orchestration, transactions, and use-case flow. No request or response objects, no UI formatting, no raw transport dependencies.
121
+ 3. Domain layer: pure business invariants, calculations, value objects, and policies. No framework, network, database, or file-system coupling.
122
+ 4. Infrastructure or repository layer: database, queue, cache, file system, and external API adapters. No business policy hidden in queries or adapters.
123
+
124
+ ## ARCH-010: Dependency Direction
125
+
126
+ 1. Dependencies flow inward: transport to application to domain.
127
+ 2. Infrastructure depends inward through interfaces or well-defined ports.
128
+ 3. Domain must not depend on infrastructure.
129
+ 4. Application must not depend on transport details.
130
+
131
+ ## ARCH-011: Project Structure and File Size Discipline
132
+
133
+ 1. Group code by feature or domain, not by one giant technical folder per type.
134
+ 2. Backend feature modules use `src/modules/<feature>/...` when the repo has no stronger existing convention.
135
+ 3. Frontend feature modules use `src/features/<feature>/...` when the repo has no stronger existing convention.
136
+ 4. Cross-cutting utilities belong in explicit shared locations, not scattered feature internals.
137
+ 5. Files above roughly 1000 lines are a refactor trigger, not a success signal.
138
+ 6. Preserve one clear public entrypoint per module when helpful, but move implementation into smaller focused files.
139
+ 7. Keep code compact because the design is understood, not because safeguards were removed.
140
+
141
+ ## ARCH-012: Module Communication
142
+
143
+ 1. Import through a module's public API instead of reaching into internal files.
144
+ 2. Keep contracts explicit at boundaries between modules.
145
+ 3. If a new developer cannot find the full flow of a feature in one clear area, the structure is too diffuse.
@@ -1,24 +1,42 @@
1
+ ---
2
+ id_prefix: DATA
3
+ domain: database-design
4
+ priority: high
5
+ scope: data
6
+ applies_to:
7
+ - backend
8
+ - fullstack
9
+ keywords:
10
+ - database-design
11
+ - data
12
+ - design
13
+ - boundary
14
+ - reject
15
+ - these
16
+ ---
17
+
1
18
  # Data Design Boundary
2
19
 
3
20
  Use the data store, ORM, migration tool, and query style already chosen by the project. If unresolved, the LLM must recommend a current fit from requirements, repo evidence, and official docs before implementation.
4
21
 
5
- Reject these bad habits:
6
- - schema changes without a migration, rollback or recovery note, and data-safety plan
7
- - duplicated facts or derived values without a sync strategy and rationale
8
- - unbounded reads or missing pagination on growable datasets
9
- - missing indexes or access-path planning for frequent filters, joins, lookups, search, or ordering
10
- - raw query construction that bypasses safe parameterization
11
- - destructive data changes without backup, migration, or deployment sequencing notes
22
+ ## DATA-001: Reject these bad habits
23
+
24
+ 1. schema changes without a migration, rollback or recovery note, and data-safety plan
25
+ 2. duplicated facts or derived values without a sync strategy and rationale
26
+ 3. unbounded reads or missing pagination on growable datasets
27
+ 4. missing indexes or access-path planning for frequent filters, joins, lookups, search, or ordering
28
+ 5. raw query construction that bypasses safe parameterization
29
+ 6. destructive data changes without backup, migration, or deployment sequencing notes
12
30
 
13
- Backend data access rules:
14
- - Relational reads must avoid N+1 query patterns. Use eager loading, joins, batching, or explicit query-shape rationale based on the project's ORM or database driver.
15
- - List endpoints and exports must paginate, limit, stream, or otherwise bound growable datasets by default.
16
- - Use cursor pagination for large or frequently changing datasets when the project contract allows it; offset pagination is acceptable for small, stable, explicitly bounded collections.
17
- - Define maximum page size, payload size, and export limits so list responses cannot exhaust memory or connection pools.
18
- - Mutations that write more than one table, aggregate, queue, or external consistency boundary must run inside a transaction or document the compensating recovery path.
19
- - Repository and data-access layers own persistence mechanics. They must not hide business policy that belongs in application or domain logic.
20
- - Index design follows read patterns, not column lists. Prefer composite indexes with selectivity-correct column order (equality before range), partial indexes for soft-delete or status-filtered tables, and covering indexes when a hot read can be satisfied without a heap fetch. Record the read pattern that justifies each non-trivial index.
21
- - Record explicit decisions for delete semantics (hard delete, soft delete, append-only audit), tenant isolation (none, row-level with `tenant_id` plus row-level security, schema-per-tenant), and normalize-vs-denormalize trade-off for read-heavy or sparse data. Default to the simplest fit, but make the choice explicit in data docs rather than letting it become a side effect of the first migration.
22
- - Cross-domain persistence must respect ownership boundaries. Independent services must not share database tables as an integration contract; modular monoliths may share one database only when module ownership and access paths stay explicit.
31
+ ## DATA-002: Backend data access rules
23
32
 
24
- Docs must record entity ownership, relationships, constraints, data lifecycle, migration risk, and assumptions to validate.
33
+ 1. Relational reads must avoid N+1 query patterns. Use eager loading, joins, batching, or explicit query-shape rationale based on the project's ORM or database driver.
34
+ 2. List endpoints and exports must paginate, limit, stream, or otherwise bound growable datasets by default.
35
+ 3. Use cursor pagination for large or frequently changing datasets when the project contract allows it; offset pagination is acceptable for small, stable, explicitly bounded collections.
36
+ 4. Define maximum page size, payload size, and export limits so list responses cannot exhaust memory or connection pools.
37
+ 5. Mutations that write more than one table, aggregate, queue, or external consistency boundary must run inside a transaction or document the compensating recovery path.
38
+ 6. Repository and data-access layers own persistence mechanics. They must not hide business policy that belongs in application or domain logic.
39
+ 7. Index design follows read patterns, not column lists. Prefer composite indexes with selectivity-correct column order (equality before range), partial indexes for soft-delete or status-filtered tables, and covering indexes when a hot read can be satisfied without a heap fetch. Record the read pattern that justifies each non-trivial index.
40
+ 8. Record explicit decisions for delete semantics (hard delete, soft delete, append-only audit), tenant isolation (none, row-level with `tenant_id` plus row-level security, schema-per-tenant), and normalize-vs-denormalize trade-off for read-heavy or sparse data. Default to the simplest fit, but make the choice explicit in data docs rather than letting it become a side effect of the first migration.
41
+ 9. Cross-domain persistence must respect ownership boundaries. Independent services must not share database tables as an integration contract; modular monoliths may share one database only when module ownership and access paths stay explicit.
42
+ 10. Docs must record entity ownership, relationships, constraints, data lifecycle, migration risk, and assumptions to validate.