context-rail 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 (194) hide show
  1. context_rail-0.1.0/LICENSE +21 -0
  2. context_rail-0.1.0/PKG-INFO +437 -0
  3. context_rail-0.1.0/README.md +418 -0
  4. context_rail-0.1.0/pyproject.toml +40 -0
  5. context_rail-0.1.0/setup.cfg +4 -0
  6. context_rail-0.1.0/src/context_rail/__init__.py +3 -0
  7. context_rail-0.1.0/src/context_rail/__main__.py +4 -0
  8. context_rail-0.1.0/src/context_rail/autonomy/__init__.py +85 -0
  9. context_rail-0.1.0/src/context_rail/autonomy/_contracts.py +487 -0
  10. context_rail-0.1.0/src/context_rail/autonomy/_drift.py +173 -0
  11. context_rail-0.1.0/src/context_rail/autonomy/_evidence_harvest.py +210 -0
  12. context_rail-0.1.0/src/context_rail/autonomy/_intent_match.py +145 -0
  13. context_rail-0.1.0/src/context_rail/autonomy/_pdca.py +783 -0
  14. context_rail-0.1.0/src/context_rail/autonomy/_rails.py +909 -0
  15. context_rail-0.1.0/src/context_rail/autonomy/_runs.py +947 -0
  16. context_rail-0.1.0/src/context_rail/autonomy/_runtime.py +194 -0
  17. context_rail-0.1.0/src/context_rail/autonomy.py +6 -0
  18. context_rail-0.1.0/src/context_rail/brainstorm/__init__.py +156 -0
  19. context_rail-0.1.0/src/context_rail/brainstorm/_phase_drafts.py +278 -0
  20. context_rail-0.1.0/src/context_rail/brainstorm/_plan_drafts.py +491 -0
  21. context_rail-0.1.0/src/context_rail/brainstorm/drafts.py +34 -0
  22. context_rail-0.1.0/src/context_rail/brainstorm_artifacts.py +160 -0
  23. context_rail-0.1.0/src/context_rail/brainstorm_conductor.py +440 -0
  24. context_rail-0.1.0/src/context_rail/brainstorm_core.py +459 -0
  25. context_rail-0.1.0/src/context_rail/brainstorm_synthesis.py +40 -0
  26. context_rail-0.1.0/src/context_rail/cli.py +661 -0
  27. context_rail-0.1.0/src/context_rail/context_pack.py +314 -0
  28. context_rail-0.1.0/src/context_rail/db.py +432 -0
  29. context_rail-0.1.0/src/context_rail/db_schema/__init__.py +19 -0
  30. context_rail-0.1.0/src/context_rail/db_schema/_gates.py +78 -0
  31. context_rail-0.1.0/src/context_rail/db_schema/_schema.py +763 -0
  32. context_rail-0.1.0/src/context_rail/db_schema.py +2 -0
  33. context_rail-0.1.0/src/context_rail/focus.py +306 -0
  34. context_rail-0.1.0/src/context_rail/gates.py +117 -0
  35. context_rail-0.1.0/src/context_rail/rules.py +201 -0
  36. context_rail-0.1.0/src/context_rail/server/__init__.py +289 -0
  37. context_rail-0.1.0/src/context_rail/server/_imports.py +165 -0
  38. context_rail-0.1.0/src/context_rail/server/_tool_surface.py +60 -0
  39. context_rail-0.1.0/src/context_rail/server/tools_artifacts.py +154 -0
  40. context_rail-0.1.0/src/context_rail/server/tools_autonomy.py +122 -0
  41. context_rail-0.1.0/src/context_rail/server/tools_brainstorm.py +192 -0
  42. context_rail-0.1.0/src/context_rail/server/tools_categories.py +103 -0
  43. context_rail-0.1.0/src/context_rail/server/tools_configure.py +69 -0
  44. context_rail-0.1.0/src/context_rail/server/tools_context.py +1212 -0
  45. context_rail-0.1.0/src/context_rail/server/tools_decisions.py +142 -0
  46. context_rail-0.1.0/src/context_rail/server/tools_find.py +201 -0
  47. context_rail-0.1.0/src/context_rail/server/tools_focus.py +313 -0
  48. context_rail-0.1.0/src/context_rail/server/tools_gates.py +194 -0
  49. context_rail-0.1.0/src/context_rail/server/tools_intent.py +67 -0
  50. context_rail-0.1.0/src/context_rail/server/tools_lifecycle.py +194 -0
  51. context_rail-0.1.0/src/context_rail/server/tools_notes.py +333 -0
  52. context_rail-0.1.0/src/context_rail/server/tools_orient.py +421 -0
  53. context_rail-0.1.0/src/context_rail/server/tools_phase_brainstorm.py +184 -0
  54. context_rail-0.1.0/src/context_rail/server/tools_plan_review.py +520 -0
  55. context_rail-0.1.0/src/context_rail/server/tools_planning.py +463 -0
  56. context_rail-0.1.0/src/context_rail/server/tools_projects.py +492 -0
  57. context_rail-0.1.0/src/context_rail/server/tools_retro.py +243 -0
  58. context_rail-0.1.0/src/context_rail/server/tools_risks.py +107 -0
  59. context_rail-0.1.0/src/context_rail/server/tools_roadmap.py +434 -0
  60. context_rail-0.1.0/src/context_rail/server/tools_rules.py +204 -0
  61. context_rail-0.1.0/src/context_rail/server/tools_runtime.py +25 -0
  62. context_rail-0.1.0/src/context_rail/server/tools_tasks.py +906 -0
  63. context_rail-0.1.0/src/context_rail/server.py +8 -0
  64. context_rail-0.1.0/src/context_rail/web.py +350 -0
  65. context_rail-0.1.0/src/context_rail/web_api.py +74 -0
  66. context_rail-0.1.0/src/context_rail/web_autonomy_api.py +109 -0
  67. context_rail-0.1.0/src/context_rail/web_core.py +59 -0
  68. context_rail-0.1.0/src/context_rail/web_dist/assets/AutonomyRailPanel-CbhEF78e.js +16 -0
  69. context_rail-0.1.0/src/context_rail/web_dist/assets/Badge-DLfxmmCr.js +1 -0
  70. context_rail-0.1.0/src/context_rail/web_dist/assets/BrainstormTemplate-CHDOfvGo.js +1 -0
  71. context_rail-0.1.0/src/context_rail/web_dist/assets/Button-B1Pa9rKn.js +1 -0
  72. context_rail-0.1.0/src/context_rail/web_dist/assets/CalendarTemplate-DeIunyja.js +1 -0
  73. context_rail-0.1.0/src/context_rail/web_dist/assets/DashboardTemplate-Car4j8De.js +1 -0
  74. context_rail-0.1.0/src/context_rail/web_dist/assets/DecisionsTemplate-4MnmyHue.js +1 -0
  75. context_rail-0.1.0/src/context_rail/web_dist/assets/DepsArtifactsTemplate-D-5DrBVK.js +1 -0
  76. context_rail-0.1.0/src/context_rail/web_dist/assets/Divider-D4ZEQqYw.js +1 -0
  77. context_rail-0.1.0/src/context_rail/web_dist/assets/Dot-DXSDh1s8.js +1 -0
  78. context_rail-0.1.0/src/context_rail/web_dist/assets/EntityDetailPanel-Be5U9SXA.js +1 -0
  79. context_rail-0.1.0/src/context_rail/web_dist/assets/ExecuteTemplate-BYJIQwUU.js +1 -0
  80. context_rail-0.1.0/src/context_rail/web_dist/assets/KanbanBoardTemplate-t-ZciXC6.js +1 -0
  81. context_rail-0.1.0/src/context_rail/web_dist/assets/PageHeader-R2cGDHn_.js +1 -0
  82. context_rail-0.1.0/src/context_rail/web_dist/assets/ProjectsTemplate-CNe-Wyat.js +1 -0
  83. context_rail-0.1.0/src/context_rail/web_dist/assets/ReviewTemplate-BzBmmZ8i.js +4 -0
  84. context_rail-0.1.0/src/context_rail/web_dist/assets/RisksTemplate-DsjhCA0v.js +1 -0
  85. context_rail-0.1.0/src/context_rail/web_dist/assets/SectionCard-CaEXeRuy.js +1 -0
  86. context_rail-0.1.0/src/context_rail/web_dist/assets/SettingsTemplate-K2LGnXE6.js +1 -0
  87. context_rail-0.1.0/src/context_rail/web_dist/assets/Sidebar-Dpbs2xk9.js +146 -0
  88. context_rail-0.1.0/src/context_rail/web_dist/assets/StatusPill-DjACmQdp.js +1 -0
  89. context_rail-0.1.0/src/context_rail/web_dist/assets/StructureTemplate-tHzD7-8T.js +1 -0
  90. context_rail-0.1.0/src/context_rail/web_dist/assets/TaskDetailPanel-Bn7EbFIK.js +1 -0
  91. context_rail-0.1.0/src/context_rail/web_dist/assets/Text-BIsiCk07.js +1 -0
  92. context_rail-0.1.0/src/context_rail/web_dist/assets/TimelineTemplate-CZ4ptEB1.js +1 -0
  93. context_rail-0.1.0/src/context_rail/web_dist/assets/TrashTemplate-D5Hzlygu.js +1 -0
  94. context_rail-0.1.0/src/context_rail/web_dist/assets/calendar-CL12sWTL.js +1 -0
  95. context_rail-0.1.0/src/context_rail/web_dist/assets/charts-BCwg4OMJ.js +67 -0
  96. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  97. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  98. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  99. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  100. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  101. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  102. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  103. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  104. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  105. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  106. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-400-normal-BTotfTJu.woff +0 -0
  107. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-400-normal-DZqxrq2p.woff2 +0 -0
  108. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-500-normal-ByOcLdNv.woff +0 -0
  109. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-500-normal-CocWQlwt.woff2 +0 -0
  110. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-600-normal-71GNu3SW.woff2 +0 -0
  111. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-600-normal-BGq0mW3O.woff +0 -0
  112. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-ext-400-normal-Dsrv2Tcn.woff +0 -0
  113. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-ext-400-normal-g30qAdWV.woff2 +0 -0
  114. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-ext-500-normal-Cs5J6C77.woff2 +0 -0
  115. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-ext-500-normal-DB5PtV2g.woff +0 -0
  116. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-ext-600-normal-Bz0x94Yp.woff +0 -0
  117. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-cyrillic-ext-600-normal-DUMzJB7m.woff2 +0 -0
  118. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-greek-400-normal-D9ESIMu3.woff +0 -0
  119. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-greek-400-normal-_efipK4i.woff2 +0 -0
  120. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-greek-500-normal-CuWXN6rf.woff +0 -0
  121. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-greek-500-normal-JMMifIXV.woff2 +0 -0
  122. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-greek-600-normal-D-CqTdkO.woff +0 -0
  123. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-greek-600-normal-DzTrcv_p.woff2 +0 -0
  124. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  125. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  126. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  127. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  128. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  129. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  130. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-ext-400-normal-C5H60-Va.woff2 +0 -0
  131. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-ext-400-normal-RBey6euL.woff +0 -0
  132. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-ext-500-normal-D0aIdm-b.woff +0 -0
  133. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-ext-500-normal-DakdToA3.woff2 +0 -0
  134. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-ext-600-normal-DIrixKbi.woff +0 -0
  135. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-latin-ext-600-normal-DOrvGEcy.woff2 +0 -0
  136. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-vietnamese-400-normal-DG4YqDda.woff2 +0 -0
  137. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-vietnamese-400-normal-fK1oJ5dG.woff +0 -0
  138. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-vietnamese-500-normal-BEb3_waV.woff +0 -0
  139. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-vietnamese-500-normal-e4dixQRQ.woff2 +0 -0
  140. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-vietnamese-600-normal-DgdngZtN.woff +0 -0
  141. context_rail-0.1.0/src/context_rail/web_dist/assets/ibm-plex-sans-vietnamese-600-normal-DpPYBSTl.woff2 +0 -0
  142. context_rail-0.1.0/src/context_rail/web_dist/assets/index-BWbvE675.css +1 -0
  143. context_rail-0.1.0/src/context_rail/web_dist/assets/index-CbFjhbCx.js +2 -0
  144. context_rail-0.1.0/src/context_rail/web_dist/assets/react-RRCjlvKK.js +67 -0
  145. context_rail-0.1.0/src/context_rail/web_dist/assets/sortable.esm-BNXrI9dD.js +5 -0
  146. context_rail-0.1.0/src/context_rail/web_dist/index.html +14 -0
  147. context_rail-0.1.0/src/context_rail/web_entities.py +471 -0
  148. context_rail-0.1.0/src/context_rail/web_flow.py +344 -0
  149. context_rail-0.1.0/src/context_rail/web_focus_api.py +265 -0
  150. context_rail-0.1.0/src/context_rail/web_projects.py +372 -0
  151. context_rail-0.1.0/src/context_rail.egg-info/PKG-INFO +437 -0
  152. context_rail-0.1.0/src/context_rail.egg-info/SOURCES.txt +192 -0
  153. context_rail-0.1.0/src/context_rail.egg-info/dependency_links.txt +1 -0
  154. context_rail-0.1.0/src/context_rail.egg-info/entry_points.txt +2 -0
  155. context_rail-0.1.0/src/context_rail.egg-info/requires.txt +10 -0
  156. context_rail-0.1.0/src/context_rail.egg-info/top_level.txt +1 -0
  157. context_rail-0.1.0/tests/test_agent_lanes.py +130 -0
  158. context_rail-0.1.0/tests/test_ambient_context.py +130 -0
  159. context_rail-0.1.0/tests/test_autonomy_drift.py +282 -0
  160. context_rail-0.1.0/tests/test_autonomy_record.py +118 -0
  161. context_rail-0.1.0/tests/test_brainstorm.py +444 -0
  162. context_rail-0.1.0/tests/test_brainstorm_tools.py +169 -0
  163. context_rail-0.1.0/tests/test_cli_agents.py +130 -0
  164. context_rail-0.1.0/tests/test_context_learning_loop.py +503 -0
  165. context_rail-0.1.0/tests/test_db.py +289 -0
  166. context_rail-0.1.0/tests/test_deps.py +96 -0
  167. context_rail-0.1.0/tests/test_evidence_harvest.py +136 -0
  168. context_rail-0.1.0/tests/test_evidence_validation.py +78 -0
  169. context_rail-0.1.0/tests/test_find.py +73 -0
  170. context_rail-0.1.0/tests/test_focus_tools.py +159 -0
  171. context_rail-0.1.0/tests/test_gates.py +108 -0
  172. context_rail-0.1.0/tests/test_governance_mode.py +123 -0
  173. context_rail-0.1.0/tests/test_governance_tiers.py +232 -0
  174. context_rail-0.1.0/tests/test_integration_lifecycle.py +155 -0
  175. context_rail-0.1.0/tests/test_intent_match.py +119 -0
  176. context_rail-0.1.0/tests/test_non_blocking_pdca.py +124 -0
  177. context_rail-0.1.0/tests/test_notes.py +104 -0
  178. context_rail-0.1.0/tests/test_orient.py +322 -0
  179. context_rail-0.1.0/tests/test_parallel_chat_safety.py +134 -0
  180. context_rail-0.1.0/tests/test_plan_review.py +608 -0
  181. context_rail-0.1.0/tests/test_project_create.py +106 -0
  182. context_rail-0.1.0/tests/test_retro.py +120 -0
  183. context_rail-0.1.0/tests/test_routing.py +338 -0
  184. context_rail-0.1.0/tests/test_runtime_check.py +254 -0
  185. context_rail-0.1.0/tests/test_runtime_integration.py +163 -0
  186. context_rail-0.1.0/tests/test_schema_invariants.py +68 -0
  187. context_rail-0.1.0/tests/test_smoke_v2.py +183 -0
  188. context_rail-0.1.0/tests/test_smoke_vibe.py +381 -0
  189. context_rail-0.1.0/tests/test_task_lifecycle.py +138 -0
  190. context_rail-0.1.0/tests/test_task_title_validation.py +110 -0
  191. context_rail-0.1.0/tests/test_tool_registry_integrity.py +181 -0
  192. context_rail-0.1.0/tests/test_tool_surface.py +101 -0
  193. context_rail-0.1.0/tests/test_usability_fixes.py +301 -0
  194. context_rail-0.1.0/tests/test_web.py +403 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,437 @@
