agent-riggs 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 (88) hide show
  1. agent_riggs-0.1.0/.github/workflows/publish.yml +45 -0
  2. agent_riggs-0.1.0/.gitignore +11 -0
  3. agent_riggs-0.1.0/.readthedocs.yml +9 -0
  4. agent_riggs-0.1.0/PKG-INFO +19 -0
  5. agent_riggs-0.1.0/README.md +233 -0
  6. agent_riggs-0.1.0/docs/architecture.md +153 -0
  7. agent_riggs-0.1.0/docs/cli-reference.md +208 -0
  8. agent_riggs-0.1.0/docs/configuration.md +99 -0
  9. agent_riggs-0.1.0/docs/index.md +29 -0
  10. agent_riggs-0.1.0/docs/integration.md +122 -0
  11. agent_riggs-0.1.0/docs/mcp.md +89 -0
  12. agent_riggs-0.1.0/docs/superpowers/plans/2026-03-29-agent-riggs.md +4270 -0
  13. agent_riggs-0.1.0/docs/superpowers/plans/2026-03-30-documentation.md +1475 -0
  14. agent_riggs-0.1.0/docs/superpowers/specs/2026-03-29-agent-riggs-design.md +482 -0
  15. agent_riggs-0.1.0/docs/superpowers/specs/2026-03-30-documentation-design.md +243 -0
  16. agent_riggs-0.1.0/docs/the-ratchet.md +109 -0
  17. agent_riggs-0.1.0/docs/tutorial.md +390 -0
  18. agent_riggs-0.1.0/mkdocs.yml +25 -0
  19. agent_riggs-0.1.0/pyproject.toml +52 -0
  20. agent_riggs-0.1.0/src/agent_riggs/__init__.py +3 -0
  21. agent_riggs-0.1.0/src/agent_riggs/assembly.py +53 -0
  22. agent_riggs-0.1.0/src/agent_riggs/briefing/__init__.py +0 -0
  23. agent_riggs-0.1.0/src/agent_riggs/briefing/project.py +21 -0
  24. agent_riggs-0.1.0/src/agent_riggs/briefing/session.py +84 -0
  25. agent_riggs-0.1.0/src/agent_riggs/cli.py +255 -0
  26. agent_riggs-0.1.0/src/agent_riggs/config.py +103 -0
  27. agent_riggs-0.1.0/src/agent_riggs/defaults/config.toml +35 -0
  28. agent_riggs-0.1.0/src/agent_riggs/ingest/__init__.py +0 -0
  29. agent_riggs-0.1.0/src/agent_riggs/ingest/pipeline.py +141 -0
  30. agent_riggs-0.1.0/src/agent_riggs/ingest/sources/__init__.py +0 -0
  31. agent_riggs-0.1.0/src/agent_riggs/ingest/sources/base.py +18 -0
  32. agent_riggs-0.1.0/src/agent_riggs/ingest/sources/blq.py +18 -0
  33. agent_riggs-0.1.0/src/agent_riggs/ingest/sources/fledgling.py +18 -0
  34. agent_riggs-0.1.0/src/agent_riggs/ingest/sources/jetsam.py +18 -0
  35. agent_riggs-0.1.0/src/agent_riggs/ingest/sources/kibitzer.py +80 -0
  36. agent_riggs-0.1.0/src/agent_riggs/mcp/__init__.py +0 -0
  37. agent_riggs-0.1.0/src/agent_riggs/mcp/server.py +28 -0
  38. agent_riggs-0.1.0/src/agent_riggs/metrics/__init__.py +0 -0
  39. agent_riggs-0.1.0/src/agent_riggs/metrics/compute.py +76 -0
  40. agent_riggs-0.1.0/src/agent_riggs/metrics/trends.py +44 -0
  41. agent_riggs-0.1.0/src/agent_riggs/plugins/__init__.py +0 -0
  42. agent_riggs-0.1.0/src/agent_riggs/plugins/base.py +37 -0
  43. agent_riggs-0.1.0/src/agent_riggs/plugins/briefing.py +40 -0
  44. agent_riggs-0.1.0/src/agent_riggs/plugins/ingest.py +47 -0
  45. agent_riggs-0.1.0/src/agent_riggs/plugins/metrics.py +59 -0
  46. agent_riggs-0.1.0/src/agent_riggs/plugins/ratchet.py +91 -0
  47. agent_riggs-0.1.0/src/agent_riggs/plugins/sandbox.py +51 -0
  48. agent_riggs-0.1.0/src/agent_riggs/plugins/trust.py +163 -0
  49. agent_riggs-0.1.0/src/agent_riggs/ratchet/__init__.py +0 -0
  50. agent_riggs-0.1.0/src/agent_riggs/ratchet/aggregator.py +23 -0
  51. agent_riggs-0.1.0/src/agent_riggs/ratchet/candidates.py +113 -0
  52. agent_riggs-0.1.0/src/agent_riggs/ratchet/history.py +24 -0
  53. agent_riggs-0.1.0/src/agent_riggs/ratchet/promotions.py +33 -0
  54. agent_riggs-0.1.0/src/agent_riggs/sandbox/__init__.py +0 -0
  55. agent_riggs-0.1.0/src/agent_riggs/sandbox/grades.py +27 -0
  56. agent_riggs-0.1.0/src/agent_riggs/sandbox/integration.py +15 -0
  57. agent_riggs-0.1.0/src/agent_riggs/sandbox/recommendations.py +23 -0
  58. agent_riggs-0.1.0/src/agent_riggs/service.py +35 -0
  59. agent_riggs-0.1.0/src/agent_riggs/store.py +38 -0
  60. agent_riggs-0.1.0/src/agent_riggs/trust/__init__.py +0 -0
  61. agent_riggs-0.1.0/src/agent_riggs/trust/events.py +30 -0
  62. agent_riggs-0.1.0/src/agent_riggs/trust/ewma.py +65 -0
  63. agent_riggs-0.1.0/src/agent_riggs/trust/scorer.py +22 -0
  64. agent_riggs-0.1.0/src/agent_riggs/trust/transitions.py +79 -0
  65. agent_riggs-0.1.0/tests/__init__.py +0 -0
  66. agent_riggs-0.1.0/tests/conftest.py +15 -0
  67. agent_riggs-0.1.0/tests/test_briefing/__init__.py +0 -0
  68. agent_riggs-0.1.0/tests/test_briefing/test_session.py +80 -0
  69. agent_riggs-0.1.0/tests/test_cli/__init__.py +0 -0
  70. agent_riggs-0.1.0/tests/test_cli/test_init.py +25 -0
  71. agent_riggs-0.1.0/tests/test_cli/test_status.py +50 -0
  72. agent_riggs-0.1.0/tests/test_config.py +28 -0
  73. agent_riggs-0.1.0/tests/test_ingest/__init__.py +0 -0
  74. agent_riggs-0.1.0/tests/test_ingest/test_kibitzer_source.py +99 -0
  75. agent_riggs-0.1.0/tests/test_ingest/test_pipeline.py +147 -0
  76. agent_riggs-0.1.0/tests/test_metrics/__init__.py +0 -0
  77. agent_riggs-0.1.0/tests/test_metrics/test_compute.py +84 -0
  78. agent_riggs-0.1.0/tests/test_metrics/test_trends.py +28 -0
  79. agent_riggs-0.1.0/tests/test_ratchet/__init__.py +0 -0
  80. agent_riggs-0.1.0/tests/test_ratchet/test_candidates.py +74 -0
  81. agent_riggs-0.1.0/tests/test_ratchet/test_promotions.py +59 -0
  82. agent_riggs-0.1.0/tests/test_service.py +86 -0
  83. agent_riggs-0.1.0/tests/test_store.py +62 -0
  84. agent_riggs-0.1.0/tests/test_trust/__init__.py +0 -0
  85. agent_riggs-0.1.0/tests/test_trust/test_events.py +27 -0
  86. agent_riggs-0.1.0/tests/test_trust/test_ewma.py +67 -0
  87. agent_riggs-0.1.0/tests/test_trust/test_scorer.py +53 -0
  88. agent_riggs-0.1.0/tests/test_trust/test_transitions.py +47 -0
