serenecode 0.3.0__tar.gz → 0.4.0__tar.gz

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 (141) hide show
  1. serenecode-0.4.0/AGENTS.md +76 -0
  2. {serenecode-0.3.0 → serenecode-0.4.0}/CLAUDE.md +11 -5
  3. serenecode-0.4.0/FEATURE_SPEC.md +222 -0
  4. serenecode-0.4.0/IMPLEMENTATION_PLAN.md +395 -0
  5. {serenecode-0.3.0 → serenecode-0.4.0}/PKG-INFO +66 -35
  6. {serenecode-0.3.0 → serenecode-0.4.0}/README.md +64 -34
  7. {serenecode-0.3.0 → serenecode-0.4.0}/SERENECODE.md +52 -2
  8. serenecode-0.4.0/docs/SECURITY.md +37 -0
  9. serenecode-0.4.0/docs/VERIFICATION_LEVELS.md +29 -0
  10. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/CLAUDE.md +7 -5
  11. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/SERENECODE.md +64 -5
  12. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/SPEC.md +2 -0
  13. {serenecode-0.3.0 → serenecode-0.4.0}/pyproject.toml +2 -1
  14. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/__init__.py +57 -1
  15. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/__init__.py +17 -0
  16. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/hypothesis_adapter.py +210 -15
  17. serenecode-0.4.0/src/serenecode/adapters/unavailable_dead_code_adapter.py +44 -0
  18. serenecode-0.4.0/src/serenecode/adapters/vulture_adapter.py +105 -0
  19. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/compositional.py +341 -1
  20. serenecode-0.4.0/src/serenecode/checker/spec_traceability.py +968 -0
  21. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/cli.py +261 -32
  22. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/contracts/predicates.py +33 -3
  23. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/core/pipeline.py +146 -6
  24. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/init.py +117 -68
  25. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/mcp/resources.py +38 -5
  26. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/mcp/schemas.py +18 -3
  27. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/mcp/server.py +63 -14
  28. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/mcp/tools.py +398 -65
  29. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/models.py +36 -7
  30. serenecode-0.4.0/src/serenecode/ports/dead_code_analyzer.py +82 -0
  31. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/reporter.py +51 -7
  32. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/source_discovery.py +104 -2
  33. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/templates/content.py +80 -13
  34. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_check_command.py +3 -0
  35. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_cli_branches.py +7 -2
  36. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_init_command.py +27 -0
  37. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_example_projects.py +19 -5
  38. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_hypothesis_adapter.py +49 -0
  39. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_hypothesis_adapter_helpers.py +19 -1
  40. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_resources.py +25 -0
  41. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_schemas.py +36 -1
  42. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_tools.py +132 -0
  43. serenecode-0.4.0/tests/integration/test_unavailable_dead_code_adapter.py +16 -0
  44. serenecode-0.4.0/tests/integration/test_vulture_adapter.py +39 -0
  45. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_compositional_helpers.py +48 -0
  46. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_spec_traceability.py +48 -1
  47. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/contracts/test_predicates.py +2 -2
  48. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_models.py +4 -1
  49. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_reporter.py +49 -2
  50. {serenecode-0.3.0 → serenecode-0.4.0}/uv.lock +15 -1
  51. serenecode-0.3.0/src/serenecode/checker/spec_traceability.py +0 -490
  52. {serenecode-0.3.0 → serenecode-0.4.0}/.gitignore +0 -0
  53. {serenecode-0.3.0 → serenecode-0.4.0}/LICENSE +0 -0
  54. {serenecode-0.3.0 → serenecode-0.4.0}/examples/DOSAGE_CALC_SPEC.md +0 -0
  55. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-regular/dosage_calc.py +0 -0
  56. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-regular/test_dosage_calc.py +0 -0
  57. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/pyproject.toml +0 -0
  58. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/src/dosage/__init__.py +0 -0
  59. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/src/dosage/core/__init__.py +0 -0
  60. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/src/dosage/core/dosage.py +0 -0
  61. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/src/dosage/core/models.py +0 -0
  62. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/src/dosage/core/safety.py +0 -0
  63. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/tests/__init__.py +0 -0
  64. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/tests/unit/__init__.py +0 -0
  65. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/tests/unit/test_dosage.py +0 -0
  66. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/tests/unit/test_models.py +0 -0
  67. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/tests/unit/test_safety.py +0 -0
  68. {serenecode-0.3.0 → serenecode-0.4.0}/examples/dosage-serenecode/uv.lock +0 -0
  69. {serenecode-0.3.0 → serenecode-0.4.0}/serenecode.jpg +0 -0
  70. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/coverage_adapter.py +0 -0
  71. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/crosshair_adapter.py +0 -0
  72. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/local_fs.py +0 -0
  73. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/module_loader.py +0 -0
  74. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/adapters/mypy_adapter.py +0 -0
  75. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/__init__.py +0 -0
  76. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/coverage.py +0 -0
  77. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/properties.py +0 -0
  78. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/structural.py +0 -0
  79. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/symbolic.py +0 -0
  80. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/checker/types.py +0 -0
  81. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/config.py +0 -0
  82. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/contracts/__init__.py +0 -0
  83. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/core/__init__.py +0 -0
  84. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/core/exceptions.py +0 -0
  85. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/mcp/__init__.py +0 -0
  86. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/ports/__init__.py +0 -0
  87. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/ports/coverage_analyzer.py +0 -0
  88. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/ports/file_system.py +0 -0
  89. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/ports/property_tester.py +0 -0
  90. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/ports/symbolic_checker.py +0 -0
  91. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/ports/type_checker.py +0 -0
  92. {serenecode-0.3.0 → serenecode-0.4.0}/src/serenecode/templates/__init__.py +0 -0
  93. {serenecode-0.3.0 → serenecode-0.4.0}/tests/__init__.py +0 -0
  94. {serenecode-0.3.0 → serenecode-0.4.0}/tests/conftest.py +0 -0
  95. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/__init__.py +0 -0
  96. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_cli.py +0 -0
  97. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_init.py +0 -0
  98. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_mcp_command.py +0 -0
  99. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_report_command.py +0 -0
  100. {serenecode-0.3.0 → serenecode-0.4.0}/tests/e2e/test_status_command.py +0 -0
  101. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/edge_cases/aliased_import.py +0 -0
  102. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/edge_cases/async_functions.py +0 -0
  103. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/edge_cases/empty_module.py +0 -0
  104. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/edge_cases/from_import.py +0 -0
  105. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/invalid/broken_postcondition.py +0 -0
  106. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/invalid/io_in_core.py +0 -0
  107. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/invalid/missing_contracts.py +0 -0
  108. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/invalid/missing_invariant.py +0 -0
  109. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/invalid/missing_types.py +0 -0
  110. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/valid/class_with_invariant.py +0 -0
  111. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/valid/full_module.py +0 -0
  112. {serenecode-0.3.0 → serenecode-0.4.0}/tests/fixtures/valid/simple_function.py +0 -0
  113. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/__init__.py +0 -0
  114. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_adapter_internals.py +0 -0
  115. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_checkers_real_code.py +0 -0
  116. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_coverage_adapter.py +0 -0
  117. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_crosshair_adapter.py +0 -0
  118. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_crosshair_adapter_helpers.py +0 -0
  119. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_file_adapter.py +0 -0
  120. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_local_fs.py +0 -0
  121. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_module_loader.py +0 -0
  122. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_mypy_adapter.py +0 -0
  123. {serenecode-0.3.0 → serenecode-0.4.0}/tests/integration/test_server.py +0 -0
  124. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/__init__.py +0 -0
  125. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/__init__.py +0 -0
  126. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_compositional.py +0 -0
  127. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_coverage.py +0 -0
  128. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_properties.py +0 -0
  129. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_structural.py +0 -0
  130. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_structural_helpers.py +0 -0
  131. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_structural_hypothesis.py +0 -0
  132. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_symbolic.py +0 -0
  133. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/checker/test_types.py +0 -0
  134. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/contracts/__init__.py +0 -0
  135. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/contracts/test_predicates_hypothesis.py +0 -0
  136. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_api.py +0 -0
  137. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_config.py +0 -0
  138. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_models_hypothesis.py +0 -0
  139. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_pipeline.py +0 -0
  140. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_source_discovery.py +0 -0
  141. {serenecode-0.3.0 → serenecode-0.4.0}/tests/unit/test_templates_content.py +0 -0