1
+ Metadata-Version: 2.4
2
+ Name: context-rail
3
+ Version: 0.1.0
4
+ Summary: Context Rail — agentic task-management that keeps your project on rails.
5
+ License: MIT
6
+ Project-URL: Repository, https://github.com/nguyenhoanhson797/Context-Rail
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: mcp>=1.0.0
11
+ Provides-Extra: web
12
+ Requires-Dist: fastapi>=0.115; extra == "web"
13
+ Requires-Dist: uvicorn>=0.30; extra == "web"
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest>=8; extra == "test"
16
+ Requires-Dist: pytest-asyncio>=0.24; extra == "test"
17
+ Requires-Dist: fastapi>=0.115; extra == "test"
18
+ Dynamic: license-file
19
+
20
+ # Context-Rail
21
+
22
+ **A local project rail for long-running agentic work.**
23
+
24
+ AI agents are good at individual tasks. Long projects drift — they forget the plan, lose context between sessions, repeat bad actions, mark work done without review, and start every session like the project is new.
25
+
26
+ Context-Rail keeps the project on rail by giving both the **human** and the **agent** the same structured project state. It is not a chatbot memory file. It is not a code indexer. It is a **local operating loop for agent work**.
27
+
28
+ ```text
29
+ PLAN → EXECUTE → REVIEW → ACT
30
+ ```
31
+
32
+ Built with **Python + SQLite + MCP**.
33
+
34
+ ---
35
+
36
+ ## Install
37
+
38
+ **Core (MCP server + CLI — lightweight, no web deps):**
39
+
40
+ ```bash
41
+ pip install git+https://github.com/nguyenhoanhson797/Context-Rail.git
42
+ ```
43
+
44
+ **With web UI (adds FastAPI + Uvicorn):**
45
+
46
+ ```bash
47
+ pip install "git+https://github.com/nguyenhoanhson797/Context-Rail.git#egg=context-rail[web]"
48
+ ```
49
+
50
+ Initialize:
51
+
52
+ ```bash
53
+ ctx-rail init
54
+ ```
55
+
56
+ This creates the local SQLite database, generates an `AGENTS.md` in the current directory (so your agent knows the CR workflow), and installs CR skills to `.agents/skills/context-rail/`.
57
+
58
+ Connect to your MCP client:
59
+
60
+ ```bash
61
+ ctx-rail config
62
+ ```
63
+
64
+ This prints the correct config with the absolute Python path — important on Windows where bare `python` may resolve to the wrong interpreter. Paste it into your MCP client config:
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "context-rail": {
70
+ "command": "C:/Python313/python.exe",
71
+ "args": ["-m", "context_rail", "serve"]
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ For Codex (TOML format):
78
+
79
+ ```bash
80
+ ctx-rail config --client codex
81
+ ```
82
+
83
+ Update later (upgrades the package + refreshes AGENTS.md + skills):
84
+
85
+ ```bash
86
+ ctx-rail update
87
+ ```
88
+
89
+ Start the MCP server:
90
+
91
+ ```bash
92
+ ctx-rail serve
93
+ ```
94
+
95
+ Start the web platform (requires `[web]` install):
96
+
97
+ ```bash
98
+ ctx-rail web # API + React UI (default)
99
+ ctx-rail web --no-frontend # API only
100
+ ```
101
+
102
+ ---
103
+
104
+ ## A session with Context-Rail
105
+
106
+ This is what it feels like to work with CR — not a tool catalog, but the flow an agent actually follows.
107
+
108
+ ### 1. Start — the agent already knows
109
+
110
+ The agent opens a session and calls one tool:
111
+
112
+ ```text
113
+ session_start(agent_id="codex-1", workdir="/path/to/repo")
114
+ ```
115
+
116
+ It gets back everything it needs in one response:
117
+
118
+ * which project is active (via workspace binding — survives across sessions);
119
+ * the roadmap story — intent, success criteria, non-goals;
120
+ * the current phase and its progress;
121
+ * the next task with dependencies and context items;
122
+ * open warnings (blocked tasks, tasks needing evidence);
123
+ * governance status — is there an intent tree? an approved plan contract?
124
+
125
+ If the workspace isn't bound yet, the agent binds it once:
126
+
127
+ ```text
128
+ project_login("project-id", agent_id="codex-1", workdir="/path/to/repo")
129
+ ```
130
+
131
+ From then on, every session in that workspace opens with the correct project automatically.
132
+
133
+ The agent does not guess what to do next. It does not start from zero.
134
+
135
+ ### 2. Plan — natural brainstorm, not a blank form
136
+
137
+ Before jumping into tasks, CR runs a **brainstorm** — a natural conversation proportional to the idea. It can shape:
138
+
139
+ * a whole project (vision, phases, roadmap, risks);
140
+ * one phase or one goal;
141
+ * one feature or task;
142
+ * a refinement or an option comparison;
143
+ * an execution plan.
144
+
145
+ The conversation stays friendly. The agent drafts the plan. The human reviews it. Only approved plans become committed project work.
146
+
147
+ Approval creates a **plan contract** — not just old context. That contract carries the goal, quality bar, autonomy boundaries, evidence rules, stop rules, plan snapshot, drift rules, and rail-check policy that later execution must follow.
148
+
149
+ ### 3. Focus — context sticks to the task
150
+
151
+ The agent calls:
152
+
153
+ ```text
154
+ focus(agent_id="codex-1", agent_name="Codex", harness="codex", role="builder")
155
+ ```
156
+
157
+ It gets the execution packet for the next task:
158
+
159
+ * task description, dependencies, notes, handoffs;
160
+ * risks, lessons, artifacts, related goals;
161
+ * active agents working on the task;
162
+ * review state;
163
+ * PDCA stage, contract constraints, required evidence, stop conditions, rail-check status.
164
+
165
+ Context is not floating in a chat log. It is **attached to the task**. The agent loads what it needs, not the whole project.
166
+
167
+ When `agent_id` is provided, CR clocks that agent into the task. If the agent was active on another task, the older session is released. When the task is done or blocked, active work sessions close. This keeps ownership flexible while answering: "which agent is doing this right now?"
168
+
169
+ ### 4. Work — guardrails that adapt to risk
170
+
171
+ The agent works freely — editing, testing, browsing, debugging. CR does not micromanage every tool call.
172
+
173
+ For risky or repeated actions, the agent can call:
174
+
175
+ ```text
176
+ check_action(kind="retry", context_json='{"path": "/abs/path", "error": "..."}')
177
+ ```
178
+
179
+ CR returns Allow, Warn, or Block based on project rules.
180
+
181
+ The key design point: **guardrails adapt to risk**. Not every task needs the same ceremony:
182
+
183
+ | Lane | Tier | Behavior |
184
+ |------|------|----------|
185
+ | `tiny` | T0 | Skip PDCA entirely — just flip status to done |
186
+ | `normal` | T1 | Lightweight cycle check, evidence validation relaxed |
187
+ | `high_risk` | T2 | Full governance — evidence, review, drift, rail-check |
188
+
189
+ This means a typo fix doesn't go through the same pipeline as an architecture change. The agent picks the lane when adding the task; CR handles the rest.
190
+
191
+ ### 5. Done — evidence is harvested, not asked for
192
+
193
+ When the agent calls `done()`, CR does not ask "please attach evidence." It **harvests evidence automatically** — git diffs, test results, file changes — and records it to the PDCA cycle.
194
+
195
+ If evidence is insufficient, the task is flagged `needs_evidence` — visible in the next `session_start()` or `focus()` call. The agent can supplement it or the human can override.
196
+
197
+ Evidence is validated before it satisfies a required rule. A failing test result or empty manual check does not count as proof.
198
+
199
+ `done()` also returns the **next task with its context** — so the agent can continue without a separate `focus()` call.
200
+
201
+ ### 6. Review — lessons become future work
202
+
203
+ After a phase, the agent or human runs a retro:
204
+
205
+ ```text
206
+ retro(phase_id="...")
207
+ ```
208
+
209
+ Then turns improvements into next-phase tasks:
210
+
211
+ ```text
212
+ retro(action="act")
213
+ ```
214
+
215
+ Lessons don't stay as passive notes. They affect future tasks, risks, rules, and reviews. Decisions are recorded with `decision_create()` so direction changes are visible and queryable.
216
+
217
+ ### 7. Resume — next session picks up where this one left
218
+
219
+ CR stores project state locally in SQLite. The next session recovers:
220
+
221
+ * current project (via workspace binding);
222
+ * active plan contract and autonomy run;
223
+ * PDCA cycle state, rail-check result;
224
+ * active phase, task queue, blocked work;
225
+ * notes, lessons, risks, artifacts, rules, review state, retros.
226
+
227
+ This makes CR useful for multi-day, multi-session, and multi-agent work.
228
+
229
+ ---
230
+
231
+ ## How Context-Rail adapts
232
+
233
+ ### Governance on/off
234
+
235
+ Not every project needs heavy governance. `project_create(governance=False)` switches to **lightweight mode**:
236
+
237
+ * `check_action` returns Allow or Warn — never Block;
238
+ * PDCA runs **non-blocking** — warnings instead of gates;
239
+ * direction guard is off;
240
+ * auto-evidence harvesting still works (always on).
241
+
242
+ This is the "OS background" metaphor: CR runs quietly, records what happened, warns when something looks off — but doesn't get in the way.
243
+
244
+ ### Intent tree — the living plan
245
+
246
+ Plans are not frozen at approval. CR maintains an **intent tree** — a living structure of what the project is trying to achieve:
247
+
248
+ ```text
249
+ intent_plant(title="User auth", intent="Secure login without friction",
250
+ success_criteria="2FA optional, <3s login", non_goals="No SSO")
251
+ intent_list()
252
+ intent_check(task_title="Add OAuth provider") → matches or warns off-plan
253
+ ```
254
+
255
+ When a new task doesn't match any intent node, CR warns. The tree grows with the project — plant new intents as scope evolves.
256
+
257
+ ### Context items — knowledge that sticks
258
+
259
+ CR has a scoped knowledge store (`context_items`) that attaches to tasks, phases, goals, and roadmaps:
260
+
261
+ ```text
262
+ context_add(scope_type="task", scope_id="...", content="API uses Bearer token", kind="reference")
263
+ context_pack(task_id="...") → relevant items for that task
264
+ context_wiki() → browse all knowledge grouped by kind
265
+ context_verify(id="...") → refresh stale items
266
+ context_health() → coverage and freshness report
267
+ ```
268
+
269
+ Context items have lifecycle: seed → grow → maintain → serve. Stale items are flagged. The agent uses `context_apply()` to mark items as used, keeping the knowledge loop alive.
270
+
271
+ ### Roadmaps — project genesis
272
+
273
+ Roadmaps are the entry point for every project — high-level initiatives, milestones, or bets that define the vision. Each roadmap carries:
274
+
275
+ * **intent** — why it matters strategically;
276
+ * **success_criteria** — what done looks like;
277
+ * **background** — context for the initiative;
278
+ * **non_goals** — what's explicitly out of scope;
279
+ * **stakeholders_note** — who cares and why;
280
+ * **progress** — auto-rolled up from phases → tasks.
281
+
282
+ The brainstorm conductor Stage 0 asks for initiatives before phases. Roadmaps link to phases; phases link to tasks; done tasks roll progress up to the roadmap automatically.
283
+
284
+ ### Multi-agent lanes
285
+
286
+ Different agents can have narrower rails:
287
+
288
+ ```text
289
+ rail_policy_set(agent_id="ui-bot", task_tags="ui")
290
+ rail_policy_set(agent_id="api-bot", task_tags="backend")
291
+ ```
292
+
293
+ An agent-specific rail can restrict what that agent touches. It cannot loosen stop rules, remove evidence requirements, or bypass phase gates.
294
+
295
+ `runtime_status()` is the single source of truth — it reports whether the agent can proceed and, if not, an ordered list of blockers across all enforcement layers (rail-check, PDCA, lease, drift).
296
+
297
+ ### Unified configuration
298
+
299
+ One tool replaces six:
300
+
301
+ ```text
302
+ configure(action="update_project", name="...", budget="high")
303
+ configure(action="add_rule", rule_kind="retry", rule_threshold='{"max": 3}')
304
+ configure(action="list_rules")
305
+ configure(action="remove_rule", rule_id="...")
306
+ configure(action="reset_session")
307
+ ```
308
+
309
+ ---
310
+
311
+ ## For humans
312
+
313
+ CR answers the questions a human actually has:
314
+
315
+ ```text
316
+ What are we building? → roadmap story
317
+ Where are we now? → phase + progress
318
+ What should happen next? → next task
319
+ What is blocked? → warnings in session_start
320
+ What needs review? → review state on tasks
321
+ What did we learn? → lessons, retros, decisions
322
+ What should change next phase? → retro → act
323
+ ```
324
+
325
+ The human does not micromanage every tool call. They review direction, approve plans, resolve blockers, and keep authority over important decisions.
326
+
327
+ ---
328
+
329
+ ## For agents
330
+
331
+ ```text
332
+ 1. session_start(agent_id="...", workdir="/path/to/repo")
333
+ If unbound, call project_login() to bind the workspace.
334
+
335
+ 2. Read the response — project, phase, next task, context, warnings, governance.
336
+
337
+ 3. autonomy_start() to activate PDCA evidence loop and lease tracking.
338
+ (Without this, done()/block() skip the evidence gate.)
339
+
340
+ 4. focus() on the next task. Pass agent_id if the harness has identity.
341
+
342
+ 5. Work freely. Save findings with note(). Save lessons with learn().
343
+ Record direction changes with decision_create().
344
+
345
+ 6. done() when complete — evidence is auto-harvested. Next task is returned.
346
+ block() when stuck or a stop rule fires.
347
+
348
+ 7. retro() when a phase ends. Convert improvements into future tasks.
349
+
350
+ If unsure whether a stop is in effect, call runtime_status().
351
+ ```
352
+
353
+ ---
354
+
355
+ ## Core objects
356
+
357
+ ```text
358
+ Project
359
+ ├─ Roadmap (vision, intent, success criteria, progress rollup)
360
+ │ └─ Phase
361
+ │ └─ Task (lane: tiny | normal | high_risk)
362
+ │ ├─ Context items (scoped knowledge)
363
+ │ ├─ Dependencies
364
+ │ ├─ Handoffs
365
+ │ ├─ Active agent sessions
366
+ │ └─ Review state
367
+ ├─ Goals ←→ Tasks (N:N links)
368
+ ├─ Intent nodes (living plan tree)
369
+ ├─ Plan contracts (approved plan → execution binding)
370
+ ├─ Autonomy runs / PDCA cycles (lease, evidence, drift)
371
+ ├─ Categories
372
+ │ ├─ Risks
373
+ │ ├─ Lessons
374
+ │ └─ Artifacts
375
+ ├─ Rules
376
+ ├─ Gates
377
+ └─ Retros
378
+ ```
379
+
380
+ <details>
381
+ <summary>Diagram: data model</summary>
382
+
383
+ ```mermaid
384
+ erDiagram
385
+ PROJECT ||--o{ ROADMAP : defines
386
+ ROADMAP ||--o{ PHASE : scopes
387
+ PROJECT ||--o{ PHASE : contains
388
+ PHASE ||--o{ TASK : tracks
389
+ PROJECT ||--o{ GOAL : defines
390
+ GOAL }o--o{ TASK : links
391
+ PROJECT ||--o{ INTENT_NODE : intends
392
+ PROJECT ||--o{ PLAN_CONTRACT : binds
393
+ PROJECT ||--o{ AUTONOMY_RUN : executes
394
+ AUTONOMY_RUN ||--o{ PDCA_CYCLE : cycles
395
+ TASK ||--o{ CONTEXT_ITEM : carries
396
+ TASK ||--o{ AGENT_WORK_SESSION : has
397
+ PROJECT ||--o{ RULE : guards
398
+ PROJECT ||--o{ GATE : reviews
399
+ PHASE ||--o{ RETRO : reviews
400
+ CATEGORY ||--o{ RISK : owns
401
+ CATEGORY ||--o{ LESSON : owns
402
+ CATEGORY ||--o{ ARTIFACT : owns
403
+ ```
404
+
405
+ </details>
406
+
407
+ ---
408
+
409
+ ## Useful commands
410
+
411
+ ```bash
412
+ ctx-rail init # Initialize database + AGENTS.md + skills
413
+ ctx-rail serve # Start MCP server (stdio)
414
+ ctx-rail config # Print MCP client config (correct Python path)
415
+ ctx-rail config --client codex # TOML format for Codex
416
+ ctx-rail status # Show active project, DB location, counts
417
+ ctx-rail doctor # Health check: DB, schema, skills, AGENTS.md, MCP config
418
+ ctx-rail web # Start web platform (requires [web] install)
419
+ ctx-rail update # Upgrade package + refresh AGENTS.md + skills
420
+ ```
421
+
422
+ ---
423
+
424
+ ## What Context-Rail is not
425
+
426
+ * a code indexer;
427
+ * a semantic search engine;
428
+ * a replacement for Git, Jira, or Linear;
429
+ * a replacement for Cursor, Claude Code, Codex, or GitNexus.
430
+
431
+ Context-Rail sits beside those tools as the **agent work rail**. Use code intelligence tools to understand the codebase. Use Context-Rail to keep the project plan, task flow, reviews, risks, lessons, and execution memory on track.
432
+
433
+ ---
434
+
435
+ ## License
436
+
437
+ MIT