contextbom 0.1.0__tar.gz → 0.2.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 (26) hide show
  1. contextbom-0.2.0/.github/workflows/test.yml +19 -0
  2. {contextbom-0.1.0 → contextbom-0.2.0}/.gitignore +10 -10
  3. {contextbom-0.1.0 → contextbom-0.2.0}/CONTRIBUTING.md +20 -20
  4. {contextbom-0.1.0 → contextbom-0.2.0}/LICENSE +201 -201
  5. contextbom-0.2.0/PKG-INFO +164 -0
  6. contextbom-0.2.0/README.md +133 -0
  7. {contextbom-0.1.0 → contextbom-0.2.0}/SECURITY.md +11 -11
  8. {contextbom-0.1.0 → contextbom-0.2.0}/SPEC.md +121 -121
  9. {contextbom-0.1.0 → contextbom-0.2.0}/examples/demo.py +37 -37
  10. {contextbom-0.1.0 → contextbom-0.2.0}/pyproject.toml +37 -31
  11. {contextbom-0.1.0 → contextbom-0.2.0}/src/contextbom/__init__.py +14 -14
  12. {contextbom-0.1.0 → contextbom-0.2.0}/src/contextbom/cli.py +71 -71
  13. {contextbom-0.1.0 → contextbom-0.2.0}/src/contextbom/context.py +104 -88
  14. contextbom-0.2.0/src/contextbom/integrations/__init__.py +1 -0
  15. contextbom-0.2.0/src/contextbom/integrations/langchain.py +89 -0
  16. contextbom-0.2.0/src/contextbom/integrations/mcp.py +78 -0
  17. {contextbom-0.1.0 → contextbom-0.2.0}/src/contextbom/manifest.py +125 -125
  18. {contextbom-0.1.0 → contextbom-0.2.0}/src/contextbom/transforms.py +109 -85
  19. contextbom-0.2.0/tests/test_cli.py +52 -0
  20. contextbom-0.2.0/tests/test_integrations.py +105 -0
  21. contextbom-0.2.0/tests/test_manifest.py +86 -0
  22. contextbom-0.2.0/tests/test_transforms.py +37 -0
  23. {contextbom-0.1.0 → contextbom-0.2.0}/tools/make_gif.py +92 -92
  24. contextbom-0.1.0/PKG-INFO +0 -107
  25. contextbom-0.1.0/README.md +0 -88
  26. {contextbom-0.1.0 → contextbom-0.2.0}/docs/demo.gif +0 -0
