context-rail 0.2.1__tar.gz → 0.2.2__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 (112) hide show
  1. {context_rail-0.2.1/src/context_rail.egg-info → context_rail-0.2.2}/PKG-INFO +1 -1
  2. {context_rail-0.2.1 → context_rail-0.2.2}/pyproject.toml +2 -2
  3. context_rail-0.2.2/src/context_rail/skills/daily/SKILL.md +114 -0
  4. context_rail-0.2.2/src/context_rail/skills/governance/SKILL.md +135 -0
  5. context_rail-0.2.2/src/context_rail/skills/orchestration/SKILL.md +168 -0
  6. context_rail-0.2.2/src/context_rail/skills/setup/SKILL.md +249 -0
  7. context_rail-0.2.2/src/context_rail/skills/wiki/SKILL.md +227 -0
  8. {context_rail-0.2.1 → context_rail-0.2.2/src/context_rail.egg-info}/PKG-INFO +1 -1
  9. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail.egg-info/SOURCES.txt +5 -0
  10. {context_rail-0.2.1 → context_rail-0.2.2}/LICENSE +0 -0
  11. {context_rail-0.2.1 → context_rail-0.2.2}/README.md +0 -0
  12. {context_rail-0.2.1 → context_rail-0.2.2}/setup.cfg +0 -0
  13. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/__init__.py +0 -0
  14. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/__main__.py +0 -0
  15. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/__init__.py +0 -0
  16. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_contracts.py +0 -0
  17. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_drift.py +0 -0
  18. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_evidence_harvest.py +0 -0
  19. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_intent_match.py +0 -0
  20. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_pdca.py +0 -0
  21. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_rails.py +0 -0
  22. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_runs.py +0 -0
  23. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy/_runtime.py +0 -0
  24. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/autonomy.py +0 -0
  25. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm/__init__.py +0 -0
  26. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm/_phase_drafts.py +0 -0
  27. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm/_plan_drafts.py +0 -0
  28. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm/drafts.py +0 -0
  29. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm_artifacts.py +0 -0
  30. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm_conductor.py +0 -0
  31. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm_core.py +0 -0
  32. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/brainstorm_synthesis.py +0 -0
  33. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/cli.py +0 -0
  34. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/context_pack.py +0 -0
  35. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/db.py +0 -0
  36. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/db_schema/__init__.py +0 -0
  37. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/db_schema/_gates.py +0 -0
  38. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/db_schema/_schema.py +0 -0
  39. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/db_schema.py +0 -0
  40. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/focus.py +0 -0
  41. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/gates.py +0 -0
  42. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/rules.py +0 -0
  43. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/__init__.py +0 -0
  44. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/_imports.py +0 -0
  45. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/_tool_surface.py +0 -0
  46. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_artifacts.py +0 -0
  47. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_autonomy.py +0 -0
  48. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_brainstorm.py +0 -0
  49. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_categories.py +0 -0
  50. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_configure.py +0 -0
  51. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_context.py +0 -0
  52. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_decisions.py +0 -0
  53. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_find.py +0 -0
  54. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_focus.py +0 -0
  55. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_gates.py +0 -0
  56. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_intent.py +0 -0
  57. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_lifecycle.py +0 -0
  58. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_notes.py +0 -0
  59. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_orient.py +0 -0
  60. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_phase_brainstorm.py +0 -0
  61. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_plan_review.py +0 -0
  62. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_planning.py +0 -0
  63. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_projects.py +0 -0
  64. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_retro.py +0 -0
  65. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_risks.py +0 -0
  66. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_roadmap.py +0 -0
  67. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_rules.py +0 -0
  68. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_runtime.py +0 -0
  69. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server/tools_tasks.py +0 -0
  70. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail/server.py +0 -0
  71. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail.egg-info/dependency_links.txt +0 -0
  72. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail.egg-info/entry_points.txt +0 -0
  73. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail.egg-info/requires.txt +0 -0
  74. {context_rail-0.2.1 → context_rail-0.2.2}/src/context_rail.egg-info/top_level.txt +0 -0
  75. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_agent_lanes.py +0 -0
  76. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_ambient_context.py +0 -0
  77. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_autonomy_drift.py +0 -0
  78. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_autonomy_record.py +0 -0
  79. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_brainstorm.py +0 -0
  80. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_brainstorm_tools.py +0 -0
  81. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_cli_agents.py +0 -0
  82. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_context_learning_loop.py +0 -0
  83. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_db.py +0 -0
  84. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_deps.py +0 -0
  85. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_evidence_harvest.py +0 -0
  86. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_evidence_validation.py +0 -0
  87. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_find.py +0 -0
  88. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_focus_tools.py +0 -0
  89. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_gates.py +0 -0
  90. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_governance_mode.py +0 -0
  91. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_governance_tiers.py +0 -0
  92. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_integration_lifecycle.py +0 -0
  93. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_intent_match.py +0 -0
  94. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_non_blocking_pdca.py +0 -0
  95. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_notes.py +0 -0
  96. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_orient.py +0 -0
  97. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_parallel_chat_safety.py +0 -0
  98. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_plan_review.py +0 -0
  99. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_project_create.py +0 -0
  100. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_retro.py +0 -0
  101. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_routing.py +0 -0
  102. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_runtime_check.py +0 -0
  103. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_runtime_integration.py +0 -0
  104. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_schema_invariants.py +0 -0
  105. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_smoke_v2.py +0 -0
  106. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_smoke_vibe.py +0 -0
  107. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_task_lifecycle.py +0 -0
  108. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_task_title_validation.py +0 -0
  109. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_tool_registry_integrity.py +0 -0
  110. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_tool_surface.py +0 -0
  111. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_usability_fixes.py +0 -0
  112. {context_rail-0.2.1 → context_rail-0.2.2}/tests/test_web.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: context-rail
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Context Rail — agentic task-management that keeps your project on rails.
5
5
  License: MIT