@@ -0,0 +1,76 @@
1
+ ## Serenecode
2
+
3
+ All code in this project MUST follow the standards defined in SERENECODE.md. Read SERENECODE.md before writing or modifying any code. Every public function must have icontract preconditions and postconditions. Every class with state must have invariants. Follow the architectural patterns specified in SERENECODE.md.
4
+
5
+ Pre-existing `*_SPEC.md` or PRD files are narrative inputs; only project-root `SPEC.md` with REQ/INT identifiers satisfies SereneCode traceability (`serenecode check --spec`).
6
+
7
+ ### Verification (prefer MCP while editing)
8
+
9
+ After each work iteration (implementing a feature, fixing a bug, refactoring), run verification before considering the task complete.
10
+
11
+ **Preferred — MCP tools in the IDE (per-symbol, fast feedback):** use **`serenecode_check_function`** (or `serenecode_check_file`) on the code you just changed. Prefer this over shell `serenecode check` during active editing. Reserve **`serenecode_check`** for whole-tree / CI-style runs. If MCP wiring is unclear, run `serenecode doctor` for install and registration hints.
12
+
13
+ **CLI — batch / CI (when not using MCP for this step):**
14
+
15
+ Quick structural check (seconds):
16
+ ```bash
17
+ serenecode check src/ --structural
18
+ ```
19
+
20
+ Full verification with coverage and property testing (minutes):
21
+ ```bash
22
+ serenecode check src/ --level 4 --allow-code-execution
23
+ ```
24
+
25
+ Full verification including symbolic and compositional (minutes):
26
+ ```bash
27
+ serenecode check src/ --level 6 --allow-code-execution
28
+ ```
29
+
30
+ ### Reading Verification Output
31
+
32
+ Each finding includes function name, file path, line number, a message, and a suggestion. The output summary uses four statuses:
33
+
34
+ - **passed** — verified at the requested level.
35
+ - **failed** — a violation was found. Read the message and suggestion to fix it.
36
+ - **skipped** — the tool could not run (e.g. tool not installed, module not importable). Investigate why.
37
+ - **exempt** — intentionally excluded from this check level (adapter code, Protocol classes, functions with non-primitive parameters). No action needed unless the function should be verified.
38
+
39
+ ### Fixing Failures by Level
40
+
41
+ **Level 1 (structural)** — Missing contracts or annotations. The suggestion names the specific parameters or return type. Add the missing decorator.
42
+
43
+ **Level 2 (types)** — mypy type errors. The suggestion includes the mypy error code and a fix direction. Fix the type annotation or the expression.
44
+
45
+ **Level 3 (coverage)** — Test coverage is below threshold. The output shows:
46
+ - Which functions have insufficient coverage and their exact uncovered lines
47
+ - Suggested test code for each uncovered path
48
+ - Mock assessment: each dependency is classified as REQUIRED (external I/O — must mock) or OPTIONAL (internal code — consider using the real implementation)
49
+ - If "no tests found", write tests first. Coverage analysis measures existing test quality.
50
+
51
+ **Level 4 (properties)** — Hypothesis found inputs that violate a postcondition. The counterexample shows the exact failing inputs (e.g. `x=-1, result=-2`). Either:
52
+ 1. Fix the implementation so the postcondition holds for these inputs, OR
53
+ 2. Add a `@icontract.require` precondition to exclude these inputs if they are not valid.
54
+
55
+ **Level 5 (symbolic)** — CrossHair found a counterexample via symbolic execution. Same fix pattern as Level 4, but the counterexample comes from the solver rather than random testing.
56
+
57
+ **Level 6 (compositional)** — Cross-module architectural violations. Fix the dependency direction, add missing contracts at module boundaries, or correct interface mismatches.
58
+
59
+ ### Writing Contracts
60
+
61
+ When adding contracts, write meaningful conditions that constrain behavior:
62
+
63
+ ```python
64
+ # GOOD — constrains real behavior
65
+ @icontract.require(lambda items: len(items) > 0, "items must not be empty")
66
+ @icontract.ensure(lambda items, result: min(items) <= result <= max(items), "result within range")
67
+
68
+ # BAD — tautological, verifies nothing
69
+ @icontract.ensure(lambda result: True, "always passes")
70
+ ```
71
+
72
+ Protocol classes and stateless adapters do not need `@icontract.invariant`. Add `# no-invariant: <reason>` above the class definition if the class has no state to constrain.
73
+
74
+ ### Verification Scope
75
+
76
+ The output shows what was and wasn't checked. Exempt items (adapters, ports, non-primitive signatures) are visible in the output — not silently omitted. If verification fails, read the error messages and fix the issues. Iterate until all checks pass.
@@ -2,21 +2,27 @@
2
2
 