@@ -0,0 +1,19 @@
1
+ name: tests
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ python-version: ["3.10", "3.12", "3.13"]
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: ${{ matrix.python-version }}
18
+ - run: pip install -e . pytest
19
+ - run: pytest tests/ -q
@@ -1,10 +1,10 @@
1
- __pycache__/
2
- *.py[cod]
3
- dist/
4
- build/
5
- *.egg-info/
6
- .venv/
7
- venv/
8
- .pytest_cache/
9
- demo.cbom.json
10
- cbom.jsonl
1
+ __pycache__/
2
+ *.py[cod]
3
+ dist/
4
+ build/
5
+ *.egg-info/
6
+ .venv/
7
+ venv/
8
+ .pytest_cache/
9
+ demo.cbom.json
10
+ cbom.jsonl
@@ -1,20 +1,20 @@
1
- # Contributing
2
-
3
- Thanks for your interest in ContextBOM.
4
-
5
- ## Spec changes (SPEC.md)
6
- The spec is the heart of this project and changes carefully. Open a GitHub Discussion
7
- in the "Spec RFC" category describing the problem, proposed change, and compatibility
8
- impact. Breaking changes are possible until v1.0, but every one needs a rationale.
9
-
10
- ## SDK changes
11
- - Good first contributions: SDK ports (TypeScript, Go), framework integrations
12
- (LangChain, LlamaIndex, MCP middleware), transform plugins, better PII/secret detectors.
13
- - Open an issue before large PRs.
14
- - Run the demo before submitting: `python examples/demo.py && cbom verify demo.cbom.json`
15
-
16
- ## Principles
17
- Manifests must never contain context content — hashes and metadata only.
18
- Producers stay zero-friction: no proxies, no required infrastructure.
19
-
20
- Apache-2.0. By contributing you agree your contributions are licensed under the same terms.
1
+ # Contributing
2
+
3
+ Thanks for your interest in ContextBOM.
4
+
5
+ ## Spec changes (SPEC.md)
6
+ The spec is the heart of this project and changes carefully. Open a GitHub Discussion
7
+ in the "Spec RFC" category describing the problem, proposed change, and compatibility
8
+ impact. Breaking changes are possible until v1.0, but every one needs a rationale.
9
+
10
+ ## SDK changes
11
+ - Good first contributions: SDK ports (TypeScript, Go), framework integrations
12
+ (LangChain, LlamaIndex, MCP middleware), transform plugins, better PII/secret detectors.
13
+ - Open an issue before large PRs.
14
+ - Run the demo before submitting: `python examples/demo.py && cbom verify demo.cbom.json`
15
+
16
+ ## Principles
17
+ Manifests must never contain context content — hashes and metadata only.
18
+ Producers stay zero-friction: no proxies, no required infrastructure.
19
+
20
+ Apache-2.0. By contributing you agree your contributions are licensed under the same terms.
@@ -1,201 +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 [yyyy] [name of copyright owner]
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.
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 [yyyy] [name of copyright owner]
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,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: contextbom
3
+ Version: 0.2.0
4
+ Summary: ContextBOM (CBOM) — a bill of materials for every prompt. Record where every piece of your AI model's context came from.
5
+ Project-URL: Homepage, https://github.com/contextbom/contextbom
6
+ Project-URL: Repository, https://github.com/contextbom/contextbom
7
+ Project-URL: Specification, https://github.com/contextbom/contextbom/blob/main/SPEC.md
8
+ Author: Akshat
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: ai,audit,bill-of-materials,cbom,context,context-engineering,llm,provenance
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Security
17
+ Requires-Python: >=3.10
18
+ Provides-Extra: all
19
+ Requires-Dist: langchain-core>=0.1; extra == 'all'
20
+ Requires-Dist: presidio-analyzer>=2.2; extra == 'all'
21
+ Requires-Dist: presidio-anonymizer>=2.2; extra == 'all'
22
+ Requires-Dist: tiktoken>=0.5; extra == 'all'
23
+ Provides-Extra: langchain
24
+ Requires-Dist: langchain-core>=0.1; extra == 'langchain'
25
+ Provides-Extra: pii
26
+ Requires-Dist: presidio-analyzer>=2.2; extra == 'pii'
27
+ Requires-Dist: presidio-anonymizer>=2.2; extra == 'pii'
28
+ Provides-Extra: tokens
29
+ Requires-Dist: tiktoken>=0.5; extra == 'tokens'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # contextbom
33
+
34
+ **A bill of materials for every prompt.** Know exactly what went into your AI model — every source, every transformation, every redaction — as a signed, auditable manifest.
35
+
36
+ ![cbom view demo](docs/demo.gif)
37
+
38
+ ```
39
+ pip install contextbom
40
+ ```
41
+
42
+ ```python
43
+ import contextbom as cbom
44
+ from openai import OpenAI
45
+
46
+ ctx = cbom.Context()
47
+
48
+ # Stamp provenance as you gather context. add() returns the (possibly transformed)
49
+ # text to place into your prompt.
50
+ docs = ctx.add(retriever.search(query), source="qdrant://kb/policies",
51
+ source_type="retrieval", sensitivity="internal")
52
+ history = ctx.add(memory.recall(user_id), source="mem0://user/123",
53
+ source_type="memory", sensitivity="pii")
54
+ ticket = ctx.add(fetch_ticket(id), source="https://jira.co/T-42",
55
+ source_type="url", transforms=[cbom.redact_pii])
56
+
57
+ # Call any model, your way. Record which model saw this context.
58
+ ctx.set_model("gpt-5", provider="openai")
59
+ response = OpenAI().chat.completions.create(
60
+ model="gpt-5", messages=build_prompt(docs, history, ticket))
61
+ ctx.record_completion(response.choices[0].message.content)
62
+
63
+ print(ctx.manifest.to_json()) # full lineage of everything the model saw
64
+ ctx.manifest.to_json("call.cbom.json") # or persist it
65
+ ```
66
+
67
+ Output — a **CBOM manifest** for that call (hashes and metadata only — never the context text itself, so it's safe to log and retain):
68
+
69
+ ```json
70
+ {
71
+ "producer": {"name": "contextbom-python", "version": "0.2.0"},
72
+ "model": {"id": "gpt-5", "provider": "openai"},
73
+ "cbom_version": "0.1",
74
+ "manifest_id": "6ab7c315-4dcf-422e-be0c-78973a3574ad",
75
+ "created_at": "2026-07-27T11:52:58Z",
76
+ "segments": [
77
+ {
78
+ "id": "seg-1",
79
+ "role": "user",
80
+ "source": {"uri": "qdrant://kb/policies", "type": "retrieval"},
81
+ "hash": "sha256:7579e8...",
82
+ "tokens": 812,
83
+ "sensitivity": "internal"
84
+ },
85
+ {
86
+ "id": "seg-2",
87
+ "role": "user",
88
+ "source": {"uri": "https://jira.co/T-42", "type": "url"},
89
+ "hash": "sha256:17bb9a...",
90
+ "hash_original": "sha256:bae7ec...",
91
+ "tokens": 240,
92
+ "sensitivity": "pii",
93
+ "authorized_by": "user:akshat",
94
+ "transforms": [
95
+ {"type": "redact_pii", "hash_after": "sha256:17bb9a...",
96
+ "detail": {"removed": 1, "engine": "regex"}}
97
+ ]
98
+ }
99
+ ],
100
+ "completion": {
101
+ "response_hash": "sha256:50f1f2...",
102
+ "usage": {"input_tokens": 1052, "output_tokens": 48}
103
+ }
104
+ }
105
+ ```
106
+
107
+ ## Why
108
+
109
+ - **Audit & compliance** — EU AI Act Article 12 requires logging what high-risk AI systems processed. A CBOM manifest is that record.
110
+ - **Security** — see exactly which tool output entered the prompt when investigating an injection or leak. Prove secrets never left the boundary.
111
+ - **Debugging** — "why did the model say that?" starts with "what did the model see?"
112
+ - **Trust** — a verifiable manifest makes AI decisions explainable to auditors, customers, and courts.
113
+
114
+ ## What it is / isn't
115
+
116
+ | | |
117
+ |---|---|
118
+ | ✅ An open spec (JSON) + SDKs that stamp provenance onto context at assembly time | ❌ A gateway or proxy you must deploy |
119
+ | ✅ Works with any model, any framework | ❌ Another agent framework |
120
+ | ✅ Complements CycloneDX ML-BOM / SPDX (static artifacts) with runtime lineage | ❌ A replacement for SBOM standards |
121
+ | ✅ A record of what entered a model call | ❌ A memory layer or context store |
122
+ | ✅ OpenTelemetry export *(roadmap)* | ❌ A hosted service |
123
+
124
+ ## Features
125
+
126
+ - **`cbom.Context`** — wrap context assembly; automatic manifest generation
127
+ - **Transforms** — built-in, recordable `redact_pii`, `strip_secrets`, `truncate`
128
+ - **`cbom view` / `cbom verify`** — CLI (installed with the package) that renders any prompt color-coded by source and sensitivity, and verifies hash chains
129
+ - **JSONL audit log** — append every call's manifest to a log with `ctx.log()`
130
+ - **Signing** — optional Sigstore-style attestation of manifests *(roadmap, v0.3)*
131
+ - **Integrations** — LangChain callback (auto-emit manifests from any chain/agent run) and MCP middleware (stamp every tool response) ship today; LlamaIndex on the roadmap
132
+
133
+ ## Integrations
134
+
135
+ **LangChain** — one handler, every LLM call gets a manifest:
136
+
137
+ ```python
138
+ from contextbom.integrations.langchain import CBOMCallbackHandler
139
+
140
+ handler = CBOMCallbackHandler(log_path="cbom.jsonl")
141
+ chain.invoke({...}, config={"callbacks": [handler]})
142
+ # retrieved docs -> retrieval segments, prompts -> literal segments, per-call manifests
143
+ ```
144
+
145
+ **MCP** — wrap your tool caller once; every tool response is provenance-stamped (and secret-stripped by default) before it enters context:
146
+
147
+ ```python
148
+ from contextbom.integrations.mcp import wrap_tool_caller
149
+
150
+ call = wrap_tool_caller(ctx, session.call_tool, server="github")
151
+ result = await call("search", {"q": "..."}) # recorded as mcp://github/search
152
+ ```
153
+
154
+ Optional extras: `pip install "contextbom[pii]"` (Presidio-backed PII detection — the manifest records which engine ran), `"contextbom[tokens]"` (tiktoken counts), `"contextbom[all]"`.
155
+
156
+ ## Spec
157
+
158
+ The manifest format is defined in [SPEC.md](./SPEC.md). v0.1 is deliberately small: segments, sources, hashes, transforms, sensitivity labels, signatures. Extensions are namespaced.
159
+
160
+ ## Contributing
161
+
162
+ The spec is developed in the open — issues and RFCs welcome. Good first contributions: SDK ports (TypeScript, Go), framework integrations, transform plugins.
163
+
164
+ Apache-2.0.