Fully Automated - 100% Backpressure - Pipeline runner ๐Ÿƒ for AI workflows. ๐Ÿš€

Commit f27389b7

f27389b7ed40Merged

Scott Nixon <[email protected]> ยท 7 months ago ยท 1 file ยท +1 added

Description

docs: add reckoner software factory feature plan

Details

Commit
f27389b7ed40
Parent
c5d99b5a05e0

docs/plans/2026-04-09-feat-reckoner-software-factory-plan.mdaddedView file

1+---
2+title: "feat: Reckoner โ€” Software Factory Wrapping PAS"
3+type: feat
4+status: active
5+date: 2026-04-09
6+deepened: 2026-04-09
7+---
8+
9+## Enhancement Summary
10+
11+**Deepened on:** 2026-04-09
12+**Research agents used:** 10 (containers/OrbStack, SQLite patterns, observability, git automation, linter framework, container security x2, macOS scheduling, architecture review, performance review)
13+
14+### Key Improvements from Research
15+1. **Switch from sqlx to rusqlite** โ€” sync API matches SQLite reality, faster CLI startup, no pool needed
16+2. **Start with JSON log files, not Loki** โ€” zero infra, hl CLI for queries, promote to Loki/VictoriaLogs later
17+3. **Bare clone + git worktree per task** โ€” solves concurrent same-repo, improves virtiofs perf, shared object store
18+4. **Shell out to git/gh** โ€” not git2/gitoxide; auth is free, containers already have git
19+5. **Docker Compose secrets** โ€” not env vars; prevents agent from reading API keys via env
20+6. **Network egress filtering** โ€” Squid proxy allowlist for LLM APIs + GitHub only
21+7. **launchd LaunchAgents** โ€” sleep-aware, concurrent-run-safe, plist crate for generation
22+8. **JSON-Lines linter output** โ€” token-efficient for agents, with natural-language remediation field
23+9. **PAS needs --output-result** โ€” structured result contract across container boundary
24+10. **outcome_json out of SQLite** โ€” prevents DB bloat, keeps under 100MB target
25+
26+### Critical Security Findings
27+- Use repo-scoped fine-grained PATs, not SSH keys (limits blast radius)
28+- Drop ALL container capabilities + no-new-privileges
29+- Read-only root filesystem + tmpfs scratch
30+- Separate .git/ from working tree bind mount
31+- Cap background agents with approval gates
32+
33+---
34+
35+# Reckoner โ€” Software Factory Wrapping PAS
36+
37+## Overview
38+
39+Reckoner (reck) is a software factory that accepts git repository URLs, provisions isolated OrbStack containers per task, runs PAS pipelines inside them, and PRs the results back. It implements the harness engineering environment layer โ€” container lifecycle, architectural linting, doc freshness enforcement, observability, and background entropy cleanup โ€” that PAS intentionally does not own.
40+
41+PAS is the pipeline execution engine. Reckoner is everything else.
42+
43+**Name origin:** Pascal's calculator was called the Reckoner. Reckoner is the machine; PAS is the engine inside it.
44+
45+## Problem Statement / Motivation
46+
47+PAS can run pipelines, but it has no opinion about:
48+- Where code lives or how it gets there (git clone, branching, PRs)
49+- Isolation between concurrent tasks (containers, resource limits)
50+- Architectural enforcement on the code pipelines produce
51+- Observability of the running application being built
52+- Recurring maintenance (doc rot, entropy accumulation, quality drift)
53+- The full lifecycle: task intake, build, verify, PR, merge
54+
55+OpenAI's harness engineering post demonstrates that the environment around an agent execution engine matters more than the engine itself for sustained quality. Reckoner fills this gap.
56+
57+## Proposed Solution
58+
59+A new Rust CLI application (reck) in a separate repository that:
60+
61+1. **Registers repos** via git URL โ€” bare clones with treeless filter for speed
62+2. **Provisions containers** per task via OrbStack โ€” each task gets a fully isolated environment with its own git worktree, browser, and logs
63+3. **Runs PAS inside containers** โ€” pas run pipeline.dot runs inside the container, not on the host
64+4. **PRs results back** โ€” uses gh inside the container to open PRs against the source repo
65+5. **Preserves logs/observability** โ€” structured JSON log files on persistent volumes, queryable via hl CLI, promotable to Loki/Grafana later
66+6. **Enforces architecture** โ€” runs linters with agent-readable remediation messages on every task
67+7. **Fights entropy** โ€” scheduled background PAS pipelines via macOS launchd for doc-gardening, quality scanning, and pattern drift detection
68+
69+## Technical Approach
70+
71+### Architecture
72+
73+The system is split into two crates to start, with internal trait boundaries designed for future extraction:
74+
75+- **reckoner-cli** โ€” clap-based CLI binary (reck)
76+- **reckoner-core** โ€” engine modules behind trait interfaces:
77+ - repo_manager: git clone/fetch/worktree/PR
78+ - container_mgr: OrbStack create/start/stop/rm (ContainerRuntime + ContainerExecutor traits)
79+ - task_runner: provision, pas run, collect
80+ - toolchain: per-repo code quality tools (ruff, ty, biome, etc.)
81+ - lint_runner: Reckoner's architectural linters (LintRule trait)
82+ - obs_collector: gather logs post-run
83+- **State**: SQLite via rusqlite (sync, no pool)
84+- **Logs**: Structured JSONL files on persistent volumes
85+
86+The ContainerRuntime trait is split from ContainerExecutor to enable future remote execution (SSH-based executor + local runtime):
87+
88+```rust
89+#[async_trait]
90+trait ContainerRuntime: Send + Sync {
91+ async fn create(&self, spec: ContainerSpec) -> Result<ContainerId>;
92+ async fn start(&self, id: &ContainerId) -> Result<()>;
93+ async fn stop(&self, id: &ContainerId) -> Result<()>;
94+ async fn remove(&self, id: &ContainerId) -> Result<()>;
95+}
96+
97+#[async_trait]
98+trait ContainerExecutor: Send + Sync {
99+ async fn exec(&self, id: &ContainerId, cmd: &[&str]) -> Result<ExecResult>;
100+ async fn exec_stream(&self, id: &ContainerId, cmd: &[&str]) -> Result<ExecStream>;
101+}
102+```
103+
104+**PAS integration contract:** PAS needs a --output-result path flag added to pas run that writes PipelineResult as JSON. Reckoner reads this from the volume mount. Without this, Reckoner must infer success/failure from exit codes, which is fragile.
105+
106+### Data Model
107+
108+```sql
109+CREATE TABLE repos (
110+ id INTEGER PRIMARY KEY AUTOINCREMENT,
111+ url TEXT NOT NULL UNIQUE,
112+ name TEXT NOT NULL,
113+ local_path TEXT NOT NULL,
114+ default_branch TEXT NOT NULL DEFAULT 'main',
115+ last_synced TEXT,
116+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
117+);
118+
119+CREATE TABLE tasks (
120+ id TEXT PRIMARY KEY,
121+ repo_id INTEGER NOT NULL REFERENCES repos(id),
122+ schedule_id INTEGER REFERENCES schedules(id),
123+ prompt TEXT NOT NULL,
124+ status TEXT NOT NULL DEFAULT 'pending'
125+ CHECK (status IN ('pending','provisioning','running',
126+ 'linting','pr_open','done','failed')),
127+ container_id TEXT,
128+ branch_name TEXT,
129+ pr_url TEXT,
130+ pipeline_path TEXT,
131+ total_cost_usd REAL DEFAULT 0.0,
132+ attempt_count INTEGER DEFAULT 1,
133+ failed_stage TEXT,
134+ error_message TEXT,
135+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
136+ started_at TEXT,
137+ completed_at TEXT
138+);
139+
140+CREATE TABLE task_transitions (
141+ id INTEGER PRIMARY KEY AUTOINCREMENT,
142+ task_id TEXT NOT NULL REFERENCES tasks(id),
143+ from_status TEXT NOT NULL,
144+ to_status TEXT NOT NULL,
145+ timestamp TEXT NOT NULL DEFAULT (datetime('now')),
146+ detail TEXT
147+);
148+
149+CREATE TABLE runs (
150+ id INTEGER PRIMARY KEY AUTOINCREMENT,
151+ task_id TEXT NOT NULL REFERENCES tasks(id),
152+ pipeline_path TEXT NOT NULL,
153+ status TEXT NOT NULL,
154+ cost_usd REAL DEFAULT 0.0,
155+ duration_secs INTEGER,
156+ logs_path TEXT NOT NULL,
157+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
158+);
159+
160+CREATE TABLE lint_results (
161+ id INTEGER PRIMARY KEY AUTOINCREMENT,
162+ repo_id INTEGER NOT NULL REFERENCES repos(id),
163+ task_id TEXT REFERENCES tasks(id),
164+ lint_run_id TEXT NOT NULL,
165+ rule_name TEXT NOT NULL,
166+ status TEXT NOT NULL,
167+ message TEXT,
168+ remediation TEXT,
169+ file_path TEXT,
170+ line_number INTEGER,
171+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
172+);
173+
174+CREATE TABLE schedules (
175+ id INTEGER PRIMARY KEY AUTOINCREMENT,
176+ repo_id INTEGER NOT NULL REFERENCES repos(id),
177+ name TEXT NOT NULL,
178+ pipeline_path TEXT NOT NULL,
179+ cron_expr TEXT NOT NULL,
180+ enabled INTEGER NOT NULL DEFAULT 1,
181+ last_run TEXT,
182+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
183+);
184+
185+CREATE INDEX idx_tasks_status ON tasks(status);
186+CREATE INDEX idx_tasks_repo_id ON tasks(repo_id);
187+CREATE INDEX idx_tasks_schedule_id ON tasks(schedule_id);
188+CREATE INDEX idx_runs_task_id ON runs(task_id);
189+CREATE INDEX idx_lint_results_repo_task ON lint_results(repo_id, task_id);
190+CREATE INDEX idx_schedules_enabled ON schedules(enabled);
191+```
192+
193+**SQLite configuration (set once on connection open):**
194+- journal_mode=WAL, synchronous=NORMAL, busy_timeout=5000
195+- foreign_keys=ON, cache_size=-64000, mmap_size=256MB, temp_store=MEMORY
196+- Migrations via rusqlite_migration (PRAGMA user_version, no migration tables)
197+- Single Connection per invocation, no pool
198+- Long-running tasks: open/close connections around each state transition
199+- File permissions: 0600 on reckoner.db and backups
200+
201+**outcome_json stored on DISK** at logs_path/outcome.json, NOT in SQLite. This is critical for keeping the DB under 100MB.
202+
203+### Container Lifecycle
204+
205+Each task gets a container with a dedicated git worktree:
206+
207+```
208+reck task my-app "add user auth"
209+
210+1. PROVISION
211+ - git fetch origin in ~/.reckoner/repos/my-app.git (bare)
212+ - git worktree add ~/.reckoner/worktrees/reck-{id} -b reckoner/feat/reck-{id}
213+ - docker create from reckoner-base image:
214+ - read_only: true (root filesystem)
215+ - tmpfs: /tmp (512m), /home/agent/.cache (1g)
216+ - bind mount: worktree to /workspace (rw)
217+ - bind mount: logs volume (rw)
218+ - secrets: /run/secrets/anthropic_api_key, gh_token
219+ - cap_drop: ALL, security_opt: no-new-privileges
220+ - network: reckoner-net (egress filtered via Squid proxy)
221+ - resources: --memory 4g --cpus 4 --pids-limit 512
222+ - user: 1000:1000
223+ - docker start
224+
225+2. EXECUTE
226+ - Generate pipeline (pas generate) OR use provided .dot
227+ - pas run pipeline.dot --workdir /workspace --output-result /workspace/.reckoner/result.json
228+ - Stream progress via docker logs
229+ - Read result.json from volume mount
230+
231+3. LINT
232+ - Run architectural linters inside container
233+ - If failures: lint-fix loop (max 3 iterations)
234+ - Feed remediation to PAS fixup pipeline, re-lint
235+ - Record lint results in SQLite
236+
237+4. PR
238+ - git add + commit inside container
239+ - git push origin reckoner/feat/reck-{id}
240+ - gh pr create with structured body template
241+ - Record PR URL in SQLite
242+
243+5. COLLECT
244+ - Logs already on volume mount (structured JSONL)
245+ - Update SQLite (status=done, cost, PR URL)
246+ - docker stop + docker rm
247+ - git worktree remove
248+
249+Done. Container gone, worktree gone, logs preserved.
250+```
251+
252+### Git + PR Integration
253+
254+**Shell out to git CLI** (not git2/gitoxide). Auth is free via credential helpers. Containers already have git. No C deps, no build complexity. Set GIT_TERMINAL_PROMPT=0 to prevent blocking.
255+
256+**Shell out to gh CLI** for PR lifecycle. Handles auth, JSON output, auto-detection of repo/branch.
257+
258+**Credentials inside containers:** GH_TOKEN via Docker secrets + gh auth setup-git in entrypoint. Single token works for both git push and gh pr create.
259+
260+**Branch naming:** reckoner/type/id-slug (e.g., reckoner/feat/reck-42-add-user-auth). Namespaced, regex-enforceable. Auto-delete on PR merge.
261+
262+**Merge conflicts:** Preemptive rebase before PR. If rebase fails, abandon-and-retry (re-checkout from current main, re-run pipeline).
263+
264+**Bare clone + worktree pattern:**
265+- reck add does git clone --bare --filter=blob:none (treeless, fast)
266+- Each task gets git worktree add from the bare clone
267+- All worktrees share one object store (2GB repo stored once)
268+- Git prevents same branch in two worktrees (built-in safety)
269+- Worktree has native filesystem speed inside container
270+
271+### Toolchain (Per-Repo Code Quality)
272+
273+Reckoner distinguishes two kinds of code checking:
274+
275+1. **Toolchain** โ€” language-specific code quality tools the *repo* needs (linters, type checkers, formatters). These are the tools you'd run in CI. Configurable per-repo.
276+2. **Architectural linters** โ€” Reckoner's own structural checks (file size, dependency direction, doc freshness). These enforce harness-level invariants.
277+
278+Both run in the LINT phase. Toolchain runs first (fix code quality), then architectural linters (fix structural issues).
279+
280+**Toolchain is pluggable.** Tools are configured per-repo in `.reckoner/toolchain.toml`, falling back to auto-detection, falling back to global defaults. The framework doesn't hardcode any specific tool โ€” it invokes whatever command is configured and parses the exit code.
281+
282+**Per-repo config** (`.reckoner/toolchain.toml` in the repo root):
283+```toml
284+[python]
285+lint = "ruff check --fix ."
286+format = "ruff format ."
287+typecheck = "ty check ."
288+
289+[typescript]
290+lint = "biome check --fix ."
291+format = "biome format --fix ."
292+typecheck = "biome check ."
293+
294+[rust]
295+lint = "cargo clippy --workspace -- -D warnings"
296+format = "cargo fmt --all"
297+typecheck = "cargo check --workspace"
298+```
299+
300+**Global defaults** in `~/.reckoner/config.toml`:
301+```toml
302+[toolchain.defaults.python]
303+lint = "ruff check --fix ."
304+format = "ruff format ."
305+typecheck = "ty check ."
306+
307+[toolchain.defaults.typescript]
308+lint = "biome check --fix ."
309+format = "biome format --fix ."
310+typecheck = "biome check ."
311+
312+[toolchain.defaults.rust]
313+lint = "cargo clippy --workspace -- -D warnings"
314+format = "cargo fmt --all"
315+typecheck = "cargo check --workspace"
316+```
317+
318+**Auto-detection:** If no `.reckoner/toolchain.toml` exists, Reckoner detects languages from file extensions and applies global defaults. `reck add` reports which toolchain it will use and scaffolds a `.reckoner/toolchain.toml` for the user to customize.
319+
320+**Execution in the LINT phase:**
321+1. Detect which languages are present in changed files
322+2. Run `format` commands (auto-fix style issues before anything else)
323+3. Run `lint` commands (catch code quality issues)
324+4. Run `typecheck` commands (catch type errors)
325+5. If any fail: feed errors into the lint-fix loop
326+
327+**Base image implications:** The base container image includes common runtimes. Language-specific tools are installed per-repo via the container entrypoint or a setup script. For Python repos, the entrypoint runs `uv sync` to install dependencies including ruff/ty. For TypeScript repos, it runs `npm install` or equivalent.
328+
329+### Architectural Linters (Reckoner's Own)
330+
331+Separate from the per-repo toolchain, Reckoner runs its own structural linters that enforce harness-level invariants across all repos.
332+
333+**JSON-Lines output** to stdout. One JSON object per line. Token-efficient for LLM consumption, streaming-friendly, trivial to author in any language.
334+
335+```json
336+{
337+ "rule": "dependency-direction",
338+ "status": "fail",
339+ "level": "error",
340+ "file": "src/service/handler.rs",
341+ "line": 12,
342+ "message": "service layer imports from ui layer. Imports must flow downward.",
343+ "remediation": "Move the shared type to types:: or define a trait in service::. Dependency direction: types, config, repo, service, runtime, ui.",
344+ "context": {
345+ "source_layer": "service",
346+ "target_layer": "ui"
347+ }
348+}
349+```
350+
351+**Plugin discovery:** Executable directory scan. repo/.reckoner/linters/ then ~/.reckoner/linters/ then built-in. Naming: reck-lint-name. Exit codes: 0=pass, 1=failures, 2=linter error.
352+
353+**Built-in architectural linters:**
354+
355+| Linter | What it checks |
356+|--------|----------------|
357+| file-size | No source file exceeds N lines (default 500) |
358+| dependency-direction | Layer imports flow in one direction only (configurable per-repo) |
359+| doc-freshness | Docs reference code that changed since last doc update |
360+| agents-md-toc | AGENTS.md exists, under N lines, points to docs/ |
361+| structured-logging | No raw println/console.log |
362+
363+### Lint-Fix Loop
364+
365+Both toolchain and architectural linters feed into the same fix loop (max 3 iterations):
366+
367+1. Run toolchain (format โ†’ lint โ†’ typecheck), collect errors
368+2. Run architectural linters, collect JSON-Lines
369+3. If no failures: done
370+4. Construct fixup prompt from all errors + remediation fields
371+5. Run lightweight PAS fixup pipeline (edit tools only, no shell)
372+6. Re-run ALL checks (a fix can introduce new violations)
373+7. Track stuck violations (same rule+file+line across iterations) for human review
374+
375+**Key principle:** Write error messages for the agent, not a human. The remediation field IS the fix instruction.
376+
377+### Observability (Tiered)
378+
379+**Tier 1 (start here): Structured JSON files + hl CLI**
380+- Containers write JSONL to stdout, Reckoner captures to ~/.reckoner/logs/
381+- Query with hl (Rust, 2 GiB/s): hl --filter 'task_id=reck-42' logs/
382+- Zero infrastructure, zero idle cost
383+
384+**Tier 2 (web UI): SQLite log store + datasette**
385+- ~10MB idle, SQL querying, web UI
386+
387+**Tier 3 (scale): VictoriaLogs + Grafana**
388+- 87% less memory than Loki, auto-indexes all fields, ~120-200MB idle
389+
390+**Tier 4 (Loki ecosystem): Loki monolithic + Grafana**
391+- Promtail is EOL (March 2026). Use direct HTTP push or Grafana Alloy.
392+- 300-500MB idle. Only if you specifically want LogQL.
393+
394+### Background Agents (macOS launchd)
395+
396+**launchd LaunchAgents** at ~/Library/LaunchAgents/com.reckoner.name.plist:
397+- Sleep-aware: fires on wake if missed during sleep
398+- Concurrent-run-safe: will not start second instance
399+- ProcessType: Background + LowPriorityIO: true
400+
401+**Plist generation:** plist crate + custom serde struct. Absolute paths required (no tilde expansion). Explicit PATH in EnvironmentVariables including /opt/homebrew/bin.
402+
403+**CLI:**
404+```
405+reck schedule add --name entropy-gc --pipeline entropy-gc.dot --cron "0 3 * * *"
406+reck schedule list
407+reck schedule remove entropy-gc
408+reck schedule status entropy-gc
409+reck schedule run entropy-gc
410+```
411+
412+**Security for background agents:**
413+- Read-only tools for scan/analysis phases
414+- Human approval gate before push/PR
415+- Lower budget caps than interactive tasks
416+- Dry-run mode by default
417+
418+**Failure notifications:** terminal-notifier (Homebrew) with osascript fallback.
419+
420+### Security Model
421+
422+**Container hardening:**
423+- cap_drop: ALL + no-new-privileges
424+- read_only: true root filesystem + tmpfs scratch
425+- pids-limit: 512 (fork bomb protection)
426+- memory: 4g, memory-swap: 4g (no swap, OOM-kill)
427+- user: 1000:1000 (non-root)
428+- Never mount Docker socket
429+- OrbStack VM boundary = two-layer isolation
430+
431+**Secrets:**
432+- Docker Compose secrets (file-mounted to /run/secrets/)
433+- Fine-grained PATs scoped per-repo (contents:write + pull_requests:write only)
434+- SSH agent socket forwarding if needed (never copy keys)
435+- Secrets die with container
436+
437+**Network:**
438+- Squid forward proxy on host with domain allowlist
439+- Allow: api.anthropic.com, api.openai.com, github.com, api.github.com, package registries
440+- Block all other outbound traffic
441+- --network none for pipeline steps that do not need network
442+
443+**Filesystem:**
444+- Worktree bind-mount (rw) โ€” working files only, not .git/
445+- Log volume (rw) โ€” named Docker volume
446+- Everything else: do not mount
447+
448+**Base image:**
449+- Pinned by SHA256 digest
450+- Claude Code install script vendored and audited
451+- All apt packages version-pinned
452+- reck doctor verifies image digest
453+
454+### CLI Commands
455+
456+```
457+reck add <git-url> # Bare treeless clone, register
458+reck remove <repo-name> # Unregister
459+reck list # List repos
460+reck sync <repo-name> # git fetch --prune
461+
462+reck task <repo> "<prompt>" # Full lifecycle
463+reck task <repo> --pipeline <.dot> # Use specific pipeline
464+reck task <repo> --spec <spec.md> # Generate pipeline from spec
465+reck task <repo> --resume <id> # Resume failed task
466+
467+reck status # All active tasks
468+reck status <task-id> # Detailed + transition history
469+reck logs <task-id> # Logs via hl
470+reck logs <task-id> --app # App logs only
471+reck logs <task-id> --lint # Lint results
472+
473+reck lint <repo> # Run arch linters
474+reck lint <repo> --fix # Linters + auto-fix loop
475+
476+reck schedule add/list/remove/status/run
477+
478+reck infra up/down/status # Observability stack (Tier 3+)
479+reck observe # Open dashboard
480+
481+reck config # Show config
482+reck init # Interactive setup
483+reck doctor # Health checks
484+reck doctor --integrity # SQLite vs filesystem consistency
485+```
486+
487+### Configuration
488+
489+```toml
490+# ~/.reckoner/config.toml
491+
492+[general]
493+repos_dir = "~/.reckoner/repos"
494+worktrees_dir = "~/.reckoner/worktrees"
495+logs_dir = "~/.reckoner/logs"
496+db_path = "~/.reckoner/reckoner.db"
497+
498+[container]
499+runtime = "orbstack"
500+base_image = "reckoner-base:latest"
501+network = "reckoner-net"
502+default_memory = "4g"
503+default_cpus = 4
504+pids_limit = 512
505+
506+[observability]
507+tier = "files"
508+
509+[git]
510+auto_pr = true
511+pr_prefix = "reckoner"
512+commit_author = "Reckoner <reckoner@local>"
513+
514+[pas]
515+binary = "pas"
516+default_model = "sonnet"
517+default_max_budget_usd = 10.0
518+default_max_steps = 200
519+min_version = "0.5.1"
520+
521+[toolchain.defaults.python]
522+lint = "ruff check --fix ."
523+format = "ruff format ."
524+typecheck = "ty check ."
525+
526+[toolchain.defaults.typescript]
527+lint = "biome check --fix ."
528+format = "biome format --fix ."
529+typecheck = "biome check ."
530+
531+[toolchain.defaults.rust]
532+lint = "cargo clippy --workspace -- -D warnings"
533+format = "cargo fmt --all"
534+typecheck = "cargo check --workspace"
535+
536+[linters]
537+enabled = true
538+fail_on_warning = false
539+max_fix_iterations = 3
540+
541+[linters.builtin]
542+file-size = { enabled = true, max_lines = 500 }
543+dependency-direction = { enabled = true }
544+doc-freshness = { enabled = true, max_age_days = 30 }
545+agents-md-toc = { enabled = true, max_lines = 150 }
546+structured-logging = { enabled = true }
547+
548+[security]
549+egress_proxy = true
550+egress_allowlist = [
551+ "api.anthropic.com",
552+ "api.openai.com",
553+ "github.com",
554+ "api.github.com",
555+]
556+```
557+
558+### Dependency Stack
559+
560+```toml
561+[dependencies]
562+clap = { version = "4", features = ["derive"] }
563+rusqlite = { version = "0.39", features = ["bundled"] }
564+rusqlite_migration = "1"
565+bollard = "0.20"
566+toml = "0.8"
567+serde = { version = "1", features = ["derive"] }
568+serde_json = "1"
569+tokio = { version = "1", features = ["rt-multi-thread", "macros", "process"] }
570+plist = "1"
571+croner = "2"
572+dirs = "6"
573+chrono = { version = "0.4", features = ["serde"] }
574+uuid = { version = "1", features = ["v4"] }
575+tracing = "0.1"
576+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
577+tracing-appender = "0.2"
578+anyhow = "1"
579+thiserror = "2"
580+regex = "1"
581+```
582+
583+## Implementation Phases
584+
585+### Phase 1: Foundation (CLI + Repo + Config)
586+- Rust workspace: reckoner-cli, reckoner-core
587+- CLI skeleton: add, list, remove, sync, config, init
588+- SQLite with rusqlite + rusqlite_migration
589+- Config parsing (toml + serde)
590+- Git: bare treeless clone, fetch, worktree add/remove
591+
592+### Phase 2: Container Engine
593+- bollard for container lifecycle
594+- Base Dockerfile (pinned, hardened, non-root)
595+- Docker secrets, egress proxy (Squid), network setup
596+- reck doctor
597+
598+### Phase 3: Task Runner
599+- reck task full lifecycle
600+- Task state machine with transitions and audit trail
601+- PAS execution via docker exec + --output-result
602+- Log collection to JSONL, reck status/logs
603+
604+### Phase 4: Git + PR Integration
605+- Worktree per task, branch naming, commit/push/PR
606+- gh auth setup-git in entrypoint
607+- Structured PR body template
608+- Cleanup: worktree remove + branch delete
609+
610+### Phase 5: Toolchain + Linter Framework
611+- Pluggable toolchain: per-repo `.reckoner/toolchain.toml` with language auto-detection
612+- Default presets: ruff+ty (Python), biome (TypeScript), clippy+fmt (Rust)
613+- Architectural linters: JSON-Lines runner with plugin discovery
614+- Built-in linters: file-size, dependency-direction, doc-freshness, agents-md-toc
615+- Lint-fix loop (max 3 iterations) covering both toolchain and architectural linters
616+- Per-rule config in config.toml, per-repo overrides
617+
618+### Phase 6: Observability
619+- Tier 1: JSONL files + hl integration
620+- Tier 2+: optional SQLite/VictoriaLogs/Loki via reck infra
621+
622+### Phase 7: Background Agents
623+- launchd plist generation, schedule CLI
624+- Restricted tools, approval gates, lower budgets
625+- Built-in pipelines: entropy-gc, doc-gardening, quality-scan
626+
627+## Risk Analysis
628+
629+| Risk | Mitigation |
630+|------|------------|
631+| OrbStack API changes | ContainerRuntime trait; bollard uses stable Docker API |
632+| Container resource exhaustion | Per-container limits, reck status shows usage |
633+| PAS version mismatch | reck doctor checks version; config pins minimum |
634+| Git auth inside containers | Scoped fine-grained PATs, Docker secrets |
635+| Agent reads API keys | Docker secrets (file mount), egress proxy blocks exfil |
636+| Agent exfiltrates code | Network egress allowlist via Squid proxy |
637+| Concurrent same-repo tasks | Git worktrees with built-in branch locking |
638+| SQLite/filesystem desync | reck doctor --integrity |
639+| Background agent prompt injection | Restricted tools, approval gate before push |
640+| Base image supply chain | Pin by SHA, vendor install scripts |
641+
642+## Sources
643+
644+- [OpenAI Harness Engineering](https://openai.com/index/harness-engineering/)
645+- [bollard crate](https://crates.io/crates/bollard)
646+- [rusqlite](https://crates.io/crates/rusqlite)
647+- [hl JSON log viewer](https://github.com/pamburus/hl)
648+- [OWASP Docker Security](https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html)
649+- [BitsAI-Fix: LLM Lint Resolution](https://arxiv.org/html/2508.03487v1)
650+- [Apple: Creating Launch Agents](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html)
651+- [VictoriaLogs](https://docs.victoriametrics.com/victorialogs/)
652+- [SkyPilot: SQLite Concurrency](https://blog.skypilot.co/abusing-sqlite-to-handle-concurrency/)