tracelayer 0.1.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 (188) hide show
  1. tracelayer-0.1.0/.gitignore +14 -0
  2. tracelayer-0.1.0/AGENTS.md +25 -0
  3. tracelayer-0.1.0/CONTRIBUTING.md +61 -0
  4. tracelayer-0.1.0/LICENSE +201 -0
  5. tracelayer-0.1.0/PKG-INFO +230 -0
  6. tracelayer-0.1.0/README.md +201 -0
  7. tracelayer-0.1.0/SECURITY.md +54 -0
  8. tracelayer-0.1.0/adapters/claude-code/README.md +61 -0
  9. tracelayer-0.1.0/adapters/claude-code/settings.template.json +70 -0
  10. tracelayer-0.1.0/adapters/codex/README.md +78 -0
  11. tracelayer-0.1.0/adapters/codex/hooks/trace-hook.sh +61 -0
  12. tracelayer-0.1.0/adapters/codex/hooks.json +68 -0
  13. tracelayer-0.1.0/adapters/generic-json-hooks/example-handler.sh +42 -0
  14. tracelayer-0.1.0/adapters/generic-json-hooks/protocol.md +86 -0
  15. tracelayer-0.1.0/adapters/hermes/README.md +78 -0
  16. tracelayer-0.1.0/adapters/hermes/config.snippet.yaml +20 -0
  17. tracelayer-0.1.0/adapters/hermes/hooks/trace-hook.sh +59 -0
  18. tracelayer-0.1.0/adapters/oh-my-pi/README.md +119 -0
  19. tracelayer-0.1.0/adapters/oh-my-pi/hooks.yaml +19 -0
  20. tracelayer-0.1.0/adapters/oh-my-pi/trace-gate.ts +73 -0
  21. tracelayer-0.1.0/adapters/opencode/README.md +44 -0
  22. tracelayer-0.1.0/adapters/opencode/config.template.json +71 -0
  23. tracelayer-0.1.0/adapters/pi/README.md +92 -0
  24. tracelayer-0.1.0/adapters/pi/hooks/trace-hook.sh +65 -0
  25. tracelayer-0.1.0/adapters/pi/hooks.template.json +34 -0
  26. tracelayer-0.1.0/docs/adr/0001-repository-first-canonical-model.md +18 -0
  27. tracelayer-0.1.0/docs/adr/0002-sqlite-materialized-index.md +17 -0
  28. tracelayer-0.1.0/docs/adr/0003-one-line-trace-v1-protocol.md +18 -0
  29. tracelayer-0.1.0/docs/adr/0004-truth-separation.md +18 -0
  30. tracelayer-0.1.0/docs/adr/0005-ast-symbol-attachment.md +18 -0
  31. tracelayer-0.1.0/docs/adr/0006-policy-separate-from-schema.md +19 -0
  32. tracelayer-0.1.0/docs/adr/0007-hooks-are-adapters.md +19 -0
  33. tracelayer-0.1.0/docs/adr/0008-python-uv-implementation.md +19 -0
  34. tracelayer-0.1.0/docs/claude-code.md +90 -0
  35. tracelayer-0.1.0/docs/concepts.md +201 -0
  36. tracelayer-0.1.0/docs/evidence.md +128 -0
  37. tracelayer-0.1.0/docs/hooks.md +208 -0
  38. tracelayer-0.1.0/docs/large-repos.md +88 -0
  39. tracelayer-0.1.0/docs/marker-protocol.md +91 -0
  40. tracelayer-0.1.0/docs/migration-codeops.md +73 -0
  41. tracelayer-0.1.0/docs/policy.md +162 -0
  42. tracelayer-0.1.0/docs/relationships.md +48 -0
  43. tracelayer-0.1.0/docs/security.md +112 -0
  44. tracelayer-0.1.0/pyproject.toml +92 -0
  45. tracelayer-0.1.0/scripts/install-skill.sh +69 -0
  46. tracelayer-0.1.0/scripts/test-with-trace-evidence.sh +18 -0
  47. tracelayer-0.1.0/skills/traceability/README.md +46 -0
  48. tracelayer-0.1.0/skills/traceability/SKILL.md +144 -0
  49. tracelayer-0.1.0/skills/traceability/references/examples.md +167 -0
  50. tracelayer-0.1.0/skills/traceability/references/marker-protocol.md +91 -0
  51. tracelayer-0.1.0/skills/traceability/references/relationship-guide.md +73 -0
  52. tracelayer-0.1.0/src/tracelayer/__init__.py +9 -0
  53. tracelayer-0.1.0/src/tracelayer/artifacts/__init__.py +0 -0
  54. tracelayer-0.1.0/src/tracelayer/artifacts/generic.py +27 -0
  55. tracelayer-0.1.0/src/tracelayer/artifacts/markdown.py +207 -0
  56. tracelayer-0.1.0/src/tracelayer/artifacts/yaml.py +76 -0
  57. tracelayer-0.1.0/src/tracelayer/audit/__init__.py +0 -0
  58. tracelayer-0.1.0/src/tracelayer/audit/auditor.py +246 -0
  59. tracelayer-0.1.0/src/tracelayer/audit/package.py +328 -0
  60. tracelayer-0.1.0/src/tracelayer/audit/schema.py +124 -0
  61. tracelayer-0.1.0/src/tracelayer/cli.py +1179 -0
  62. tracelayer-0.1.0/src/tracelayer/config.py +329 -0
  63. tracelayer-0.1.0/src/tracelayer/diagnostics.py +159 -0
  64. tracelayer-0.1.0/src/tracelayer/discovery/__init__.py +0 -0
  65. tracelayer-0.1.0/src/tracelayer/discovery/files.py +144 -0
  66. tracelayer-0.1.0/src/tracelayer/discovery/ignore.py +87 -0
  67. tracelayer-0.1.0/src/tracelayer/discovery/scopes.py +27 -0
  68. tracelayer-0.1.0/src/tracelayer/doctor.py +268 -0
  69. tracelayer-0.1.0/src/tracelayer/engine.py +1370 -0
  70. tracelayer-0.1.0/src/tracelayer/evidence/__init__.py +0 -0
  71. tracelayer-0.1.0/src/tracelayer/evidence/cobertura.py +58 -0
  72. tracelayer-0.1.0/src/tracelayer/evidence/freshness.py +80 -0
  73. tracelayer-0.1.0/src/tracelayer/evidence/ingest.py +267 -0
  74. tracelayer-0.1.0/src/tracelayer/evidence/junit.py +83 -0
  75. tracelayer-0.1.0/src/tracelayer/evidence/models.py +77 -0
  76. tracelayer-0.1.0/src/tracelayer/evidence/normalized.py +139 -0
  77. tracelayer-0.1.0/src/tracelayer/evidence/per_test.py +102 -0
  78. tracelayer-0.1.0/src/tracelayer/git/__init__.py +0 -0
  79. tracelayer-0.1.0/src/tracelayer/git/diff.py +86 -0
  80. tracelayer-0.1.0/src/tracelayer/git/history.py +67 -0
  81. tracelayer-0.1.0/src/tracelayer/git/repo.py +186 -0
  82. tracelayer-0.1.0/src/tracelayer/graph/fingerprints.py +47 -0
  83. tracelayer-0.1.0/src/tracelayer/graph/migrations.py +95 -0
  84. tracelayer-0.1.0/src/tracelayer/graph/models.py +70 -0
  85. tracelayer-0.1.0/src/tracelayer/graph/store.py +709 -0
  86. tracelayer-0.1.0/src/tracelayer/graph/traverse.py +99 -0
  87. tracelayer-0.1.0/src/tracelayer/hooks/__init__.py +0 -0
  88. tracelayer-0.1.0/src/tracelayer/hooks/common.py +159 -0
  89. tracelayer-0.1.0/src/tracelayer/hooks/post_batch.py +46 -0
  90. tracelayer-0.1.0/src/tracelayer/hooks/post_mutation.py +160 -0
  91. tracelayer-0.1.0/src/tracelayer/hooks/pre_mutation.py +101 -0
  92. tracelayer-0.1.0/src/tracelayer/hooks/prompt_context.py +47 -0
  93. tracelayer-0.1.0/src/tracelayer/hooks/session_start.py +44 -0
  94. tracelayer-0.1.0/src/tracelayer/hooks/session_state.py +100 -0
  95. tracelayer-0.1.0/src/tracelayer/hooks/stop_gate.py +110 -0
  96. tracelayer-0.1.0/src/tracelayer/install.py +254 -0
  97. tracelayer-0.1.0/src/tracelayer/migration/__init__.py +0 -0
  98. tracelayer-0.1.0/src/tracelayer/migration/codeops.py +484 -0
  99. tracelayer-0.1.0/src/tracelayer/migration/scry.py +50 -0
  100. tracelayer-0.1.0/src/tracelayer/policy/__init__.py +0 -0
  101. tracelayer-0.1.0/src/tracelayer/policy/evaluator.py +178 -0
  102. tracelayer-0.1.0/src/tracelayer/policy/models.py +46 -0
  103. tracelayer-0.1.0/src/tracelayer/policy/profiles.py +117 -0
  104. tracelayer-0.1.0/src/tracelayer/policy/rules.py +585 -0
  105. tracelayer-0.1.0/src/tracelayer/protocol/__init__.py +58 -0
  106. tracelayer-0.1.0/src/tracelayer/protocol/grammar.py +157 -0
  107. tracelayer-0.1.0/src/tracelayer/protocol/ids.py +83 -0
  108. tracelayer-0.1.0/src/tracelayer/protocol/marker.py +222 -0
  109. tracelayer-0.1.0/src/tracelayer/protocol/ontology.py +119 -0
  110. tracelayer-0.1.0/src/tracelayer/protocol/schema.py +183 -0
  111. tracelayer-0.1.0/src/tracelayer/query/__init__.py +0 -0
  112. tracelayer-0.1.0/src/tracelayer/query/context.py +181 -0
  113. tracelayer-0.1.0/src/tracelayer/query/impact.py +97 -0
  114. tracelayer-0.1.0/src/tracelayer/query/search.py +17 -0
  115. tracelayer-0.1.0/src/tracelayer/query/why.py +123 -0
  116. tracelayer-0.1.0/src/tracelayer/symbols/__init__.py +0 -0
  117. tracelayer-0.1.0/src/tracelayer/symbols/base.py +287 -0
  118. tracelayer-0.1.0/src/tracelayer/symbols/go.py +108 -0
  119. tracelayer-0.1.0/src/tracelayer/symbols/java.py +106 -0
  120. tracelayer-0.1.0/src/tracelayer/symbols/javascript.py +74 -0
  121. tracelayer-0.1.0/src/tracelayer/symbols/python.py +61 -0
  122. tracelayer-0.1.0/src/tracelayer/symbols/registry.py +42 -0
  123. tracelayer-0.1.0/src/tracelayer/symbols/rust.py +118 -0
  124. tracelayer-0.1.0/src/tracelayer/symbols/typescript.py +32 -0
  125. tracelayer-0.1.0/tests/__init__.py +0 -0
  126. tracelayer-0.1.0/tests/conftest.py +93 -0
  127. tracelayer-0.1.0/tests/fixtures/symbols/go/sample.go +17 -0
  128. tracelayer-0.1.0/tests/fixtures/symbols/java/Greeter.java +22 -0
  129. tracelayer-0.1.0/tests/fixtures/symbols/javascript/sample.js +13 -0
  130. tracelayer-0.1.0/tests/fixtures/symbols/python/sample.py +20 -0
  131. tracelayer-0.1.0/tests/fixtures/symbols/rust/sample.rs +21 -0
  132. tracelayer-0.1.0/tests/fixtures/symbols/typescript/sample.ts +16 -0
  133. tracelayer-0.1.0/tests/golden/__init__.py +0 -0
  134. tracelayer-0.1.0/tests/golden/context_impl_json.golden +44 -0
  135. tracelayer-0.1.0/tests/golden/status_json.golden +12 -0
  136. tracelayer-0.1.0/tests/golden/test_golden_outputs.py +56 -0
  137. tracelayer-0.1.0/tests/golden/verify_merge_stale_json.golden +71 -0
  138. tracelayer-0.1.0/tests/golden/verify_pass_json.golden +7 -0
  139. tracelayer-0.1.0/tests/integration/__init__.py +0 -0
  140. tracelayer-0.1.0/tests/integration/_fixtures.py +341 -0
  141. tracelayer-0.1.0/tests/integration/test_acceptance_matrix.py +378 -0
  142. tracelayer-0.1.0/tests/integration/test_cli_e2e.py +179 -0
  143. tracelayer-0.1.0/tests/integration/test_debug_flag.py +45 -0
  144. tracelayer-0.1.0/tests/integration/test_dod_gaps.py +220 -0
  145. tracelayer-0.1.0/tests/integration/test_hooks_cli.py +168 -0
  146. tracelayer-0.1.0/tests/integration/test_install.py +92 -0
  147. tracelayer-0.1.0/tests/unit/__init__.py +0 -0
  148. tracelayer-0.1.0/tests/unit/config/test_config.py +287 -0
  149. tracelayer-0.1.0/tests/unit/conftest.py +94 -0
  150. tracelayer-0.1.0/tests/unit/discovery/test_discovery.py +233 -0
  151. tracelayer-0.1.0/tests/unit/evidence/test_freshness.py +276 -0
  152. tracelayer-0.1.0/tests/unit/evidence/test_ingest.py +218 -0
  153. tracelayer-0.1.0/tests/unit/evidence/test_parsers.py +191 -0
  154. tracelayer-0.1.0/tests/unit/evidence/test_per_test.py +161 -0
  155. tracelayer-0.1.0/tests/unit/evidence/test_spec_47_7.py +220 -0
  156. tracelayer-0.1.0/tests/unit/git/test_git.py +266 -0
  157. tracelayer-0.1.0/tests/unit/graph/test_fingerprints.py +69 -0
  158. tracelayer-0.1.0/tests/unit/graph/test_store.py +577 -0
  159. tracelayer-0.1.0/tests/unit/graph/test_traverse.py +153 -0
  160. tracelayer-0.1.0/tests/unit/hooks/conftest.py +27 -0
  161. tracelayer-0.1.0/tests/unit/hooks/test_post_batch.py +49 -0
  162. tracelayer-0.1.0/tests/unit/hooks/test_post_mutation.py +117 -0
  163. tracelayer-0.1.0/tests/unit/hooks/test_pre_mutation.py +158 -0
  164. tracelayer-0.1.0/tests/unit/hooks/test_prompt_context.py +91 -0
  165. tracelayer-0.1.0/tests/unit/hooks/test_sanitize.py +60 -0
  166. tracelayer-0.1.0/tests/unit/hooks/test_session_start.py +50 -0
  167. tracelayer-0.1.0/tests/unit/hooks/test_session_state.py +129 -0
  168. tracelayer-0.1.0/tests/unit/hooks/test_stop_gate.py +93 -0
  169. tracelayer-0.1.0/tests/unit/migration/test_codeops.py +383 -0
  170. tracelayer-0.1.0/tests/unit/migration/test_scry.py +73 -0
  171. tracelayer-0.1.0/tests/unit/policy/test_evaluator.py +349 -0
  172. tracelayer-0.1.0/tests/unit/policy/test_profiles.py +156 -0
  173. tracelayer-0.1.0/tests/unit/policy/test_rules.py +509 -0
  174. tracelayer-0.1.0/tests/unit/protocol/__init__.py +0 -0
  175. tracelayer-0.1.0/tests/unit/protocol/test_grammar.py +240 -0
  176. tracelayer-0.1.0/tests/unit/protocol/test_ids.py +195 -0
  177. tracelayer-0.1.0/tests/unit/protocol/test_marker.py +397 -0
  178. tracelayer-0.1.0/tests/unit/protocol/test_ontology.py +125 -0
  179. tracelayer-0.1.0/tests/unit/protocol/test_property.py +156 -0
  180. tracelayer-0.1.0/tests/unit/protocol/test_schema.py +91 -0
  181. tracelayer-0.1.0/tests/unit/query/conftest.py +68 -0
  182. tracelayer-0.1.0/tests/unit/query/test_context.py +350 -0
  183. tracelayer-0.1.0/tests/unit/query/test_impact.py +138 -0
  184. tracelayer-0.1.0/tests/unit/query/test_search.py +96 -0
  185. tracelayer-0.1.0/tests/unit/query/test_why.py +135 -0
  186. tracelayer-0.1.0/tests/unit/symbols/test_parse_stability.py +102 -0
  187. tracelayer-0.1.0/tests/unit/symbols/test_symbols.py +331 -0
  188. tracelayer-0.1.0/tests/unit/test_doctor.py +335 -0
