sift-engine 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 (129) hide show
  1. sift_engine-0.1.0/LICENSE +202 -0
  2. sift_engine-0.1.0/PKG-INFO +342 -0
  3. sift_engine-0.1.0/README.md +306 -0
  4. sift_engine-0.1.0/evals/__init__.py +13 -0
  5. sift_engine-0.1.0/evals/agent_loop/__init__.py +23 -0
  6. sift_engine-0.1.0/evals/agent_loop/agent.py +314 -0
  7. sift_engine-0.1.0/evals/agent_loop/judge.py +228 -0
  8. sift_engine-0.1.0/evals/agent_loop/questions.py +396 -0
  9. sift_engine-0.1.0/evals/agent_loop/report.py +197 -0
  10. sift_engine-0.1.0/evals/agent_loop/runner.py +234 -0
  11. sift_engine-0.1.0/evals/agent_loop/tools.py +384 -0
  12. sift_engine-0.1.0/evals/bench/__init__.py +0 -0
  13. sift_engine-0.1.0/evals/bench/aggregate_report.py +113 -0
  14. sift_engine-0.1.0/evals/bench/drift.py +301 -0
  15. sift_engine-0.1.0/evals/bench/fixtures/__init__.py +0 -0
  16. sift_engine-0.1.0/evals/bench/fixtures/sites.py +440 -0
  17. sift_engine-0.1.0/evals/bench/full_suite.py +380 -0
  18. sift_engine-0.1.0/evals/bench/per_stage/__init__.py +0 -0
  19. sift_engine-0.1.0/evals/bench/per_stage/commit.py +88 -0
  20. sift_engine-0.1.0/evals/bench/per_stage/extract.py +267 -0
  21. sift_engine-0.1.0/evals/bench/per_stage/fetch.py +190 -0
  22. sift_engine-0.1.0/evals/bench/per_stage/mcp.py +83 -0
  23. sift_engine-0.1.0/evals/bench/per_stage/plan.py +186 -0
  24. sift_engine-0.1.0/evals/bench/per_stage/publish.py +61 -0
  25. sift_engine-0.1.0/evals/bench/per_stage/seed.py +189 -0
  26. sift_engine-0.1.0/evals/bench/report.py +167 -0
  27. sift_engine-0.1.0/evals/bench/runner.py +103 -0
  28. sift_engine-0.1.0/evals/bench/scoring/__init__.py +0 -0
  29. sift_engine-0.1.0/evals/bench/scoring/fidelity.py +118 -0
  30. sift_engine-0.1.0/evals/bench/scoring/structural.py +121 -0
  31. sift_engine-0.1.0/evals/bench/scoring/use_case.py +60 -0
  32. sift_engine-0.1.0/evals/cli.py +620 -0
  33. sift_engine-0.1.0/evals/determinism.py +135 -0
  34. sift_engine-0.1.0/evals/efficiency.py +162 -0
  35. sift_engine-0.1.0/evals/facts_coverage.py +198 -0
  36. sift_engine-0.1.0/evals/facts_validation.py +150 -0
  37. sift_engine-0.1.0/evals/llm_judge.py +331 -0
  38. sift_engine-0.1.0/evals/performance.py +217 -0
  39. sift_engine-0.1.0/evals/sampler.py +111 -0
  40. sift_engine-0.1.0/evals/structural.py +237 -0
  41. sift_engine-0.1.0/pyproject.toml +64 -0
  42. sift_engine-0.1.0/setup.cfg +4 -0
  43. sift_engine-0.1.0/sift/__init__.py +40 -0
  44. sift_engine-0.1.0/sift/_io.py +82 -0
  45. sift_engine-0.1.0/sift/agent_surface.py +267 -0
  46. sift_engine-0.1.0/sift/browser.py +420 -0
  47. sift_engine-0.1.0/sift/classify.py +164 -0
  48. sift_engine-0.1.0/sift/cli.py +1388 -0
  49. sift_engine-0.1.0/sift/commit.py +165 -0
  50. sift_engine-0.1.0/sift/config.py +302 -0
  51. sift_engine-0.1.0/sift/decide.py +173 -0
  52. sift_engine-0.1.0/sift/extract.py +669 -0
  53. sift_engine-0.1.0/sift/extract_code.py +190 -0
  54. sift_engine-0.1.0/sift/extract_next_state.py +305 -0
  55. sift_engine-0.1.0/sift/extract_strategy.py +143 -0
  56. sift_engine-0.1.0/sift/facts.py +334 -0
  57. sift_engine-0.1.0/sift/fetch.py +459 -0
  58. sift_engine-0.1.0/sift/index_profile.py +50 -0
  59. sift_engine-0.1.0/sift/integrity.py +155 -0
  60. sift_engine-0.1.0/sift/manifest.py +441 -0
  61. sift_engine-0.1.0/sift/mcp_server.py +1889 -0
  62. sift_engine-0.1.0/sift/normalize.py +62 -0
  63. sift_engine-0.1.0/sift/paths.py +136 -0
  64. sift_engine-0.1.0/sift/plan.py +149 -0
  65. sift_engine-0.1.0/sift/publish.py +642 -0
  66. sift_engine-0.1.0/sift/purge.py +58 -0
  67. sift_engine-0.1.0/sift/registry.py +495 -0
  68. sift_engine-0.1.0/sift/sites/__init__.py +232 -0
  69. sift_engine-0.1.0/sift/sites/ato.py +331 -0
  70. sift_engine-0.1.0/sift/sites/augov.py +186 -0
  71. sift_engine-0.1.0/sift/sites/generic.py +14 -0
  72. sift_engine-0.1.0/sift/sites/generic_browser.py +50 -0
  73. sift_engine-0.1.0/sift/sites/mdn.py +128 -0
  74. sift_engine-0.1.0/sift/sites/python_docs.py +134 -0
  75. sift_engine-0.1.0/sift/sites/stripe.py +138 -0
  76. sift_engine-0.1.0/sift/sources/__init__.py +86 -0
  77. sift_engine-0.1.0/sift/sources/firecrawl.py +488 -0
  78. sift_engine-0.1.0/sift/sources/sitemap.py +345 -0
  79. sift_engine-0.1.0/sift/status.py +141 -0
  80. sift_engine-0.1.0/sift_engine.egg-info/PKG-INFO +342 -0
  81. sift_engine-0.1.0/sift_engine.egg-info/SOURCES.txt +127 -0
  82. sift_engine-0.1.0/sift_engine.egg-info/dependency_links.txt +1 -0
  83. sift_engine-0.1.0/sift_engine.egg-info/entry_points.txt +4 -0
  84. sift_engine-0.1.0/sift_engine.egg-info/requires.txt +22 -0
  85. sift_engine-0.1.0/sift_engine.egg-info/top_level.txt +2 -0
  86. sift_engine-0.1.0/tests/test_agent_loop.py +634 -0
  87. sift_engine-0.1.0/tests/test_agent_surface.py +174 -0
  88. sift_engine-0.1.0/tests/test_backup.py +93 -0
  89. sift_engine-0.1.0/tests/test_browser_contract.py +1034 -0
  90. sift_engine-0.1.0/tests/test_browser_real.py +230 -0
  91. sift_engine-0.1.0/tests/test_classify.py +155 -0
  92. sift_engine-0.1.0/tests/test_commit_chain.py +109 -0
  93. sift_engine-0.1.0/tests/test_config.py +181 -0
  94. sift_engine-0.1.0/tests/test_consolidate_md.py +142 -0
  95. sift_engine-0.1.0/tests/test_decide.py +182 -0
  96. sift_engine-0.1.0/tests/test_eval_bench_b3.py +119 -0
  97. sift_engine-0.1.0/tests/test_eval_bench_b5.py +93 -0
  98. sift_engine-0.1.0/tests/test_eval_bench_drift.py +282 -0
  99. sift_engine-0.1.0/tests/test_eval_bench_scoring.py +170 -0
  100. sift_engine-0.1.0/tests/test_evals.py +181 -0
  101. sift_engine-0.1.0/tests/test_excludes_and_pdf.py +180 -0
  102. sift_engine-0.1.0/tests/test_extract_anchors.py +66 -0
  103. sift_engine-0.1.0/tests/test_extract_code.py +187 -0
  104. sift_engine-0.1.0/tests/test_extract_next_state.py +278 -0
  105. sift_engine-0.1.0/tests/test_extract_strategy.py +176 -0
  106. sift_engine-0.1.0/tests/test_facts.py +143 -0
  107. sift_engine-0.1.0/tests/test_facts_coverage.py +117 -0
  108. sift_engine-0.1.0/tests/test_fetch_browser.py +375 -0
  109. sift_engine-0.1.0/tests/test_firecrawl_scrape.py +462 -0
  110. sift_engine-0.1.0/tests/test_gates.py +135 -0
  111. sift_engine-0.1.0/tests/test_integrity.py +181 -0
  112. sift_engine-0.1.0/tests/test_manifest.py +189 -0
  113. sift_engine-0.1.0/tests/test_markdown_passthrough.py +203 -0
  114. sift_engine-0.1.0/tests/test_mcp_index.py +342 -0
  115. sift_engine-0.1.0/tests/test_mcp_multi_index.py +686 -0
  116. sift_engine-0.1.0/tests/test_mcp_server.py +326 -0
  117. sift_engine-0.1.0/tests/test_mcp_verify.py +89 -0
  118. sift_engine-0.1.0/tests/test_normalize.py +78 -0
  119. sift_engine-0.1.0/tests/test_only_urls.py +185 -0
  120. sift_engine-0.1.0/tests/test_pre_freeze_hardening.py +284 -0
  121. sift_engine-0.1.0/tests/test_production_hardening.py +678 -0
  122. sift_engine-0.1.0/tests/test_publish_integrity.py +172 -0
  123. sift_engine-0.1.0/tests/test_purge.py +166 -0
  124. sift_engine-0.1.0/tests/test_re_extract.py +180 -0
  125. sift_engine-0.1.0/tests/test_registry.py +368 -0
  126. sift_engine-0.1.0/tests/test_sites.py +548 -0
  127. sift_engine-0.1.0/tests/test_sources_firecrawl.py +288 -0
  128. sift_engine-0.1.0/tests/test_sources_sitemap_auto.py +247 -0
  129. sift_engine-0.1.0/tests/test_user_agent_warnings.py +202 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Deval Shah
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.4
2
+ Name: sift-engine
3
+ Version: 0.1.0
4
+ Summary: Sift — deterministic website indexing for grep-first LLM agents
5
+ Author: Deval Shah
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/dvlshah/sift
8
+ Project-URL: Repository, https://github.com/dvlshah/sift
9
+ Project-URL: Issues, https://github.com/dvlshah/sift/issues
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: httpx>=0.27
17
+ Requires-Dist: trafilatura>=1.12
18
+ Requires-Dist: aiolimiter>=1.1
19
+ Requires-Dist: click>=8.1
20
+ Requires-Dist: lxml>=5.0
21
+ Requires-Dist: selectolax>=0.3
22
+ Requires-Dist: mcp>=1.0
23
+ Requires-Dist: pypdf>=4.0
24
+ Requires-Dist: jsonschema>=4
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
28
+ Requires-Dist: respx>=0.21; extra == "dev"
29
+ Provides-Extra: evals
30
+ Requires-Dist: anthropic>=0.40; extra == "evals"
31
+ Requires-Dist: pydantic>=2.0; extra == "evals"
32
+ Requires-Dist: jsonschema>=4; extra == "evals"
33
+ Provides-Extra: browser
34
+ Requires-Dist: playwright>=1.40; extra == "browser"
35
+ Dynamic: license-file
36
+
37
+ <div align="center">
38
+
39
+ <img src="assets/sift.gif" alt="sift" width="480">
40
+
41
+ **Deterministic, content-hashed website indexing for grep-first AI agents — served over MCP.**
42
+
43
+ [![Tests](https://github.com/dvlshah/sift/actions/workflows/tests.yml/badge.svg)](https://github.com/dvlshah/sift/actions/workflows/tests.yml)
44
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
45
+ [![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/downloads/)
46
+ [![MCP](https://img.shields.io/badge/MCP-stdio-purple)](https://modelcontextprotocol.io/)
47
+
48
+ </div>
49
+
50
+ sift turns any website you can reach by URL into a complete, always-current, **verifiable** corpus that an AI agent reads over MCP — files on disk, not vectors. Every page is content-hashed and dated, so any answer can be proved back to the exact source, hash, and snapshot. Self-hosted: your data and your proof stay yours.
51
+
52
+ - **Provable** — same input → same `content_hash` → same Merkle root; a hash-chained changelog; optional GPG-signed snapshots; per-read `verify=true`.
53
+ - **Any site, self-hosted** — point it at any `http(s)` site (static HTML, or JS-rendered SPAs via the optional browser path). A pluggable `SiteProfile` handles per-site logic with no core changes.
54
+ - **Complete & grep-native** — the full crawled corpus as markdown + structured facts that agents `read` / `grep` / `glob` / query — not a few browsed pages, not opaque vector similarity.
55
+ - **Incremental & low-ops** — conditional GETs re-extract only what changed; bump a transformer version and re-derive from cached raw with no refetch.
56
+
57
+ > **Open core.** This repository is the open-source engine (pipeline + MCP server), Apache-2.0, and runs fully on its own. A hosted platform built on it is in development.
58
+
59
+ [Quickstart](#quickstart) · [Architecture](#architecture) · [CLI](#cli-reference) · [MCP server](#mcp-server) · [Integrity](#integrity-guarantees) · [Develop](#development) · [Contributing](#contributing)
60
+
61
+ ---
62
+
63
+ ## Scope — what sift indexes
64
+
65
+ **Today:** any `http(s)` URL — HTML pages and PDFs. Discover URLs from a `sitemap.xml`, whole-domain sitemap auto-discovery, a Firecrawl map, or a plain URL list. JS-rendered SPAs go through the optional Playwright path; bot-blocked or rate-limited hosts through the optional Firecrawl fallback. Works on public sites and on internal ones your machine can reach (add the host to the allow-list).
66
+
67
+ **Not yet (roadmap — and good first contributions):** non-URL sources — local files and folders, git repos, API-only knowledge bases (Notion, Confluence, Slack, Google Drive), and databases. The pipeline is source-agnostic once content is in, so these land as ingestion *connectors*.
68
+
69
+ ---
70
+
71
+ ## Quickstart
72
+
73
+ Requires Python 3.11+.
74
+
75
+ ```bash
76
+ git clone https://github.com/dvlshah/sift.git && cd sift
77
+ pip install -e .
78
+
79
+ # 1. create an index root
80
+ sift init --root ./index
81
+
82
+ # 2. seed URLs — ships with an ATO reference profile that needs no config
83
+ sift seed --root ./index --from-sitemap https://www.ato.gov.au/sitemap.xml
84
+
85
+ # 3. build a small index first — cap the crawl with --limit; --coverage-base
86
+ # planned tells the coverage gate the cap was intentional
87
+ sift run --root ./index --limit 25 --coverage-base planned
88
+
89
+ # 4. verify end-to-end integrity
90
+ sift verify --root ./index --skip-signature
91
+
92
+ # 5. serve it to an agent over MCP (read-only)
93
+ sift-mcp --root ./index
94
+ ```
95
+
96
+ **Indexing a different site?** Drop a `sift.toml` next to your index with the generic profile + host allow-list:
97
+
98
+ ```toml
99
+ [site]
100
+ profile = "sift.sites.generic:GenericProfile"
101
+
102
+ [seed]
103
+ host_allow = ["docs.example.com"]
104
+ ```
105
+
106
+ ```bash
107
+ sift seed --root ./index --config sift.toml --from-domain https://docs.example.com
108
+ sift run --root ./index --config sift.toml --limit 25 --coverage-base planned
109
+ ```
110
+
111
+ Indexing JS-rendered SPAs needs the optional browser stack:
112
+
113
+ ```bash
114
+ pip install -e ".[browser]" && python -m playwright install chromium
115
+ ```
116
+
117
+ ---
118
+
119
+ ## What you get
120
+
121
+ After a run, the index root contains:
122
+
123
+ ```
124
+ <root>/
125
+ ├── manifest.db SQLite — single source of truth for URL state
126
+ ├── raw/<aa>/<sha256>.html.gz Content-addressed raw HTML/PDF blobs
127
+ ├── changelog.jsonl Append-only, hash-chained per-content-change log
128
+ ├── current/ Symlink → the most-recent passing snapshot
129
+ ├── runs/<run_id>/
130
+ │ ├── INDEX.md Always-loaded pointer table for agents
131
+ │ ├── routes.tsv url → md_path map (grep/awk friendly)
132
+ │ ├── sections/<top>/INDEX.md Per-section drill-down indexes
133
+ │ ├── md/<url-path>.md Markdown mirror of the URL tree
134
+ │ ├── facts/<schema>/*.json Atomic structured records (rate tables, etc.)
135
+ │ ├── artifacts/by_guide/*.md Multi-page guide rollups
136
+ │ └── snapshot.json Gate results, version pins, Merkle root, gpg sig (opt)
137
+ └── backups/manifest-*.db Online SQLite backups (run on cron)
138
+ ```
139
+
140
+ Every markdown file leads with YAML frontmatter: URL, fetch timestamp, raw + content hashes, tier, audience, FY years, anchors, and four version pins (crawler, extractor, normalizer, classifier). Re-verify any file in `O(1)` by re-normalizing the body and comparing its SHA-256 to the stored `content_hash`.
141
+
142
+ ---
143
+
144
+ ## Architecture
145
+
146
+ Five sequential phases, each idempotent and resumable from a checkpoint:
147
+
148
+ ```
149
+ seed ──► Add URLs to the manifest (tier + parent_guide assigned per site profile)
150
+ plan ──► Per-URL decision: FETCH / FETCH_CONDITIONAL / SKIP / TOMBSTONE_PURGE
151
+ (pure function of manifest state, sitemap lastmod, clock, versions)
152
+ fetch ──► HTTP (async httpx + per-host token bucket + conditional GETs) or,
153
+ per profile, the Playwright browser path. Raw stored by SHA-256.
154
+ extract──► HTML→markdown (trafilatura) / PDF→text (pypdf); deterministic
155
+ anchor injection + hash normalization → content_hash
156
+ commit ──► One SQLite transaction applies all outcomes; appends chained
157
+ entries to changelog.jsonl per content change
158
+ publish──► 5 verification gates → atomic symlink swap to current/;
159
+ Merkle root over all content_hashes written to snapshot.json
160
+ ```
161
+
162
+ Each transformation is versioned independently (`CRAWLER_VERSION`, `EXTRACTOR_VERSION`, `NORMALIZER_VERSION`, `CLASSIFIER_VERSION`, `INTEGRITY_VERSION`) — bump one and `sift re-extract` re-derives from cached raw with no network. Failures are contained per-URL: one bad page never breaks a snapshot, and the coverage gate blocks publish if too many URLs are non-terminal.
163
+
164
+ ---
165
+
166
+ ## CLI reference
167
+
168
+ `--root` is required on every command; `--config PATH` (default `./sift.toml` / `./sift.local.toml`) is accepted on the pipeline commands. CLI flags override config.
169
+
170
+ **Pipeline**
171
+
172
+ | Command | Purpose |
173
+ |---|---|
174
+ | `sift init` | Create `manifest.db`; surface changelog state |
175
+ | `sift seed` | Add URLs via `--from-sitemap` / `--from-domain` / `--from-firecrawl-map` / `--from-json` |
176
+ | `sift plan` / `fetch` / `extract` / `commit` | Run a single phase (`--run-id` for fetch/extract/commit) |
177
+ | `sift run` | plan → fetch → extract → commit → publish, with per-phase timings (`--limit`, `--tier`, `--rate`, `--coverage-base`, `--firecrawl-fallback`, `--only-urls`) |
178
+ | `sift publish --run-id ID` | 5 verification gates + atomic symlink swap |
179
+ | `sift status` | Counts by state + tier, version pins, recent runs |
180
+
181
+ **Operational**
182
+
183
+ | Command | Purpose |
184
+ |---|---|
185
+ | `sift re-extract` | Re-derive `content_hash`es from cached raw (no network); preserves the changelog. Run after an extractor/normalizer version bump |
186
+ | `sift purge` | Drop manifest rows whose plan decision is `TOMBSTONE_PURGE` (`--dry-run` to preview) |
187
+ | `sift backup [--to PATH] [--keep N]` | Online SQLite backup, safe under concurrent writes |
188
+ | `sift verify-backup BACKUP` | `PRAGMA integrity_check` + schema sanity on a backup |
189
+
190
+ **Integrity & read access**
191
+
192
+ | Command | Purpose |
193
+ |---|---|
194
+ | `sift verify [--skip-signature]` | Merkle root + changelog chain + optional GPG, in one |
195
+ | `sift verify-snapshot` / `verify-changelog` / `verify-signature` | The individual integrity checks |
196
+ | `sift manifest-query "SELECT ..."` | Read-only SQL against `manifest.db` (refuses non-`SELECT`/`WITH`) |
197
+
198
+ ---
199
+
200
+ ## Configuration
201
+
202
+ A single TOML file (`sift.toml` in cwd, or `--config PATH`) controls everything tunable:
203
+
204
+ ```toml
205
+ [site]
206
+ profile = "sift.sites.ato:ATOProfile" # or sift.sites.generic:GenericProfile
207
+
208
+ [fy]
209
+ current_start_year = 2025 # FY cutoff for the FROZEN tier
210
+
211
+ [crawl]
212
+ rate_per_sec = 5.0 # per-host token bucket
213
+ concurrency = 8
214
+ timeout_sec = 30.0
215
+ retries = 3
216
+
217
+ [publish]
218
+ coverage_floor = 0.99 # fraction of seeded URLs that must reach a terminal state
219
+ hash_sample_rate = 0.01 # 1% of md files re-hashed each publish
220
+ gpg_key_id = "" # optional: detach-sign snapshot.json
221
+
222
+ [seed]
223
+ host_allow = ["www.ato.gov.au"]
224
+ use_default_excludes = true
225
+ extra_exclude_patterns = ["^/other-languages/"]
226
+
227
+ [browser] # optional; only used if a profile opts a URL in
228
+ enabled = false # default off → SPAs become SKIPPED_BROWSER_DISABLED
229
+ wait_until = "domcontentloaded" # profiles can override (ATO uses "networkidle")
230
+
231
+ # [tiers.NEWS] / [tiers.LIVING] / [tiers.CURRENT_FORMS] / [tiers.FROZEN]
232
+ # each: floor_days, ceiling_days, tombstone_ttl_days, max_failures
233
+ ```
234
+
235
+ ---
236
+
237
+ ## MCP server
238
+
239
+ `sift-mcp --root /path/to/index` exposes **7 read-only tools** over stdio, for grep-first agents:
240
+
241
+ | Tool | Purpose |
242
+ |---|---|
243
+ | `snapshot_status` | Published yes/no, run_id, gate results, artifact inventory. **Call first.** Never errors. |
244
+ | `grep_corpus` | Regex over the markdown tree — best for identifiers/exact phrases (capped at 200 matches) |
245
+ | `read_md` | Read one markdown file (`offset`/`limit` to page; `verify=true` re-hashes before you cite) |
246
+ | `read_facts` | Read one `facts/<schema>/*.json` with `$schema` + `source_url` + `content_hash` provenance |
247
+ | `glob_corpus` | List files by fnmatch glob (capped at 500) |
248
+ | `list_dir` | Cheap directory enumeration |
249
+ | `query_manifest` | Read-only SQL against `manifest.db` for cross-cutting queries |
250
+
251
+ Read-only by default; hard-fails with an actionable message if no `current/` snapshot exists. Output is capped per tool — locate with `grep_corpus`, then drill in with `read_md` (`offset`/`limit`).
252
+
253
+ **Multi-index mode** — point `--root` at a *parent directory* of several index roots and the server auto-exposes `list_indexes` plus an `index=<slug>` parameter on every content tool (`index="*"` fans out the read tools).
254
+
255
+ **Write tools** — add `--enable-index` to expose `index_url` (seed allow-listed URLs + trigger a background crawl; returns a `run_id` immediately) and `index_status` (poll by `run_id`). One in-flight crawl per index, capped across indexes by `--max-concurrent-crawls` (default 4); each crawl is an isolated `sift seed && sift run` subprocess, so a failed fetch can't take down the read server. Off by default — the standard deployment is strictly read-only.
256
+
257
+ Wire into Claude Code / Cursor / Codex:
258
+
259
+ ```json
260
+ {
261
+ "mcpServers": {
262
+ "sift": { "command": "sift-mcp", "args": ["--root", "/abs/path/to/index"] }
263
+ }
264
+ }
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Integrity guarantees
270
+
271
+ | Property | Mechanism | Verified by |
272
+ |---|---|---|
273
+ | Same input → same `content_hash` | Deterministic `extract` + versioned `normalize_for_hash` | `tests/test_integrity.py`, `sift-evals determinism` |
274
+ | Snapshot is bit-identical to publish time | Merkle root over all `(url, content_hash)` in `snapshot.json` | `sift verify-snapshot` |
275
+ | Changelog hasn't been tampered with | SHA-256 chain: `entry_hash = sha256(prev_hash ‖ canonical(entry))` | `sift verify-changelog` |
276
+ | Per-file integrity on agent reads | `read_md verify=true` re-hashes the body vs. frontmatter | MCP returns `isError` on mismatch |
277
+ | Every FRESH row has a real md file | Publish gate `manifest_fs_integrity` | publish blocks on orphan/missing files |
278
+ | Every `facts/*.json` validates against its `$schema` | Publish gate `facts_validation` (Draft 2020-12) | publish blocks on invalid facts |
279
+ | Optional cryptographic signature | `[publish].gpg_key_id` → `gpg --detach-sign` | `sift verify-signature` |
280
+
281
+ **Known gaps:** no content-pinning against the source server (TLS is the fetch-time root of trust); the MCP per-read hash isn't chained back to the GPG signature automatically; no built-in off-machine storage (pair `sift backup` with `rclone`/`rsync`).
282
+
283
+ ---
284
+
285
+ ## Site profiles
286
+
287
+ Every site-specific decision lives in a `SiteProfile` subclass under `sift/sites/` — URL→tier classification, `parent_guide` extraction, default excludes, dynamic-content patterns stripped before hashing, section taxonomy, facts schemas, and browser routing. The core pipeline never names a site. Ships `generic` (every URL `LIVING`, no facts, HTTP only — the right starting point for any site), `generic_browser`, and reference profiles (`ato`, `augov`, `mdn`, `python_docs`, `stripe`); the default is `sift.sites.ato:ATOProfile` (~330 lines).
288
+
289
+ Adding a site is usually a small subclass — no core changes:
290
+
291
+ ```python
292
+ # sift/sites/irs.py
293
+ import re
294
+ from . import SiteProfile
295
+
296
+ class IRSProfile(SiteProfile):
297
+ name = "irs"
298
+ primary_host = "www.irs.gov"
299
+
300
+ @property
301
+ def default_excludes(self):
302
+ return (r"^/coronavirus/", r"^/spanish/")
303
+
304
+ def classify_tier(self, url, current_year_start):
305
+ ... # IRS uses calendar years, not FY
306
+ ```
307
+
308
+ Then set `profile = "sift.sites.irs:IRSProfile"` in `sift.toml`, reseed, and run.
309
+
310
+ ---
311
+
312
+ ## Development
313
+
314
+ ```bash
315
+ pip install -e ".[dev,evals]" # runtime + test + eval-suite deps
316
+ pytest -q # full suite — hermetic (HTTP mocked), no network needed
317
+ ruff check . && ruff format . # lint + format
318
+ ```
319
+
320
+ The optional eval harness is the `sift-evals` CLI (installed via the `[evals]` extra) — performance, determinism, structural-fidelity, facts, and agent-in-the-loop benchmarks (`sift-evals --help`). See **[CONTRIBUTING.md](./CONTRIBUTING.md)** for the full guide: conventional commits, the `SiteProfile` extension path, the determinism invariant, and CI (every PR runs the suite on Python 3.11 / 3.12 / 3.13).
321
+
322
+ ---
323
+
324
+ ## Project status
325
+
326
+ **0.1.0 — initial public release.** Full test suite green on Python 3.11–3.13. Known limitations (PRs welcome):
327
+
328
+ - No run-dir / raw-blob garbage collection yet — storage grows; reclaim with `rm -rf runs/<old>` + manifest `VACUUM`.
329
+ - Logging is stdout-only (no structured logging); no alerting beyond cron exit codes.
330
+ - MCP transport is stdio only — wrap with an HTTP/MCP proxy to host it.
331
+ - One facts extractor is wired (rate tables); other schemas exist without extractors.
332
+ - Kasada-class anti-bot remains out of reach; the Firecrawl path handles most Cloudflare/Akamai.
333
+
334
+ ---
335
+
336
+ ## Contributing
337
+
338
+ Bug reports and features via [GitHub Issues](https://github.com/dvlshah/sift/issues/new/choose); see [CONTRIBUTING.md](./CONTRIBUTING.md). Found a security issue? Follow the private disclosure process in [SECURITY.md](./SECURITY.md) — please don't open a public issue.
339
+
340
+ ## License
341
+
342
+ [Apache-2.0](./LICENSE) — Copyright © 2026 Deval Shah.