3
3
  All code in this project MUST follow the standards defined in SERENECODE.md. Read SERENECODE.md before writing or modifying any code. Every public function must have icontract preconditions and postconditions. Every class with state must have invariants. Follow the architectural patterns specified in SERENECODE.md.
4
4
 
5
- ### Verification Commands
5
+ Pre-existing `*_SPEC.md` or PRD files are narrative inputs; only project-root `SPEC.md` with REQ/INT identifiers satisfies SereneCode traceability (`serenecode check --spec`).
6
6
 
7
- After each work iteration (implementing a feature, fixing a bug, refactoring), offer to run verification before considering the task complete.
7
+ ### Verification (prefer MCP while editing)
8
8
 
9
- **Quick structural check (seconds):**
9
+ After each work iteration (implementing a feature, fixing a bug, refactoring), run verification before considering the task complete.
10
+
11
+ **Preferred — MCP tools in the IDE (per-symbol, fast feedback):** use **`serenecode_check_function`** (or `serenecode_check_file`) on the code you just changed. Prefer this over shell `serenecode check` during active editing. Reserve **`serenecode_check`** for whole-tree / CI-style runs. If MCP wiring is unclear, run `serenecode doctor` for install and registration hints.
12
+
13
+ **CLI — batch / CI (when not using MCP for this step):**
14
+
15
+ Quick structural check (seconds):
10
16
  ```bash
11
17
  serenecode check src/ --structural
12
18
  ```