@@ -0,0 +1,45 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ id-token: write
10
+
11
+ jobs:
12
+ lint:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+ - run: pip install ruff
20
+ - run: ruff check src/ tests/
21
+
22
+ test:
23
+ runs-on: ubuntu-latest
24
+ strategy:
25
+ matrix:
26
+ python-version: ["3.11", "3.12", "3.13"]
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-python@v5
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+ - run: pip install -e ".[dev]"
33
+ - run: python -m pytest tests/ -v --tb=short
34
+
35
+ publish:
36
+ needs: [lint, test]
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: actions/setup-python@v5
41
+ with:
42
+ python-version: "3.12"
43
+ - run: pip install hatch
44
+ - run: hatch build
45
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,11 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .riggs/
7
+ .pytest_cache/
8
+ .ruff_cache/
9
+ .mypy_cache/
10
+ .venv/
11
+ .claude/
@@ -0,0 +1,9 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-24.04
5
+ tools:
6
+ python: "3.12"
7
+
8
+ mkdocs:
9
+ configuration: mkdocs.yml
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-riggs
3
+ Version: 0.1.0
4
+ Summary: Cross-session memory and analysis layer for the Rigged tool suite
5
+ Author: Teague Sterling
6
+ License-Expression: MIT
7
+ Keywords: agent,claude-code,duckdb,mcp,ratchet,trust
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: click>=8.1
10
+ Requires-Dist: duckdb>=1.0
11
+ Requires-Dist: mcp[cli]>=1.0
12
+ Requires-Dist: tomli-w>=1.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: mypy>=1.0; extra == 'dev'
15
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
16
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
17
+ Requires-Dist: pytest>=7.0; extra == 'dev'
18
+ Requires-Dist: ruff>=0.1; extra == 'dev'
19
+ Provides-Extra: full
@@ -0,0 +1,233 @@
1
+ # Agent Riggs
2
+
3
+ > The one who shows up the next morning having gone through all the case files.
4
+
5
+ Agent Riggs is the **cross-session memory and analysis layer for the Rigged tool suite**. It implements Beer's System 3* — audit and intelligence across sessions — to inform kibitzer's within-session control.
6
+
7
+ Riggs tracks agent behavior across sessions using a trust-scoring system, identifies patterns of failure and success, recommends tool and constraint promotions (ratcheting), and provides session briefings to help agents understand their performance context.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install agent-riggs
13
+ agent-riggs init
14
+ ```
15
+
16
+ This creates a `.riggs/` directory with configuration and a DuckDB store for cross-session analysis.
17
+
18
+ ## What It Does
19
+
20
+ ### Trust Scoring
21
+ Riggs uses a **3-window exponential weighted moving average (EWMA)** similar to uptime monitoring:
22
+ - **t1** (immediate, α=0.4): Last ~2–3 turns
23
+ - **t5** (session, α=0.08): Last ~50–60 turns
24
+ - **t15** (baseline, α=0.02): Project lifetime
25
+
26
+ Each turn is scored (0.0–1.0) based on event type: successful tool calls, mode switches, failures, constraint violations.
27
+
28
+ ### Trust-Informed Transitions
29
+ Riggs monitors trust windows and recommends tightening/loosening:
30
+ - t1 < 0.3: Recommend tightening
31
+ - t1 < 0.3 AND t5 < 0.5: Auto-tighten
32
+ - t5 declining 10+ turns: Coach message
33
+ - t1 > 0.9 AND t5 > 0.8 for 20+ turns: Suggest loosening
34
+ - t15 < 0.5: Flag project config
35
+
36
+ Recommendations are written to `.kibitzer/state.json`. Riggs never enforces directly — kibitzer controls the decision.
37
+
38
+ ### Cross-Session Failure Stream
39
+ Riggs ingests turn data from kibitzer and builds a cross-session failure stream. Each failure is categorized (path denial, edit failure, mode violation, etc.) and stored with the trust score at failure time.
40
+
41
+ ### Ratchet Candidates
42
+ Riggs identifies two types of promotion candidates:
43
+
44
+ | Candidate Type | Criteria | Action |
45
+ |---|---|---|
46
+ | **Tool promotion** | Bash pattern frequency ≥ 5, sessions ≥ 3, success_rate ≥ 0.8, structured alternative exists | Promote bash to structured tool |
47
+ | **Constraint promotion** | Repeated failures at same boundary (category + tool + mode) ≥ 3 occurrences | Tighten or document constraint |
48
+
49
+ ### Sandbox Intelligence
50
+ If `blq` is installed, Riggs integrates sandbox profiling data to recommend resource tightening. Tracks memory and duration percentiles across runs.
51
+
52
+ ### Ratchet Metrics
53
+ Computes and trends:
54
+ - Ratchet velocity (promotions/session)
55
+ - Self-service ratio (tools without controller intervention)
56
+ - Mode switch frequency
57
+ - Failure rate trends
58
+
59
+ ### Session Briefing
60
+ Riggs composes session briefings from trust, ratchet, and metrics data — helping agents understand what happened and why.
61
+
62
+ ## Architecture
63
+
64
+ ### Composable Plugin Service Layer
65
+
66
+ Every subsystem is a **plugin** that registers:
67
+ - **CLI commands** — contributed to the main command group
68
+ - **MCP resources** — read-only data resources for agents
69
+ - **MCP tools** — read-only query/analysis tools for agents
70
+ - **Schema DDL** — tables owned by this plugin
71
+
72
+ The CLI and MCP server are thin shells that auto-discover and compose from registered plugins.
73
+
74
+ ### Plugins
75
+
76
+ | Plugin | Responsibility |
77
+ |---|---|
78
+ | **trust** | Event scoring, EWMA, trust windows, transition recommendations |
79
+ | **ingest** | Discover and read events from sibling tools (kibitzer, blq, jetsam, fledgling) |
80
+ | **ratchet** | Identify promotion candidates, track decisions, manage promotions |
81
+ | **sandbox** | Integrate blq profiling, generate tightening recommendations |
82
+ | **metrics** | Compute ratchet velocity, trends, self-service ratio |
83
+ | **briefing** | Compose session and project briefings from other plugins |
84
+
85
+ ### DuckDB Persistence
86
+
87
+ All data is stored in a local DuckDB database (`.riggs/store.duckdb`). Schema is managed idempotently — plugins declare their tables via `CREATE TABLE IF NOT EXISTS`. No migrations or daemon required.
88
+
89
+ ## Usage
90
+
91
+ ### CLI Commands
92
+
93
+ ```bash
94
+ agent-riggs init # Initialize .riggs/ config and store
95
+ agent-riggs ingest # Pull events from sibling tools (kibitzer, blq, etc.)
96
+ agent-riggs status # Show current trust scores and recent events
97
+ agent-riggs trust [--window {1,5,15}]
98
+ # Display trust window and trajectory
99
+ agent-riggs ratchet [--candidate {tool,constraint}]
100
+ # Show ratchet candidates and recent decisions
101
+ agent-riggs sandbox [--command CMD]
102
+ # Show sandbox profiles and recommendations
103
+ agent-riggs metrics [--period DAYS]
104
+ # Display ratchet velocity, trends, metrics
105
+ agent-riggs brief [--type {session,project}]
106
+ # Generate session or project briefing
107
+ ```
108
+
109
+ ### MCP Server
110
+
111
+ Start the MCP server for integration with agents:
112
+
113
+ ```bash
114
+ agent-riggs serve
115
+ ```
116
+
117
+ Agents can then access:
118
+
119
+ **Resources** (read-only):
120
+ - `riggs://briefing` — Session briefing markdown
121
+ - `riggs://trust` — Current t1/t5/t15 + trajectory
122
+ - `riggs://ratchet` — Pending candidates + recent decisions
123
+ - `riggs://sandbox` — Grades + recommendations
124
+ - `riggs://metrics` — Ratchet metrics markdown
125
+
126
+ **Tools** (read-only):
127
+ - `RiggsTrust` — Query trust window and history
128
+ - `RiggsMetrics` — Compute metrics over a period
129
+ - `RiggsFailures` — Query failure stream by category
130
+ - `RiggsSandbox` — Get sandbox profile for a command
131
+
132
+ ## Configuration
133
+
134
+ ### .riggs/config.toml
135
+
136
+ Configuration is loaded from `.riggs/config.toml` with sensible defaults shipped in the package. User config merges over defaults.
137
+
138
+ Example sections:
139
+
140
+ ```toml
141
+ [trust]
142
+ # Event scoring weights (0.0 - 1.0)
143
+ success_correct_mode = 1.0
144
+ success_suboptimal_tool = 0.7
145
+ mode_switch_agent = 0.8
146
+ mode_switch_controller = 0.3
147
+ tool_failure = 0.2
148
+ path_denial = 0.1
149
+ repeated_failure = 0.0
150
+
151
+ # EWMA parameters
152
+ alpha_short = 0.4 # t1 window
153
+ alpha_session = 0.08 # t5 window
154
+ alpha_baseline = 0.02 # t15 window
155
+
156
+ # Transition thresholds
157
+ tighten_threshold_t1 = 0.3
158
+ tighten_threshold_t5 = 0.5
159
+ loosening_threshold_t1 = 0.9
160
+ loosening_threshold_t5 = 0.8
161
+ loosening_window_turns = 20
162
+
163
+ [ratchet]
164
+ tool_promotion_freq = 5
165
+ tool_promotion_sessions = 3
166
+ tool_promotion_success_rate = 0.8
167
+ constraint_promotion_occurrences = 3
168
+
169
+ [sandbox]
170
+ # blq integration (optional)
171
+ enabled = true
172
+
173
+ [metrics]
174
+ # Trend detection windows
175
+ velocity_period_days = 30
176
+ trend_window_turns = 50
177
+
178
+ [store]
179
+ path = ".riggs/store.duckdb"
180
+ ```
181
+
182
+ ## Design Principles
183
+
184
+ ### Reads Everything, Writes Nothing (to other tools)
185
+ Riggs is a **read-only observer** of the Rigged tool suite. It ingests state from kibitzer, blq, jetsam, and fledgling but never mutates their configs or data directly. Promotions are written to `.riggs/` only, then reviewed by humans before application.
186
+
187
+ ### Human in the Loop
188
+ Riggs recommends but never enforces. All promotion decisions require human review and approval. Constraint tightening is suggested, not automatic.
189
+
190
+ ### Specified Throughout
191
+ Every threshold, weight, and heuristic is configurable in `.riggs/config.toml`. Defaults are sensible but tunable.
192
+
193
+ ### DuckDB Native
194
+ No external database or daemon. Schema is declared per-plugin as idempotent DDL. Queries use standard SQL. Data is portable and inspectable.
195
+
196
+ ### Graceful Degradation
197
+ Optional tools (blq, jetsam, fledgling) are discovered at runtime. If absent, Riggs continues with reduced capability — sandbox features disabled, commit patterns skipped, etc.
198
+
199
+ ## Design Specification
200
+
201
+ For detailed architecture, event types, trust formulas, failure categorization, and ratchet logic, see:
202
+
203
+ **[Agent Riggs Design Spec](docs/superpowers/specs/2026-03-29-agent-riggs-design.md)**
204
+
205
+ For step-by-step implementation plan and build order, see:
206
+
207
+ **[Agent Riggs Implementation Plan](docs/superpowers/plans/2026-03-29-agent-riggs.md)**
208
+
209
+ ## Dependencies
210
+
211
+ | Package | Role | Required |
212
+ |---|---|---|
213
+ | click | CLI framework | Yes |
214
+ | duckdb | Persistence | Yes |
215
+ | mcp[cli] | MCP server | Yes |
216
+ | tomli-w | Config serialization | Yes |
217
+ | kibitzer | Event source | Optional |
218
+ | blq | Sandbox integration | Optional |
219
+ | jetsam | Commit pattern analysis | Optional |
220
+ | fledgling | Conversation analytics | Optional |
221
+
222
+ Python 3.11+ required (for `tomllib` stdlib and clean union syntax).
223
+
224
+ ## License
225
+
226
+ MIT
227
+
228
+ ## Related Tools
229
+
230
+ - **[kibitzer](https://github.com/anthropics/rigged)** — In-session control and constraint management
231
+ - **[blq](https://github.com/anthropics/rigged)** — Sandboxing and resource profiling
232
+ - **[jetsam](https://github.com/anthropics/rigged)** — File state and git integration
233
+ - **[fledgling](https://github.com/anthropics/rigged)** — Conversation and context analytics
@@ -0,0 +1,153 @@
1
+ # Architecture
2
+
3
+ ## Plugin System
4
+
5
+ Agent Riggs uses a composable plugin architecture. Each subsystem (trust, ingest, ratchet, metrics, briefing, sandbox) is a plugin that implements the `ServicePlugin` protocol:
6
+
7
+ ```python
8
+ class ServicePlugin(Protocol):
9
+ name: str
10
+ def bind(self, service: RiggsService) -> None: ...
11
+ def cli_commands(self) -> list[click.Command]: ...
12
+ def mcp_resources(self) -> list[tuple[str, Callable]]: ...
13
+ def mcp_tools(self) -> list[tuple[str, Callable]]: ...
14
+ def schema_ddl(self) -> list[str]: ...
15
+ ```
16
+
17
+ Each plugin contributes:
18
+ - **Schema DDL** — `CREATE TABLE IF NOT EXISTS` statements for tables it owns
19
+ - **CLI commands** — Click commands registered on the main group
20
+ - **MCP resources** — URI/handler pairs for read-only resources
21
+ - **MCP tools** — Name/handler pairs for agent-callable tools
22
+
23
+ ## Service Layer
24
+
25
+ `RiggsService` composes plugins. It holds the project root, DuckDB store, and config:
26
+
27
+ ```python
28
+ service = RiggsService(project_root, store, config)
29
+ service.register(TrustPlugin())
30
+ service.register(IngestPlugin())
31
+ # ...
32
+ ```
33
+
34
+ Cross-plugin access works through the service: `service.plugin("trust").current()`.
35
+
36
+ ## Assembly
37
+
38
+ `assemble()` builds the service from discovered plugins:
39
+
40
+ 1. Load config (defaults merged with `.riggs/config.toml`)
41
+ 2. Open DuckDB store
42
+ 3. Register core plugins (trust, ingest, ratchet, metrics, briefing)
43
+ 4. Register optional plugins (sandbox — only if blq is on PATH)
44
+ 5. Execute DDL from all plugins (idempotent schema creation)
45
+
46
+ The `read_only` parameter controls whether the store allows writes. The MCP server uses `read_only=True`.
47
+
48
+ ## CLI and MCP: Thin Shells
49
+
50
+ Both the CLI (`cli.py`) and MCP server (`mcp/server.py`) are thin shells over the service layer:
51
+
52
+ - **CLI** calls `assemble()`, gets a service, calls plugin methods, formats output for the terminal
53
+ - **MCP server** calls `assemble(read_only=True)`, auto-discovers resources and tools from plugins
54
+
55
+ Neither contains business logic. All logic lives in plugins and their backing modules.
56
+
57
+ ## DuckDB Schema
58
+
59
+ Each plugin owns its tables:
60
+
61
+ ### Trust Plugin
62
+
63
+ **turns** — every turn from every session:
64
+
65
+ | Column | Type | Description |
66
+ |--------|------|-------------|
67
+ | turn_id | BIGINT PK | Unique turn identifier |
68
+ | session_id | VARCHAR | Session this turn belongs to |
69
+ | project | VARCHAR | Project name |
70
+ | turn_number | INTEGER | Turn sequence within session |
71
+ | timestamp | TIMESTAMPTZ | When the turn occurred |
72
+ | tool_name | VARCHAR | Tool that was called |
73
+ | tool_success | BOOLEAN | Whether the call succeeded |
74
+ | mode | VARCHAR | Kibitzer mode at time of turn |
75
+ | trust_score | DOUBLE | Per-turn score (0-1) |
76
+ | trust_1 | DOUBLE | EWMA short window after this turn |
77
+ | trust_5 | DOUBLE | EWMA session window after this turn |
78
+ | trust_15 | DOUBLE | EWMA baseline window after this turn |
79
+ | event_category | VARCHAR | Classification (success, failure, etc.) |
80
+ | metadata | JSON | Tool-specific details |
81
+
82
+ **failure_stream** — failure events with classification:
83
+
84
+ | Column | Type | Description |
85
+ |--------|------|-------------|
86
+ | failure_id | BIGINT PK | Unique failure identifier |
87
+ | turn_id | BIGINT | Reference to turns table |
88
+ | session_id | VARCHAR | Session |
89
+ | project | VARCHAR | Project |
90
+ | occurred_at | TIMESTAMPTZ | When the failure occurred |
91
+ | failure_category | VARCHAR | Classification |
92
+ | tool_name | VARCHAR | Tool that failed |
93
+ | mode | VARCHAR | Mode at time of failure |
94
+ | trust_at_failure | DOUBLE | Trust score when this failure occurred |
95
+ | detail | JSON | Failure-specific details |
96
+
97
+ **session_summaries** — session-level aggregates:
98
+
99
+ | Column | Type | Description |
100
+ |--------|------|-------------|
101
+ | session_id | VARCHAR PK | Session identifier |
102
+ | project | VARCHAR | Project |
103
+ | started_at / ended_at | TIMESTAMPTZ | Session boundaries |
104
+ | total_turns / total_failures | INTEGER | Counts |
105
+ | failure_rate | DOUBLE | failures / turns |
106
+ | trust_start / trust_end / trust_delta | DOUBLE | Trust trajectory |
107
+ | modes_used | VARCHAR[] | Modes active during session |
108
+ | mode_switches | INTEGER | Number of mode changes |
109
+ | structured_tool_fraction | DOUBLE | Fraction using structured tools |
110
+ | computation_channel_fraction | DOUBLE | Fraction at computation level 4+ |
111
+
112
+ ### Ratchet Plugin
113
+
114
+ **ratchet_decisions** — promotion and rejection audit trail:
115
+
116
+ | Column | Type | Description |
117
+ |--------|------|-------------|
118
+ | decision_id | BIGINT PK | Unique decision identifier |
119
+ | decided_at | TIMESTAMP | When the decision was made |
120
+ | candidate_type | VARCHAR | tool_promotion, constraint_promotion, etc. |
121
+ | candidate_key | VARCHAR | Human-readable identifier |
122
+ | decision | VARCHAR | promoted, rejected, deferred |
123
+ | reason | VARCHAR | Human-provided reason |
124
+ | evidence | JSON | Frequency, success rate, etc. |
125
+ | config_change | JSON | What was changed (audit trail) |
126
+
127
+ ### Sandbox Plugin
128
+
129
+ **sandbox_profiles** — aggregated execution profiles:
130
+
131
+ | Column | Type | Description |
132
+ |--------|------|-------------|
133
+ | command | VARCHAR | Command name (composite PK with project) |
134
+ | project | VARCHAR | Project name |
135
+ | updated_at | TIMESTAMPTZ | Last update |
136
+ | total_runs | INTEGER | Total executions |
137
+ | memory_p50/p95/max | BIGINT | Memory usage percentiles |
138
+ | duration_p50/p95/max | INTERVAL | Duration percentiles |
139
+ | current_spec | JSON | Current sandbox specification |
140
+ | current_grade_w | VARCHAR | World coupling grade |
141
+ | current_effects_ceiling | INTEGER | Effects ceiling |
142
+
143
+ ## Design Principles
144
+
145
+ 1. **Reads everything, writes nothing (to other tools).** Riggs aggregates data from kibitzer, lackpy, blq, jetsam, and fledgling but never modifies their state. Each tool owns its own storage. Riggs owns `.riggs/store.duckdb` and nothing else.
146
+
147
+ 2. **Human in the loop for promotions.** The ratchet identifies candidates automatically. Applying a promotion requires a human decision (`agent-riggs ratchet promote`). Riggs can recommend trust transitions (specified rules) but cannot expand capabilities.
148
+
149
+ 3. **Specified throughout.** Trust scoring is arithmetic. Failure classification is pattern matching. Candidate identification is SQL. Trend detection is windowed aggregation. No LLM in the analysis loop. Every decision traces to `config.toml` or a SQL query.
150
+
151
+ 4. **DuckDB native.** The store is DuckDB. The queries are SQL. The analytics compose with the rest of the suite's DuckDB usage.
152
+
153
+ 5. **Graceful degradation.** No kibitzer? No primary data source, but everything else works. No blq? Sandbox features disabled. No lackpy? Template promotion disabled. No fledgling? Conversation analytics unavailable. Each missing tool disables a feature, not the system.
@@ -0,0 +1,208 @@
1
+ # CLI Reference
2
+
3
+ ## agent-riggs
4
+
5
+ ```
6
+ Usage: agent-riggs [OPTIONS] COMMAND [ARGS]...
7
+
8
+ agent-riggs -- cross-session memory and analysis for the Rigged tool suite.
9
+
10
+ Options:
11
+ --version Show the version and exit.
12
+ --help Show this message and exit.
13
+ ```
14
+
15
+ ## Setup Commands
16
+
17
+ ### agent-riggs init
18
+
19
+ Initialize `.riggs/` directory and DuckDB store.
20
+
21
+ ```bash
22
+ agent-riggs init
23
+ ```
24
+
25
+ ```
26
+ Initialized .riggs/ in /home/you/your-project
27
+ Discovered tools: kibitzer
28
+ ```
29
+
30
+ Creates:
31
+ - `.riggs/config.toml` — copy of defaults (only if not present)
32
+ - `.riggs/store.duckdb` — DuckDB database with schema for all registered plugins
33
+
34
+ Discovers sibling tools by checking both PATH (`shutil.which`) and project directories (`.kibitzer/`, `.lq/`, `.jetsam/`, `.fledgling/`).
35
+
36
+ Safe to run multiple times — idempotent.
37
+
38
+ ### agent-riggs ingest
39
+
40
+ Pull session data from sibling tool state files into the store.
41
+
42
+ ```bash
43
+ agent-riggs ingest
44
+ ```
45
+
46
+ ```
47
+ Ingested 5 turns from ['kibitzer']
48
+ Recorded 1 failures
49
+ ```
50
+
51
+ Reads from all discovered sources (kibitzer, blq, jetsam, fledgling). Each event is scored and the trust EWMA is updated. Failures are recorded in the failure stream.
52
+
53
+ ## Status Commands
54
+
55
+ ### agent-riggs status
56
+
57
+ Quick health check — trust scores at a glance.
58
+
59
+ ```bash
60
+ agent-riggs status
61
+ ```
62
+
63
+ ```
64
+ trust: 0.61 / 0.91 / 0.98
65
+ now session baseline
66
+ ```
67
+
68
+ Shows `trust_1 / trust_5 / trust_15`. If no data has been ingested, shows "trust: no data yet".
69
+
70
+ ### agent-riggs brief
71
+
72
+ Full session briefing.
73
+
74
+ ```bash
75
+ agent-riggs brief
76
+ ```
77
+
78
+ ```
79
+ PROJECT BRIEFING: your-project
80
+
81
+ Trust baseline: 0.98
82
+ Last session: sess-tutorial-1, 34 turns, trust 0.91
83
+ Known issues:
84
+ - edit_failure (12 occurrences)
85
+ Active ratchet candidates: 2
86
+ ```
87
+
88
+ ## Trust Commands
89
+
90
+ ### agent-riggs trust current
91
+
92
+ Detailed trust scores.
93
+
94
+ ```bash
95
+ agent-riggs trust current
96
+ ```
97
+
98
+ ```
99
+ trust_1 (now): 0.6080
100
+ trust_5 (session): 0.9139
101
+ trust_15 (baseline):0.9781
102
+ ```
103
+
104
+ ### agent-riggs trust history
105
+
106
+ Trust score trajectory over time.
107
+
108
+ ```bash
109
+ agent-riggs trust history [--limit N]
110
+ ```
111
+
112
+ | Option | Default | Description |
113
+ |--------|---------|-------------|
114
+ | `--limit` | 20 | Number of entries to show |
115
+
116
+ ```
117
+ [sess-tutorial-2:4] 0.24 / 0.86 / 0.96
118
+ [sess-tutorial-2:3] 0.35 / 0.88 / 0.96
119
+ [sess-tutorial-1:5] 0.61 / 0.91 / 0.98
120
+ ...
121
+ ```
122
+
123
+ ## Ratchet Commands
124
+
125
+ ### agent-riggs ratchet candidates
126
+
127
+ Show pending promotion candidates.
128
+
129
+ ```bash
130
+ agent-riggs ratchet candidates
131
+ ```
132
+
133
+ ```
134
+ [tool_promotion] bash-to-finddefinitions
135
+ Graduate FindDefinitions interceptor
136
+ Evidence: {'frequency': 89, 'sessions': 23, 'success_rate': 0.97}
137
+ ```
138
+
139
+ Shows nothing if no patterns meet the threshold criteria configured in `[ratchet]`.
140
+
141
+ ### agent-riggs ratchet promote
142
+
143
+ Promote a candidate. Records the decision and applies the config change.
144
+
145
+ ```bash
146
+ agent-riggs ratchet promote <KEY> [--reason TEXT]
147
+ ```
148
+
149
+ | Argument/Option | Required | Description |
150
+ |-----------------|----------|-------------|
151
+ | `KEY` | Yes | The candidate key (e.g., `bash-to-finddefinitions`) |
152
+ | `--reason` | No | Why you're promoting this candidate |
153
+
154
+ ### agent-riggs ratchet reject
155
+
156
+ Reject a candidate with a reason. The rejection is tracked for future re-evaluation.
157
+
158
+ ```bash
159
+ agent-riggs ratchet reject <KEY> --reason TEXT
160
+ ```
161
+
162
+ | Argument/Option | Required | Description |
163
+ |-----------------|----------|-------------|
164
+ | `KEY` | Yes | The candidate key |
165
+ | `--reason` | Yes | Why you're rejecting (required — document your reasoning) |
166
+
167
+ ### agent-riggs ratchet history
168
+
169
+ Show all promotion and rejection decisions.
170
+
171
+ ```bash
172
+ agent-riggs ratchet history
173
+ ```
174
+
175
+ ```
176
+ [2026-03-30 14:00:00] promoted: bash-to-finddefinitions — agents should use structured search
177
+ [2026-03-29 10:00:00] rejected: bash-to-blq-run-test — agents need raw pytest output
178
+ ```
179
+
180
+ ## Metrics Command
181
+
182
+ ### agent-riggs metrics
183
+
184
+ Ratchet metrics dashboard.
185
+
186
+ ```bash
187
+ agent-riggs metrics [--period DAYS]
188
+ ```
189
+
190
+ | Option | Default | Description |
191
+ |--------|---------|-------------|
192
+ | `--period` | 30 | Analysis window in days |
193
+
194
+ ```
195
+ RATCHET METRICS (47 sessions)
196
+
197
+ Ratchet velocity: 3 promotions
198
+ Self-service ratio: 72% structured
199
+ Computation channel %: 31%
200
+ Trust trajectory: 0.87 -> 0.91
201
+ Failure rate: 12%
202
+
203
+ Mode distribution:
204
+ implement: 64%
205
+ debug: 18%
206
+ test_dev: 12%
207
+ document: 6%
208
+ ```