6
6
  Project-URL: Repository, https://github.com/nguyenhoanhson797/Context-Rail
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "context-rail"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Context Rail — agentic task-management that keeps your project on rails."
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -33,4 +33,4 @@ Repository = "https://github.com/nguyenhoanhson797/Context-Rail"
33
33
  where = ["src"]
34
34
 
35
35
  [tool.setuptools.package-data]
36
- context_rail = []
36
+ context_rail = ["skills/**/*"]
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: context-rail-daily
3
+ description: "Context Rail day-to-day workflow — capture reflex, project facts, session startup, find() search, memory vs CR boundary."
4
+ version: 1.0.0
5
+ author: Context Rail
6
+ license: MIT
7
+ platforms: [linux, macos, windows]
8
+ metadata:
9
+ hermes:
10
+ tags: [Context-Rail, Capture, Project-Facts, Daily-Workflow, Session-Startup]
11
+ related_skills: [context-rail-governance, context-rail-orchestration]
12
+ ---
13
+
14
+ # Context Rail — Daily Workflow
15
+
16
+ The minimal daily loop for using Context Rail on every task. Load this skill at session start to get the capture reflex and avoid the memory() trap.
17
+
18
+ ## Session Startup (MANDATORY)
19
+
20
+ Every session starts with these 3 calls — in order. Never skip a step.
21
+
22
+ ```
23
+ 1. orient(workdir="/path/to/repo") — project status + recently captured items
24
+ 2. find("task keywords") — search ALL context before working
25
+ 3. focus() — get task execution packet
26
+ ```
27
+
28
+ `orient()` shows "Recently Captured" items — if you see the fact you need there, skip `find()`.
29
+ `find()` searches context_items, tasks, lessons, project_notes, decisions, risks — everything.
30
+ `focus()` returns context_pack with inherited project facts from the scope hierarchy.
31
+
32
+ ## The Capture Boundary (CRITICAL — VIOLATE THIS AND YOU WASTE SESSIONS)
33
+
34
+ ```
35
+ ┌─────────────────────────────────────────────────────┐
36
+ │ Project codebase facts → note(content, kind="...") │
37
+ │ Agent environment facts → memory() │
38
+ │ │
39
+ │ NEVER use memory() for project facts. │
40
+ │ NEVER re-discover the same fact across sessions. │
41
+ │ If you found it once, it belongs in Context Rail. │
42
+ └─────────────────────────────────────────────────────┘
43
+ ```
44
+
45
+ ### What is a "project fact"?
46
+
47
+ - Run commands: `yarn test tests/agent-chat/`, `npm run build`
48
+ - Test patterns: "mock DB in conftest.py, use pytest fixtures"
49
+ - Architecture notes: "API at localhost:4175, 3 microservices"
50
+ - API endpoints: `POST /api/v2/tasks`, `GET /api/v2/projects`
51
+ - File locations: "tests live in tests/agent-chat/, 3 test files"
52
+ - Configuration: "use .env.local for dev, .env for CI"
53
+
54
+ ### What is an "environment fact" (→ memory)?
55
+
56
+ - Host details: "Python 3.13 at /c/Python313/python.exe"
57
+ - Tool quirks: "patch tool replace_all is dangerous on this host"
58
+ - Shell syntax: "use bash not PowerShell on this Windows host"
59
+ - Path conventions: "venv at ~/AppData/Local/hermes/"
60
+
61
+ ## Quick Capture (2 params, always works)
62
+
63
+ ```
64
+ note(content, kind="reference")
65
+ ```
66
+
67
+ With `task_id`: writes to task_context (task-scoped, surfaces in focus()).
68
+ Without `task_id`: writes to context_items as project-scoped (surfaces in find(), orient(), context_pack).
69
+
70
+ Valid kinds: `reference`, `command`, `finding`, `note`, `decision`, `link`, `warning`, `file_path`, `file_touched`, `attempt`
71
+
72
+ ### Capture reflex checklist
73
+
74
+ After any of these actions, immediately note() the finding:
75
+ - Discovered a run command → `note("yarn test tests/agent-chat/", kind="command")`
76
+ - Found a test pattern → `note("mock DB in conftest.py", kind="reference")`
77
+ - Located an API endpoint → `note("POST /api/v2/tasks", kind="reference")`
78
+ - Hit a pitfall → `note("watch out for X when doing Y", kind="warning")`
79
+
80
+ ## Search First, Discover Later
81
+
82
+ Before using `search_files`, `read_file`, or `grep` to find project information:
83
+ 1. Call `find("keywords")` first
84
+ 2. If it returns results — use them, don't re-discover
85
+ 3. If it returns empty — discover from source, then `note()` it for next time
86
+
87
+ ## Task Completion
88
+
89
+ ```
90
+ done(task_id) — marks task complete
91
+ block(task_id, reason) — marks task blocked
92
+ ```
93
+
94
+ `done()` has a soft gate: if context items were presented but none were touched, it warns.
95
+ Second `done()` call always succeeds. This is a speed bump, not a wall.
96
+
97
+ ## Common Anti-Patterns
98
+
99
+ | Anti-pattern | Why it's wrong |
100
+ |---|---|
101
+ | `memory.add("yarn test")` | Project fact in memory — invisible to find(), not scoped, not shared |
102
+ | Calling `search_files("yarn")` before `find("yarn")` | Context Rail already has it — re-discovering wastes 10+ tool calls |
103
+ | Skipping `orient()` at session start | Missing gap alerts, recently captured items, project status |
104
+ | Using `context_add(19 params)` for a simple run command | Overkill — `note(content, kind="command")` is 2 params |
105
+
106
+ ## Verification
107
+
108
+ After implementing a task, verify the capture loop works:
109
+ 1. `note("test fact", kind="reference")` → "Project note saved"
110
+ 2. `orient()` → see the fact in "Recently Captured"
111
+ 3. `find("test fact")` → see the fact in context_items
112
+ 4. `focus()` → see the fact in context_pack under "project"
113
+
114
+ If any step fails, Context Rail needs attention — report it.
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: context-rail-governance
3
+ description: "Context Rail governance patterns — brainstorm, plan_review, autonomy PDCA, retros, evidence validation, context learning loop."
4
+ version: 1.0.0
5
+ author: Context Rail
6
+ license: MIT
7
+ platforms: [linux, macos, windows]
8
+ metadata:
9
+ hermes:
10
+ tags: [Context-Rail, Governance, PDCA, Planning, Retros, Evidence, Autonomy]
11
+ related_skills: [context-rail-daily, context-rail-orchestration]
12
+ ---
13
+
14
+ # Context Rail — Governance
15
+
16
+ Planned work patterns: brainstorm, approve, execute with PDCA checks, retro, act. Load this when working on structured phases, not quick tasks.
17
+
18
+ ## Plan Flow
19
+
20
+ ```
21
+ brainstorm(goal="...")
22
+ ↓
23
+ brainstorm_continue(answer) × 7 stages:
24
+ roadmap → frame → explore → challenge → converge → plan → approve
25
+ ↓
26
+ plan_review(action="gates") — evaluate gates, provide evidence
27
+ ↓
28
+ plan_review(action="approve") — commit to database, create active contract
29
+ ↓
30
+ autonomy_start() — begin PDCA execution
31
+ ```
32
+
33
+ ### Brainstorm gates
34
+
35
+ Each gate in `plan_review(action="gates")` needs a YES/NO + evidence:
36
+ - `proj_gap_coverage` — does the plan cover all requirements?
37
+ - `proj_scope_boundary` — are non-goals explicitly excluded?
38
+ - `proj_dependency_order` — are phases ordered correctly?
39
+ - 5 more gates available
40
+
41
+ Evidence must include a `falsifier` (test kind: runnable command that FAILS if wrong) or `file_path` (manual_check kind: path the validator can check exists).
42
+
43
+ ## Execute Flow (PDCA)
44
+
45
+ ```
46
+ orient() → see contract, lease, rail-check, stop state
47
+ ↓
48
+ focus() → get execution packet with context_pack
49
+ ↓
50
+ harness work → note/learn/decision as you go
51
+ ↓
52
+ autonomy_record(do_json, evidence_json) → record what was done
53
+ ↓
54
+ autonomy_gate("rail_check") → check gates before next cycle
55
+ ↓
56
+ done(task_id) → complete task (triggers PDCA cycle check)
57
+ ↓
58
+ block(task_id, reason) → if blocked, stop the cycle
59
+ ```
60
+
61
+ ### Evidence format
62
+
63
+ ```json
64
+ // For test evidence:
65
+ {"kind": "test", "falsifier": "pytest tests/test_x.py -k 'test_feature'", "summary": "All 5 scenarios pass"}
66
+
67
+ // For manual check evidence:
68
+ {"kind": "manual_check", "file_path": "docs/architecture.md", "summary": "Architecture documented"}
69
+ ```
70
+
71
+ ## Review Flow
72
+
73
+ After a phase completes:
74
+ ```
75
+ retro(phase_id) → view retros for this phase
76
+
77
+ retro(phase_id,
78
+ went_well="What worked",
79
+ went_wrong="What didn't",
80
+ improve="What to change"
81
+ ) → write retro
82
+
83
+ retro(action="act") → convert improve items into tasks for next phase
84
+ ```
85
+
86
+ ## Context Learning Loop
87
+
88
+ For governance-level context (scoped, ranked, validated):
89
+
90
+ ```
91
+ focus() → context_pack + recommended_reads
92
+
93
+ For items used: context_apply(id) — bumps applied_count
94
+ For correct items: context_verify(id) — updates freshness
95
+ For wrong/stale: context_update(id, content=...) — fixes stale info
96
+ For missing info: context_add(title, content, scope_type="phase", scope_id="...", priority=80)
97
+
98
+ Health check: context_health() — after several tasks
99
+ Improvement ideas: context_propose() — mechanical proposals from friction patterns
100
+ Friction log: autonomy_record(do_json='{"harness_friction":"...","context_items_read":[...]}"')
101
+ ```
102
+
103
+ ## Decisions (provenance)
104
+
105
+ ```
106
+ decision_create(question="...", choice="X", rationale="because Y",
107
+ alternatives=["A", "B"], category="architecture")
108
+ decision_list() — browse before re-litigating
109
+ ```
110
+
111
+ ## Autonomy Run Management
112
+
113
+ ```
114
+ autonomy_status() — view active run state
115
+ autonomy_next(max_cycles=3) — get next execution packet
116
+ autonomy_gate(action="resume") — resume after stop
117
+ rail_policy_set(phase_ids="...", category_ids="...") — narrow agent lane
118
+ ```
119
+
120
+ ## Rail-check Resolution
121
+
122
+ When a rail-check stop occurs:
123
+ 1. Read the `stop_reason` from `autonomy_status()` or `runtime_status()`
124
+ 2. Fix the underlying issue (add evidence, resolve dependency, etc.)
125
+ 3. Call `autonomy_gate(action="resume", notes="Fixed X")` to continue
126
+
127
+ ## Common Governance Pitfalls
128
+
129
+ | Pitfall | Fix |
130
+ |---|---|
131
+ | Evidence without `falsifier` or `file_path` | Evidence marked invalid_or_insufficient_evidence |
132
+ | `plan_phase` ignores `project_id` param | Call `project_set_active` first, all MCP calls in one subprocess |
133
+ | `task_add` missing phase_id | Must pass both `phase_id` AND `project_id` |
134
+ | `tags` as comma-separated string | Must be JSON array: `'["tag1","tag2"]'` |
135
+ | State.json split-brain | Use `workdir` + `agent_id` on every call |
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: context-rail-orchestration
3
+ description: "Context Rail multi-agent orchestration — delegation, lanes, N:N goal-task DAGs, rail policies, subagent-driven development."
4
+ version: 1.0.0
5
+ author: Context Rail
6
+ license: MIT
7
+ platforms: [linux, macos, windows]
8
+ metadata:
9
+ hermes:
10
+ tags: [Context-Rail, Multi-Agent, Orchestration, Delegation, DAG, Subagent]
11
+ related_skills: [context-rail-daily, context-rail-governance]
12
+ ---
13
+
14
+ # Context Rail — Orchestration
15
+
16
+ Multi-agent patterns: delegate tasks, design N:N goal-task DAGs, enforce rail policies, run two-stage reviews. Load for large features and parallel workstreams.
17
+
18
+ ## Agent Roles
19
+
20
+ | Role | Depth | Can spawn | Use case |
21
+ |---|---|---|---|
22
+ | **leaf** (default) | 0 | Cannot delegate further | Single atomic task |
23
+ | **orchestrator** | 1 | Can spawn 2-3 leaves | Coordinates sub-tasks toward a goal |
24
+
25
+ Max spawn depth: 2. Max concurrent children: 5. Orchestrators track their children and synthesize results.
26
+
27
+ ## Task Lanes
28
+
29
+ ```
30
+ task_add(title="...", lane="tiny|normal|high_risk")
31
+ ```
32
+
33
+ | Lane | Token budget | Review required | Use case |
34
+ |---|---|---|---|
35
+ | `tiny` | ~2K tokens | No | Copy changes, labels, one-line fixes |
36
+ | `normal` | ~5K tokens | No | Standard features and bug fixes |
37
+ | `high_risk` | ~10K tokens | **Yes** | Auth, schema migrations, API changes |
38
+
39
+ High-risk tasks automatically set `review_required=true` and get expanded context packs.
40
+
41
+ ## Delegation Patterns
42
+
43
+ ### Pattern 1: Simple split (2-3 leaves)
44
+
45
+ ```python
46
+ delegate_task(tasks=[
47
+ {"goal": "Implement parser fix in src/parser.ts", "context": "The bug is on line 42..."},
48
+ {"goal": "Update tests for parser fix", "context": "Test file: tests/parser.test.ts"},
49
+ {"goal": "Update docs with new parser behavior", "context": "Doc file: docs/parser.md"},
50
+ ])
51
+ ```
52
+
53
+ All run in parallel. Results arrive as independent messages.
54
+
55
+ ### Pattern 2: Orchestrator + leaves (2-stage)
56
+
57
+ ```python
58
+ # Stage 1: Orchestrator designs the approach
59
+ delegate_task(
60
+ goal="Design audit approach for Nexterface imagination loop",
61
+ role="orchestrator",
62
+ context="Focus on state machine paths, not test coverage. Write findings to .md in project root."
63
+ )
64
+ # Orchestrator spawns 2-3 leaf workers for deep-dive on specific areas
65
+
66
+ # Stage 2: Synthesize (you, the parent) — combine orchestrator's results
67
+ ```
68
+
69
+ ### Pattern 3: Two-stage review (subagent-driven)
70
+
71
+ For complex tasks:
72
+ ```
73
+ 1. delegate_task(goal="Write spec for feature X", role="orchestrator")
74
+ → Orchestrator produces spec with acceptance criteria
75
+ 2. delegate_task(goal="Implement feature X from spec", context="Spec: ...")
76
+ → Leaf worker implements against the spec
77
+ 3. You review leaf output against the spec
78
+ → review(task_id, status="approved|changes_requested", notes="...")
79
+ ```
80
+
81
+ ## N:N Goal-Task DAGs
82
+
83
+ Goals and tasks are not 1:1. One task can serve multiple goals:
84
+
85
+ ```
86
+ task_link_goal(task_id="t1", goal_id="g1") — add link
87
+ task_link_goal(task_id="t1", goal_id="g2") — same task, second goal
88
+ task_unlink_goal(task_id="t1", goal_id="g2") — remove link
89
+
90
+ task_bulk_link_goal(task_ids="t1,t2,t3", goal_ids="g1,g2") — cross-product link
91
+ ```
92
+
93
+ ### DAG design rules
94
+
95
+ 1. **Foundation tasks** (shared across goals) → link to all goals via `task_link_goal`
96
+ 2. **Integration tasks** (wire goal outputs together) → link to both goals
97
+ 3. **Goal-specific tasks** → link to single goal only
98
+ 4. **Tasks with no goal** → flagged as "Orphans" in `orient()`
99
+
100
+ ### Dependency types
101
+
102
+ ```
103
+ task_add(deps="taskid:FS,taskid2:SS")
104
+ ```
105
+
106
+ | Type | Meaning |
107
+ |---|---|
108
+ | `FS` | Finish-to-Start (default) — dep must complete before task starts |
109
+ | `FF` | Finish-to-Finish — task finishes when dep finishes |
110
+ | `SS` | Start-to-Start — task starts when dep starts |
111
+ | `SF` | Start-to-Finish — task finishes when dep starts (rare) |
112
+
113
+ ## Rail Policies (Agent Lanes)
114
+
115
+ Narrow what an agent can work on:
116
+
117
+ ```
118
+ rail_policy_set(phase_ids="phase1,phase2", category_ids="cat1", task_tags='["parser","security"]')
119
+ ```
120
+
121
+ The agent can only:
122
+ - Focus on tasks in phase1 or phase2
123
+ - Work on tasks tagged "parser" or "security"
124
+ - Access context items in category cat1
125
+
126
+ ## Enforcement Rules
127
+
128
+ ```
129
+ rule_add(kind="read_limit", threshold_json='{"max_per_file": 1}')
130
+ rule_add(kind="tool_limit", threshold_json='{"max": 30}')
131
+ rule_add(kind="retry_limit", threshold_json='{"failures": 1}')
132
+ rule_add(kind="block_list", threshold_json='{"paths": ["*.gen.*", "*.min.js"]}')
133
+ rule_add(kind="test_required", threshold_json='{"paths": ["src/db.py"]}')
134
+
135
+ rule_list() — view active rules
136
+ rule_update(id, ...) — modify a rule
137
+ rule_remove(id) — delete a rule
138
+
139
+ # Rules auto-derive from lessons:
140
+ learn(content="Never read *.gen.ts files", kind="pitfall")
141
+ # → auto-creates block_list rule for *.gen.ts
142
+ ```
143
+
144
+ ## Handoffs
145
+
146
+ ```
147
+ handoff(task_id="t1", to="agent-name", note="Handing over parser work")
148
+ ```
149
+
150
+ Transfers task ownership. Pass `agent_id` to also clock the recipient into the task and record them in the agents table.
151
+
152
+ ## Conflict Detection
153
+
154
+ When two agents edit the same task, `focus()` returns a `conflict_warning`:
155
+ ```json
156
+ {"edited_by": "agent-2", "edited_at": "2026-06-24T...",
157
+ "message": "This task was last modified by a different agent. Review before continuing."}
158
+ ```
159
+
160
+ ## Common Orchestration Pitfalls
161
+
162
+ | Pitfall | Fix |
163
+ |---|---|
164
+ | Orchestrator depth exceeds 2 | Split into separate delegation calls |
165
+ | More than 5 concurrent tasks | Batch in groups of ≤5 |
166
+ | High-risk task without review | `task_add(lane="high_risk")` auto-sets `review_required=true` |
167
+ | Orphan tasks (no goal) | Link to goal with `task_link_goal` |
168
+ | Dead subagent output not verified | `review()` the output before marking task done |
@@ -0,0 +1,249 @@
1
+ ---
2
+ name: context-rail-setup
3
+ description: "Set up and manage Context Rail in a project — project creation, workspace binding, skill loading, installation, upgrades."
4
+ version: 1.0.0
5
+ author: Context Rail
6
+ license: MIT
7
+ platforms: [linux, macos, windows]
8
+ metadata:
9
+ hermes:
10
+ tags: [Context-Rail, Setup, Project-Management, Skills, Installation]
11
+ related_skills: [context-rail-daily, context-rail-governance, context-rail-orchestration]
12
+ ---
13
+
14
+ # Context Rail — Project Setup & Management
15
+
16
+ Everything needed to set up, configure, upgrade, and understand the Context Rail project context system. Load this when creating a new project, troubleshooting setup, or explaining how Context Rail works.
17
+
18
+ ## Architecture
19
+
20
+ Context Rail has two layers that work together:
21
+
22
+ ```
23
+ ┌────────────────────────────────────────────┐
24
+ │ AGENTS.md (~22 lines, always loaded) │
25
+ │ The MAP — compact reference, points to │
26
+ │ skills for detailed instructions │
27
+ ├────────────────────────────────────────────┤
28
+ │ Skills (loaded on demand, injected into │
29
+ │ system prompt context) │
30
+ │ The GUIDEBOOK — detailed workflows, │
31
+ │ pitfalls, examples │
32
+ ├────────────────────────────────────────────┤
33
+ │ context-rail-setup ← YOU ARE HERE │
34
+ │ context-rail-daily ← daily workflow│
35
+ │ context-rail-governance ← planning/PDCA │
36
+ │ context-rail-orchestration ← multi-agent │
37
+ └────────────────────────────────────────────┘
38
+ ```
39
+
40
+ AGENTS.md is auto-generated by `context-rail init` or `context-rail update`.
41
+ Skills are auto-copied to `.agents/skills/context-rail/` in the current project.
42
+
43
+ ## Creating a New Project
44
+
45
+ ```
46
+ 1. project_create(name="My Project", description="What it does", workdir="/path/to/repo")
47
+ → Creates project in database, auto-generates AGENTS.md
48
+ → Optionally binds the workspace
49
+
50
+ 2. project_set_active(project_id="...", workdir="/path/to/repo")
51
+ → Sets as active project in state.json
52
+ → Creates workspace binding (agent resolves project from cwd)
53
+
54
+ 3. project_login(project_id, agent_id="...", workdir="/path/to/repo")
55
+ → Alternative: log an agent into the project with workspace binding
56
+ → Call this when orient() shows ⚠ unbound
57
+ ```
58
+
59
+ ### Verifying setup
60
+
61
+ ```
62
+ orient(workdir="/path/to/repo")
63
+ → Should show: "Login: ✓ bound as '<agent>' in this workspace"
64
+ → If shows "⚠ no workspace binding" → run project_login or project_set_active
65
+ ```
66
+
67
+ ## Workspace Binding (how agents resolve projects)
68
+
69
+ Context Rail resolves the active project from the agent's current working directory:
70
+
71
+ | Method | How it works | When to use |
72
+ |---|---|---|
73
+ | `project_set_active(workdir="/repo")` | Binds workspace → project (wildcard `*`) | Any agent in that directory gets this project |
74
+ | `project_login(agent_id="a1", workdir="/repo")` | Binds workspace → project for specific agent | Multiple agents in same directory, different projects |
75
+ | `orient(workdir="/repo")` | Queries bindings → falls back to state.json | Called automatically on session startup |
76
+
77
+ All 113 MCP tools use `resolve_pid_for_tool(workdir, agent_id)` first, then fall back to `load_state()`. Workspace bindings take priority.
78
+
79
+ ## Loading Skills
80
+
81
+ ```
82
+ skill_view("context-rail-daily") — load daily capture workflow
83
+ skill_view("context-rail-governance") — load governance patterns
84
+ skill_view("context-rail-orchestration") — load multi-agent patterns
85
+ skill_view("context-rail-setup") — load this setup guide
86
+ ```
87
+
88
+ ### When to load each skill
89
+
90
+ | Situation | Load |
91
+ |---|---|
92
+ | Starting any session | context-rail-daily |
93
+ | Starting a planned phase / brainstorm | context-rail-governance |
94
+ | Splitting work across agents | context-rail-orchestration |
95
+ | Setting up a new project | context-rail-setup |
96
+ | Troubleshooting Context Rail itself | context-rail-setup |
97
+ | Explaining the system to someone | context-rail-setup |
98
+
99
+ AGENTS.md tells you which skills exist and when to load them. Skills contain the detailed instructions.
100
+
101
+ ## Understanding a Project's State
102
+
103
+ ```
104
+ orient()
105
+ → Project name, status, phase progress, roadmaps
106
+ → Recently Captured context items
107
+ → Alerts: blocked goals, stale tasks, unverified items, pending retros
108
+ → Active enforcement rules and session counters
109
+ → Active plan contract and autonomy run status
110
+
111
+ focus(task_id)
112
+ → Full task detail + context_pack with inherited context items
113
+ → Related lessons, decisions, enforcement rules
114
+ → Recommended reads (lane-aware: tiny/normal/high_risk)
115
+
116
+ find("keyword")
117
+ → Searches ALL tables: tasks, goals, lessons, context_items,
118
+ project_notes, risks, artifacts, decisions
119
+ → Use before search_files() or read_file() to avoid re-discovery
120
+ ```
121
+
122
+ ## Installation & Updates
123
+
124
+ ### Fresh install
125
+
126
+ ```
127
+ pip install git+https://github.com/nguyenhoanhson797/Context-Rail.git
128
+ context-rail init
129
+ ```
130
+
131
+ ### Update
132
+
133
+ ```
134
+ context-rail update
135
+ ```
136
+
137
+ Both `init` and `update`:
138
+ 1. Initialize/verify the database
139
+ 2. Generate/refresh AGENTS.md in the current directory
140
+ 3. Copy skills to `.agents/skills/context-rail/`
141
+
142
+ ### Verify installation
143
+
144
+ ```
145
+ python -m context_rail status
146
+ → Shows project count, active project, active task
147
+ ```
148
+
149
+ ### MCP client config
150
+
151
+ ```
152
+ context-rail config
153
+ → Prints JSON config for MCP client
154
+ → Use `command: C:/Python313/python.exe, args: [-m, context_rail, serve]`
155
+ ```
156
+
157
+ ## Multiple Projects
158
+
159
+ ```
160
+ project_list()
161
+ → Lists all projects with task counts and completion percentages
162
+
163
+ project_set_active(project_id="...", workdir="/another/repo")
164
+ → Switch active project for a different workspace
165
+
166
+ project_list(include_deleted=True)
167
+ → Shows soft-deleted projects (can be restored)
168
+ ```
169
+
170
+ Each workspace can be bound to a different project. Agents in `/repo-a` get project A, agents in `/repo-b` get project B.
171
+
172
+ ## Project Lifecycle Management
173
+
174
+ ```
175
+ project_update(name="New Name", description="Updated desc") — rename/re-describe
176
+ project_budget(budget="high") — set expansion budget (small/medium/high/max)
177
+ project_delete() — soft-delete (recoverable)
178
+ project_restore() — restore soft-deleted project
179
+ project_hard_delete() — permanent delete (cannot undo)
180
+ ```
181
+
182
+ ## Troubleshooting
183
+
184
+ ### orient() shows ⚠ unbound
185
+
186
+ ```
187
+ project_login(project_id="...", agent_id="...", workdir="/path/to/repo")
188
+ ```
189
+
190
+ ### Find() returns empty for known facts
191
+
192
+ 1. Was the fact saved via `note()` or `context_add()`?
193
+ 2. `orient()` → check "Recently Captured" section
194
+ 3. `context_list(scope_type="project")` → verify the item exists
195
+ 4. If saved before the usability fix, it may be in `project_notes` or `task_context` (older tables)
196
+
197
+ ### MCP server not responding
198
+
199
+ 1. Check config: `context-rail config` — verify command and args
200
+ 2. Restart MCP server (quit and restart Hermes, or restart the MCP process)
201
+ 3. Check database: `python -m context_rail status`
202
+
203
+ ### Skills not appearing in your project
204
+
205
+ 1. Run `context-rail init` to regenerate skills
206
+ 2. Verify files exist: `ls .agents/skills/context-rail/`
207
+ 3. Restart your agent to pick up new skills
208
+
209
+ ### "No active project" on tools that should work
210
+
211
+ The tool may be using `load_state()` only (legacy). All tools should now use workspace binding. If a specific tool still fails:
212
+ 1. Pass `workdir="/path/to/repo"` explicitly
213
+ 2. Call `project_set_active(workdir="/path/to/repo")` first
214
+ 3. Report the tool name — it may still need the workspace binding fix
215
+
216
+ ## Capturing Project Context (the full flow)
217
+
218
+ ```
219
+ Session start:
220
+ orient(workdir="/path/to/repo")
221
+ → "Recently Captured: Run Commands, Test Patterns"
222
+ → Gap alert if 0 context items
223
+
224
+ find("task keywords")
225
+ → Search ALL tables before working
226
+
227
+ focus()
228
+ → Get task with context_pack
229
+
230
+ Work:
231
+ Discover a fact → note(content, kind="reference")
232
+ Learn a lesson → learn(content, kind="pattern")
233
+ Make a decision → decision_create(question, choice, rationale)
234
+
235
+ Complete:
236
+ done(task_id) → soft gate if context items untouched
237
+
238
+ Next session:
239
+ orient() → sees the saved facts → trusts the system → saves more
240
+ ```
241
+
242
+ ## The Memory Boundary
243
+
244
+ ```
245
+ Project facts → note() → context_items (searchable, scoped, shared)
246
+ Environment facts → memory() → agent memory (auto-injected, per-agent)
247
+ ```
248
+
249
+ If you save a run command to memory(), it's invisible to find(), not scoped to the project, not shared across agents. When in doubt: project fact = note().