@@ -0,0 +1,14 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .trace/cache/
5
+ .build/
6
+ dist/
7
+ build/
8
+ .pytest_cache/
9
+ .coverage
10
+ htmlcov/
11
+ .ruff_cache/
12
+ .mypy_cache/
13
+ node_modules/
14
+ .serena/
@@ -0,0 +1,25 @@
1
+ # TraceLayer
2
+
3
+ Agent-native software traceability system. Python 3.12+ core, managed with `uv`.
4
+
5
+ This repository uses mandatory semantic traceability. Trace integrity is part
6
+ of the Definition of Done. Follow the repository traceability skill
7
+ (`skills/traceability/SKILL.md`) and any trace instructions injected by hooks.
8
+
9
+ Do not invent trace fields, replace stable IDs during refactors, or remove
10
+ markers to silence validation. Before completing implementation work,
11
+ `trace verify --changed` must pass under the active policy.
12
+
13
+ Contributor workflow:
14
+
15
+ ```bash
16
+ uv sync
17
+ uv run pytest
18
+ uv run ruff check .
19
+ uv run trace --help
20
+ ```
21
+
22
+ Generated docs (`docs/marker-protocol.md`, `docs/relationships.md`,
23
+ `skills/traceability/references/marker-protocol.md`) are produced from the
24
+ protocol registries; run `uv run trace docs generate` after changing the
25
+ protocol and never edit them by hand.
@@ -0,0 +1,61 @@
1
+ # Contributing to TraceLayer
2
+
3
+ TraceLayer is a deterministic traceability engine that sits in the coding-agent control loop. Small changes can alter marker parsing, staleness propagation, policy gates, or hook enforcement for every repository that adopts it. Contributions are welcome when they preserve the protocol invariants and include evidence for the behavior they change.
4
+
5
+ Read [AGENTS.md](AGENTS.md) for repository-specific engineering rules. The normative specification is [traceability-system-master-spec.md](traceability-system-master-spec.md); generated documentation must come from the registries, never be hand-edited.
6
+
7
+ ## Development setup
8
+
9
+ ### Prerequisites
10
+
11
+ - Git
12
+ - Python `3.12+`
13
+ - [`uv`](https://docs.astral.sh/uv/) — dependency management is uv-only
14
+
15
+ ```bash
16
+ git clone https://github.com/carterlasalle/tracelayer.git
17
+ cd tracelayer
18
+ uv sync
19
+ ```
20
+
21
+ Confirm the baseline before editing:
22
+
23
+ ```bash
24
+ uv run pytest
25
+ uv run ruff check .
26
+ uv run trace docs generate --check
27
+ ```
28
+
29
+ ## Repository rules
30
+
31
+ - **Deterministic before semantic.** If a fact can be proven by parsing, Git, file existence, tests, or coverage, the engine must prove it. Never spend an LLM on it, and never hand an LLM the job of the deterministic engine.
32
+ - **One canonical schema.** The marker grammar, ontology, and TL-rule registries in `src/tracelayer/protocol/` and `src/tracelayer/diagnostics.py` are the single source of truth. `docs/marker-protocol.md`, `docs/relationships.md`, and `skills/traceability/references/marker-protocol.md` are generated — run `uv run trace docs generate` after changing the protocol and never edit them by hand.
33
+ - **Every failure is explainable.** Diagnostics come from the rule registry (`tracelayer.diagnostics.make`) with severity and remediation. Recoverable input problems are diagnostics, never exceptions.
34
+ - **Trace integrity is part of the Definition of Done.** Before completing implementation work, `trace verify --changed` must pass under the active policy.
35
+ - **Derived facts are never declared.** Paths, line numbers, commit SHAs, test results, and structural/observed edges must not appear in markers.
36
+ - **Ambiguity fails loudly.** A parser that cannot decide reports TL003; it never attaches a marker to a guessed symbol.
37
+
38
+ ## Pull requests
39
+
40
+ - Protected, squash-only pull requests with required checks.
41
+ - Every PR must include tests for the behavior it changes and update generated reference docs when the protocol changes.
42
+ - Use the [pull request template](.github/pull_request_template.md): list affected trace IDs, summarize the change, and check the verification boxes.
43
+ - New observable contracts (CLI flags, JSON shapes, rule behavior) get a focused test — see `tests/integration/test_dod_gaps.py` for the pattern.
44
+
45
+ ## Development commands
46
+
47
+ ```bash
48
+ uv run pytest # full suite (709 tests)
49
+ uv run pytest tests/unit/protocol -q # scoped runs work too
50
+ uv run ruff check . # lint; fix with uv run ruff check --fix .
51
+ uv run trace --help # CLI smoke
52
+ uv run trace docs generate --check # protocol docs drift check
53
+ ```
54
+
55
+ ## Testing conventions
56
+
57
+ - Deterministic only: `tmp_path` fixtures, no network, no wall-clock dependence. Normalize timestamps and SHAs in golden outputs.
58
+ - Shared fixtures live in `tests/conftest.py` (`make_git_repo`, `run_trace`).
59
+ - Property tests use Hypothesis (`tests/unit/protocol/test_property.py`).
60
+ - Hook behavior is tested by simulating harness events as JSON; no harness is required.
61
+ - The repository traces itself: add `trace:v1` markers to meaningful behavior boundaries you create, then run `uv run trace verify --changed`.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 TraceLayer contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.5
2
+ Name: tracelayer
3
+ Version: 0.1.0
4
+ Summary: TraceLayer: agent-native software traceability system
5
+ Project-URL: Homepage, https://github.com/carterlasalle/tracelayer
6
+ Project-URL: Repository, https://github.com/carterlasalle/tracelayer
7
+ Project-URL: Issues, https://github.com/carterlasalle/tracelayer/issues
8
+ Project-URL: Documentation, https://github.com/carterlasalle/tracelayer#documentation
9
+ Author: carterlasalle
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agents,ci,cli,requirements,software-engineering,traceability
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: pydantic>=2.7
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: tree-sitter-language-pack>=0.3
26
+ Requires-Dist: tree-sitter>=0.23
27
+ Requires-Dist: typer>=0.12
28
+ Description-Content-Type: text/markdown
29
+
30
+ <div align="center">
31
+
32
+ # TraceLayer
33
+
34
+ **Agent-native software traceability: intent, implementation, verification, provenance, and evidence as a deterministic graph.**
35
+
36
+ [![CI](https://img.shields.io/github/actions/workflow/status/carterlasalle/tracelayer/trace.yml?branch=master&label=CI)](https://github.com/carterlasalle/tracelayer/actions/workflows/trace.yml)
37
+ ![Python](https://img.shields.io/badge/Python-3.12%2B-3776AB?logo=python&logoColor=white)
38
+ ![uv](https://img.shields.io/badge/uv-managed-884AA8?logo=python&logoColor=white)
39
+ ![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
40
+ ![Tests](https://img.shields.io/badge/tests-709%20passing-brightgreen)
41
+
42
+ [Marker protocol](docs/marker-protocol.md) · [Relationships](docs/relationships.md) · [Concepts](docs/concepts.md) · [Policy](docs/policy.md) · [Hooks](docs/hooks.md) · [Evidence](docs/evidence.md) · [Security](docs/security.md)
43
+
44
+ </div>
45
+
46
+ TraceLayer makes the **why** of software traversable. One-line `trace:v1` markers declare the semantic relationships that cannot be derived — which work item produced a behavior, which requirement it satisfies, which tests intend to verify it. The engine derives everything else: AST symbol attachment, Git provenance, revision fingerprints, staleness, and runtime evidence. The result is a continuously verified trace graph that agents and reviewers can query instead of loading the whole repository.
47
+
48
+ ## How it works
49
+
50
+ ```mermaid
51
+ flowchart LR
52
+ A[trace:v1 markers] --> B[Marker parser]
53
+ B --> C[AST symbol attachment]
54
+ C --> D[SQLite trace graph]
55
+ D --> E[Git provenance]
56
+ E --> F[Fingerprints and staleness]
57
+ F --> G[Policy evaluation]
58
+ D --> H[Query engine]
59
+ H --> I[context / why / impact / search]
60
+ G --> J[Verify gate]
61
+ J --> K[Hook engine]
62
+ K --> L[Agent context and Stop gate]
63
+ L --> M[CI merge gate]
64
+ ```
65
+
66
+ Markers are the authoring notation; the graph is the product. Paths, line numbers, commit SHAs, and test results are derived — never written into markers — so trace identity survives refactors and evidence can never silently go stale.
67
+
68
+ ## Capabilities
69
+
70
+ | Area | What TraceLayer provides |
71
+ |---|---|
72
+ | Protocol | One-line versioned `trace:v1` grammar, typed semantic edges, stable IDs, deterministic type inference, generated schema docs |
73
+ | Indexing | Full and changed-scope indexing, Markdown/YAML artifact extraction, fence-aware marker scanning, honest file-level degradation for unsupported languages |
74
+ | Symbols | Tree-sitter attachment for Python, TypeScript, JavaScript, Go, Rust, and Java — markers attach to symbols, never line numbers |
75
+ | Graph | SQLite materialized index with declared, structural (`contains`), and observed (`executed`) provenance; FTS5 search; bounded traversal |
76
+ | Provenance | Git-derived first-seen/last-modified history, rename tracking, changed-line ranges, dirty-tree status — no commit IDs in source |
77
+ | Staleness | Requirement/implementation fingerprints, upstream-change propagation, review states, historical evidence preservation |
78
+ | Policy | Four profiles (minimal/standard/strict/safety-critical) across five lifecycles, scoped expiring waivers, deterministic TL-rule registry |
79
+ | Query UX | `context`, `why`, `impact`, `search`, `graph` (tree/mermaid/DOT/JSON/JSONL), `status`, `doctor`, `report pr` |
80
+ | Hooks | Session start, prompt context, pre-mutation block-once guard, post-mutation guidance, batch summary, fail-closed Stop gate |
81
+ | Evidence | JUnit/Cobertura/normalized ingestion, revision binding, L0–L3 proof levels, per-test Python coverage adapter |
82
+ | Migration | CodeOps scan/plan/apply with deterministic classification, Scry detection, doctor diagnostics with rename suggestions |
83
+ | Audit | Bounded deterministic audit packages for an independent semantic reviewer — no LLM required for the engine itself |
84
+
85
+ ## Quick start
86
+
87
+ ### Install
88
+
89
+ From the repository (no publish step needed):
90
+
91
+ ```bash
92
+ uv tool install git+https://github.com/carterlasalle/tracelayer.git
93
+ trace --help
94
+ ```
95
+
96
+ Or install from a local checkout: `uv tool install .`. The wheel is verified
97
+ against a clean venv with `uv build`; a PyPI publish is the planned next step.
98
+
99
+ The first time you run `trace` outside a configured repository it prints
100
+ next steps: `trace init` to enable traceability in the current repo, or
101
+ `trace install` to install the skill and hooks into your agent harnesses
102
+ globally. Set `TRACE_NO_HINT=1` to silence that message (e.g. in CI).
103
+
104
+ ### Publishing
105
+
106
+ `tracelayer` is published to PyPI on version tags via trusted publishing
107
+ (no tokens stored in CI). Publish a release with:
108
+
109
+ ```bash
110
+ git tag v0.1.0 && git push origin v0.1.0
111
+ ```
112
+
113
+ Manual publish from a checkout: `uv build && uv publish`. See
114
+ `.github/workflows/release.yml` for the one-time PyPI trusted-publisher
115
+ setup.
116
+
117
+ ### Prerequisites
118
+
119
+ - Python `3.12+`
120
+ - [`uv`](https://docs.astral.sh/uv/) (dependency management is uv-only; no pip)
121
+
122
+ ```bash
123
+ uv sync
124
+ uv run trace --help
125
+ ```
126
+
127
+ Trace an existing repository:
128
+
129
+ ```bash
130
+ uv run trace init --root <repo> # writes .trace/trace.toml + policy.toml
131
+ uv run trace index --root <repo> --all
132
+ uv run trace verify --root <repo> --all
133
+ uv run trace context --root <repo> <trace-id>
134
+ ```
135
+
136
+ Run the full development baseline:
137
+
138
+ ```bash
139
+ uv run pytest
140
+ uv run ruff check .
141
+ uv run trace docs generate --check
142
+ ```
143
+
144
+ ## Architecture
145
+
146
+ TraceLayer is a single Python package with deliberately narrow module boundaries:
147
+
148
+ ```text
149
+ src/tracelayer/
150
+ cli.py Typer CLI; business logic lives in modules
151
+ engine.py Indexing pipeline, verify, staleness, TraceRepository API
152
+ config.py trace.toml / policy.toml models and loading
153
+ diagnostics.py TL-rule registry; every failure carries remediation
154
+ protocol/ Marker grammar, parser, ID rules, ontology, generated schema
155
+ discovery/ File enumeration, ignore logic, monorepo scopes
156
+ artifacts/ Markdown, YAML, and generic file-level extraction
157
+ symbols/ Tree-sitter parsers and marker-to-symbol attachment
158
+ graph/ Node/edge models, SQLite store, migrations, traversal, fingerprints
159
+ git/ Provenance, history, diff-range mapping (argv-array subprocess only)
160
+ evidence/ JUnit, Cobertura, normalized JSON, freshness, proof levels
161
+ policy/ Profiles, lifecycle, waivers, deterministic rule functions
162
+ query/ context, why, impact, search
163
+ hooks/ Event handlers and file-backed session state
164
+ audit/ Bounded semantic-audit packages and external auditor adapter
165
+ migration/ CodeOps and Scry importers
166
+ ```
167
+
168
+ Every module is independently testable; the CLI is a thin shell over the engine.
169
+
170
+ ## Safety model
171
+
172
+ TraceLayer sits in the coding-agent control loop, so correctness is fail-closed by construction:
173
+
174
+ - Declared claims are never displayed as proven: a `test -> exercises -> implementation` claim stays unproven until observed execution evidence exists (proof levels L0–L3).
175
+ - Derived facts cannot be declared: paths, SHAs, test results, and structural/observed edges are rejected in markers.
176
+ - Ambiguity is a diagnostic, never a silent guess: detached markers, unresolved targets, and duplicate IDs are deterministic TL failures with remediation.
177
+ - Staleness preserves history: changing a requirement marks downstream review-required; it never deletes evidence.
178
+ - Repository text is untrusted data: hooks inject bounded, sanitized summaries; subprocess calls use argv arrays; no `shell=True`.
179
+ - Policy can weaken only deliberately: enforcement-file changes surface as TL063 warnings; waivers are scoped, owned, and expiring.
180
+ - CI and the Stop gate run the same engine as the CLI — there is no separate enforcement code path.
181
+
182
+ ## Documentation
183
+
184
+ | Document | Purpose |
185
+ |---|---|
186
+ | [Concepts](docs/concepts.md) | Three truths, the trace graph, stable IDs, staleness |
187
+ | [Marker protocol](docs/marker-protocol.md) | Generated normative `trace:v1` syntax and placement rules |
188
+ | [Relationships](docs/relationships.md) | Generated semantic/structural/observed edge semantics |
189
+ | [Policy](docs/policy.md) | Profiles, lifecycles, waivers, and the TL-rule catalog |
190
+ | [Hooks](docs/hooks.md) | Event model, block-once semantics, injection safety |
191
+ | [Evidence](docs/evidence.md) | JUnit/Cobertura ingestion and proof levels L0–L3 |
192
+ | [Migration](docs/migration-codeops.md) | CodeOps scan/plan/apply workflow |
193
+ | [Security](docs/security.md) | Threat model and mitigations |
194
+ | [Large repositories](docs/large-repos.md) | Incremental indexing, monorepo scopes, performance targets |
195
+ | [Architecture decisions](docs/adr/) | ADR-0001 through ADR-0008 |
196
+
197
+ ## Installing the agent skill
198
+
199
+ The canonical skill (canonical layout: `SKILL.md` + `README.md` +
200
+ `references/`) lives in [`skills/traceability/`](skills/traceability/README.md)
201
+ and is bundled with the installed package. Install it with `trace install`:
202
+
203
+ ```bash
204
+ trace install --list # detect agents and install state
205
+ trace install --agent claude-code # project scope (.claude/skills)
206
+ trace install --agent claude-code --global --yes # ~/.claude/skills
207
+ trace install --yes # all detected agents, non-interactive
208
+ ```
209
+
210
+ Hooks are merged for claude-code (`.claude/settings.json`) and codex
211
+ (`.codex/hooks.json`) in project scope; other agents get the skill only —
212
+ see `adapters/<harness>/README.md` for their hook setup. The same skill is
213
+ installable through the skills.sh ecosystem:
214
+
215
+ ```bash
216
+ npx skills add carterlasalle/tracelayer --agent claude-code
217
+ ```
218
+
219
+ For existing repositories, `trace init --skill` copies the skill into
220
+ `.agents/skills/traceability/` directly. The same folder is ready for skill
221
+ registries (e.g. skills.sh, anthropics/skills) — it follows the standard
222
+ layout and links references directly from `SKILL.md`.
223
+
224
+ ## Contributing
225
+
226
+ TraceLayer uses protected, squash-only pull requests with required checks. Read [CONTRIBUTING.md](CONTRIBUTING.md) before making changes. Run `uv run trace docs generate --check` when editing protocol documentation and `trace verify --changed` before proposing a merge — this repository traces itself.
227
+
228
+ ## License
229
+
230
+ Apache License 2.0 — see [LICENSE](LICENSE).