13
19
 
14
- **Full verification with coverage and property testing (minutes):**
20
+ Full verification with coverage and property testing (minutes):
15
21
  ```bash
16
22
  serenecode check src/ --level 4 --allow-code-execution
17
23
  ```
18
24
 
19
- **Full verification including symbolic and compositional (minutes):**
25
+ Full verification including symbolic and compositional (minutes):
20
26
  ```bash
21
27
  serenecode check src/ --level 6 --allow-code-execution
22
28
  ```
@@ -0,0 +1,222 @@
1
+ # SereneCode Feature Spec — Integration Traceability and Dead Code Review
2
+
3
+ **Purpose:** Extend SereneCode so it can detect integration gaps that AI coding agents often miss, and so it can surface likely dead code for explicit user review instead of letting it silently accumulate.
4
+
5
+ This spec intentionally uses the current `REQ-xxx` format so it can be validated by today's SereneCode tooling. The feature described here adds a second traceability namespace, `INT-xxx`, for integration points.
6
+
7
+ ---
8
+
9
+ ## Integration Point Specification
10
+
11
+ ### REQ-001: Existing REQ-only specs remain valid
12
+
13
+ SereneCode must continue to accept and validate existing specs that contain only `REQ-xxx` entries. Projects that do not use integration-point tracking must not be forced to add `INT-xxx` entries, new metadata fields, or new code/test tags.
14
+
15
+ ### REQ-002: Specs may declare integration-point identifiers
16
+
17
+ A spec may declare integration points using identifiers in the form `INT-001`, `INT-002`, and so on. `INT-xxx` identifiers represent expected interactions between components, modules, classes, or functions that are important enough to track explicitly.
18
+
19
+ ### REQ-003: Every integration point has a structured declaration
20
+
21
+ Each `INT-xxx` entry in the spec must include:
22
+
23
+ - A short heading description.
24
+ - A `Kind` field.
25
+ - A `Source` field naming the initiating component, class, or function.
26
+ - A `Target` field naming the depended-on component, class, or function.
27
+
28
+ If any of these fields are missing, the integration point is invalid and must be reported as a spec-level failure.
29
+
30
+ ### REQ-004: Integration identifiers are unique and sequential
31
+
32
+ Within a spec, `INT-xxx` identifiers must be unique and sequential with no numbering gaps, using the same zero-padded numbering style already used for `REQ-xxx` identifiers.
33
+
34
+ ### REQ-005: Supported integration kinds are explicit and finite
35
+
36
+ The initial supported integration kinds are:
37
+
38
+ - `call`: one implementation element must call or invoke another.
39
+ - `implements`: a class must implement or remain substitutable for an interface or protocol.
40
+
41
+ If a spec declares an unsupported `Kind`, SereneCode must report that integration point as invalid rather than silently ignoring it.
42
+
43
+ ### REQ-006: Integration points may reference behavioral requirements
44
+
45
+ An `INT-xxx` entry may include a `Supports` field listing one or more `REQ-xxx` identifiers. This expresses that the integration point exists in service of those behavioral requirements. Invalid or orphaned `REQ-xxx` references in `Supports` must be reported.
46
+
47
+ ---
48
+
49
+ ## Integration Traceability
50
+
51
+ ### REQ-007: Implementation tags may reference both REQ and INT identifiers
52
+
53
+ Code docstrings may reference both behavioral requirements and integration points in the existing `Implements:` tag. A single implementation element may implement multiple `REQ-xxx` identifiers, multiple `INT-xxx` identifiers, or a mixture of both.
54
+
55
+ ### REQ-008: Test tags may reference both REQ and INT identifiers
56
+
57
+ Test docstrings may reference both behavioral requirements and integration points in the existing `Verifies:` tag. A single test may verify multiple `REQ-xxx` identifiers, multiple `INT-xxx` identifiers, or a mixture of both.
58
+
59
+ ### REQ-009: Every integration point must be implemented and tested
60
+
61
+ For every `INT-xxx` entry in the spec, SereneCode must verify that at least one implementation location references it through `Implements:` and at least one test location references it through `Verifies:`.
62
+
63
+ ### REQ-010: Orphan integration references are failures
64
+
65
+ If code or tests reference an `INT-xxx` identifier that is not declared in the spec, SereneCode must report an orphan-reference failure and point to the first detected location.
66
+
67
+ ### REQ-011: Traceability output distinguishes integration coverage states
68
+
69
+ When reporting integration status, SereneCode must distinguish at least these states:
70
+
71
+ - implemented and tested
72
+ - implemented but untested
73
+ - tested but not implemented
74
+ - neither implemented nor tested
75
+ - orphan reference
76
+
77
+ The output must identify the relevant integration identifier and at least one concrete code or test location for the finding.
78
+
79
+ ---
80
+
81
+ ## Semantic Integration Verification
82
+
83
+ ### REQ-012: Call integrations are checked semantically
84
+
85
+ For an integration point whose `Kind` is `call`, SereneCode must do more than validate tags. It must analyze the implementation locations referenced by `Implements:` and fail the integration if no statically detectable call, invocation, or resolved cross-module reference from the declared `Source` to the declared `Target` exists.
86
+
87
+ ### REQ-013: Interface integrations are checked semantically
88
+
89
+ For an integration point whose `Kind` is `implements`, SereneCode must verify that the declared implementing class explicitly implements, inherits from, or remains substitutable for the declared target interface or protocol. Signature incompatibilities must be reported as integration failures.
90
+
91
+ ### REQ-014: Missing tags and broken semantics are reported separately
92
+
93
+ SereneCode must distinguish between:
94
+
95
+ - a traceability failure, where an `INT-xxx` entry is missing `Implements:` or `Verifies:` references, and
96
+ - a semantic integration failure, where the references exist but the declared integration is not actually present or is incompatible.
97
+
98
+ The output must make this distinction explicit so the user and coding agent can tell whether the problem is documentation drift or an actual implementation bug.
99
+
100
+ ### REQ-015: Integration status is available through reporting and MCP surfaces
101
+
102
+ The human-readable report, JSON output, and relevant MCP status tools must surface integration-point findings and locations in the same way they already surface requirement traceability findings, so an AI coding agent can inspect and act on them without parsing free-form prose.
103
+
104
+ ---
105
+
106
+ ## Dead Code Review
107
+
108
+ ### REQ-016: SereneCode reports likely dead code in project source
109
+
110
+ SereneCode must analyze project source for likely unused code, including unused functions, classes, methods, variables, or imports when the underlying analyzer can identify them. Findings must identify the symbol, file, and line number.
111
+
112
+ ### REQ-017: Dead code findings require explicit disposition
113
+
114
+ When SereneCode reports likely dead code, the finding message or suggestion must instruct the coding agent to ask the user whether the code should be removed or explicitly allowlisted. SereneCode must not present likely dead code as something the agent should automatically delete without user confirmation.
115
+
116
+ ### REQ-018: Dead code findings are suppressible with explicit allowlisting
117
+
118
+ SereneCode must support an explicit suppression mechanism for legitimate false positives or framework-required entry points. Once a symbol is allowlisted, future runs must not continue to report it as dead code unless the allowlist entry is removed.
119
+
120
+ ### REQ-019: Dead code analysis failures are visible
121
+
122
+ If dead code analysis cannot run because its backend is unavailable, misconfigured, or crashes, SereneCode must report that state as a visible skipped finding instead of silently omitting dead code analysis.
123
+
124
+ ### REQ-020: Dead code analysis does not silently examine tests as product dead code
125
+
126
+ By default, dead code findings intended to drive removal decisions must apply to shipped project source rather than test-only helpers. If test files are analyzed at all, their findings must be clearly distinguished from product-code findings.
127
+
128
+ ---
129
+
130
+ ## Cross-Level Applicability
131
+
132
+ ### REQ-021: Integration traceability applies to every verification level
133
+
134
+ Integration-point validation and traceability must be part of every SereneCode verification run, regardless of whether the requested maximum verification level is 1, 2, 3, 4, 5, or 6. A request for a deeper level must not skip or suppress integration-point findings that would have been reported in a shallower run.
135
+
136
+ ### REQ-022: Dead-code review applies to every verification level
137
+
138
+ Dead-code analysis and its user-review guidance must be part of every SereneCode verification run, regardless of whether the requested maximum verification level is 1, 2, 3, 4, 5, or 6. A request for a deeper level must not skip or suppress dead-code findings that would have been reported in a shallower run.
139
+
140
+ ### REQ-023: Higher levels may strengthen evidence but not remove baseline checks
141
+
142
+ Higher verification levels may add stronger evidence for declared integrations, including deeper compositional checks at higher levels, but the baseline integration-traceability and dead-code checks must remain present at all levels. User-facing reporting must make it clear which findings are baseline structural/static findings and which findings come from deeper verification.
143
+
144
+ ---
145
+
146
+ ## Generated Guidance and Documentation
147
+
148
+ ### REQ-024: Every generated SERENECODE.md variant documents integration points
149
+
150
+ Every generated `SERENECODE.md` variant that includes spec traceability guidance, including the `default`, `strict`, and `minimal` templates, must explain:
151
+
152
+ - that specs may include `INT-xxx` integration-point entries,
153
+ - how to write valid `INT-xxx` entries,
154
+ - how to reference `INT-xxx` identifiers from `Implements:` and `Verifies:` tags, and
155
+ - that integration points must be both traceable and semantically satisfied.
156
+
157
+ ### REQ-025: Every generated SERENECODE.md variant documents dead-code review workflow
158
+
159
+ Every generated `SERENECODE.md` variant must instruct coding agents and human contributors that likely dead code findings are advisory review items. The guidance must say that the coding agent should ask the user whether the code should be removed or allowlisted before deleting it.
160
+
161
+ ### REQ-026: Shipped SERENECODE guidance stays aligned with behavior
162
+
163
+ The repository's own `SERENECODE.md`, the template generator, and any shipped example `SERENECODE.md` content must remain aligned with the actual feature behavior, terminology, and workflow for integration traceability and dead-code review. The documentation must not claim support that the implementation does not provide.
164
+
165
+ ---
166
+
167
+ ## MCP Tooling
168
+
169
+ ### REQ-027: MCP spec-validation surfaces understand integration points
170
+
171
+ The MCP surface for spec validation must recognize and validate both `REQ-xxx` and `INT-xxx` declarations. Integration-point validation failures must be reported as structured findings rather than embedded only in prose.
172
+
173
+ ### REQ-028: MCP exposes structured integration traceability status
174
+
175
+ The MCP tool surface must let an AI coding agent retrieve structured integration-point status, including:
176
+
177
+ - declared integration identifiers,
178
+ - implementation locations,
179
+ - verification locations, and
180
+ - derived status such as complete, implemented-only, tested-only, missing, or orphaned.
181
+
182
+ This may be provided by extending existing spec-traceability tools or by adding dedicated integration-oriented tools, but the capability must be present.
183
+
184
+ ### REQ-029: MCP exposes structured dead-code findings
185
+
186
+ The MCP tool surface must let an AI coding agent retrieve likely dead-code findings as structured data with symbol name, file, line, confidence or severity information when available, and guidance that user confirmation is required before removal.
187
+
188
+ ### REQ-030: Existing REQ-focused MCP workflows remain backward compatible
189
+
190
+ Existing REQ-focused MCP workflows must continue to function for projects that do not use integration points. Any extensions for `INT-xxx` support must preserve backward compatibility for current tool callers or provide a clearly documented migration path.
191
+
192
+ ---
193
+
194
+ ## README and User-Facing Documentation
195
+
196
+ ### REQ-031: README documents the integration-point workflow
197
+
198
+ `README.md` must document the purpose of `INT-xxx` integration points, how they differ from `REQ-xxx` behavioral requirements, how they are tagged from implementation and tests, and what kinds of failures SereneCode reports when an integration is missing, orphaned, or semantically broken.
199
+
200
+ ### REQ-032: README documents MCP support for integrations and dead code
201
+
202
+ `README.md` must describe the MCP support for integration traceability and dead-code review, including the relevant tool names or tool categories an AI coding agent should use during authoring and verification.
203
+
204
+ ### REQ-033: README documents dead-code review as a user decision
205
+
206
+ `README.md` must explain that likely dead code is reported for review, that false positives are possible, that allowlisting is supported, and that the coding agent should ask the user before removing suspected dead code.
207
+
208
+ ---
209
+
210
+ ## Example Integration Entry Format
211
+
212
+ The intended `INT-xxx` format is illustrated here for clarity:
213
+
214
+ ```markdown
215
+ ### INT-001: Checkout submits payment through the payment gateway
216
+ Kind: call
217
+ Source: CheckoutService.checkout
218
+ Target: PaymentGateway.charge
219
+ Supports: REQ-003, REQ-004
220
+ ```
221
+
222
+ This example is explanatory prose, not a `REQ-xxx` requirement. The behavior SereneCode must implement is defined by the requirements above.