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: feat4+
status: active5+
date: 2026-04-096+
deepened: 2026-04-097+
---8+
9+
## Enhancement Summary10+
11+
**Deepened on:** 2026-04-0912+
**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 Research15+
1. **Switch from sqlx to rusqlite** โ sync API matches SQLite reality, faster CLI startup, no pool needed16+
2. **Start with JSON log files, not Loki** โ zero infra, hl CLI for queries, promote to Loki/VictoriaLogs later17+
3. **Bare clone + git worktree per task** โ solves concurrent same-repo, improves virtiofs perf, shared object store18+
4. **Shell out to git/gh** โ not git2/gitoxide; auth is free, containers already have git19+
5. **Docker Compose secrets** โ not env vars; prevents agent from reading API keys via env20+
6. **Network egress filtering** โ Squid proxy allowlist for LLM APIs + GitHub only21+
7. **launchd LaunchAgents** โ sleep-aware, concurrent-run-safe, plist crate for generation22+
8. **JSON-Lines linter output** โ token-efficient for agents, with natural-language remediation field23+
9. **PAS needs --output-result** โ structured result contract across container boundary24+
10. **outcome_json out of SQLite** โ prevents DB bloat, keeps under 100MB target25+
26+
### Critical Security Findings27+
- Use repo-scoped fine-grained PATs, not SSH keys (limits blast radius)28+
- Drop ALL container capabilities + no-new-privileges29+
- Read-only root filesystem + tmpfs scratch30+
- Separate .git/ from working tree bind mount31+
- Cap background agents with approval gates32+
33+
---34+
35+
# Reckoner โ Software Factory Wrapping PAS36+
37+
## Overview38+
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 / Motivation46+
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 produce51+
- Observability of the running application being built52+
- Recurring maintenance (doc rot, entropy accumulation, quality drift)53+
- The full lifecycle: task intake, build, verify, PR, merge54+
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 Solution58+
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 speed62+
2. **Provisions containers** per task via OrbStack โ each task gets a fully isolated environment with its own git worktree, browser, and logs63+
3. **Runs PAS inside containers** โ pas run pipeline.dot runs inside the container, not on the host64+
4. **PRs results back** โ uses gh inside the container to open PRs against the source repo65+
5. **Preserves logs/observability** โ structured JSON log files on persistent volumes, queryable via hl CLI, promotable to Loki/Grafana later66+
6. **Enforces architecture** โ runs linters with agent-readable remediation messages on every task67+
7. **Fights entropy** โ scheduled background PAS pipelines via macOS launchd for doc-gardening, quality scanning, and pattern drift detection68+
69+
## Technical Approach70+
71+
### Architecture72+
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/PR78+
- container_mgr: OrbStack create/start/stop/rm (ContainerRuntime + ContainerExecutor traits)79+
- task_runner: provision, pas run, collect80+
- 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-run83+
- **State**: SQLite via rusqlite (sync, no pool)84+
- **Logs**: Structured JSONL files on persistent volumes85+
86+
The ContainerRuntime trait is split from ContainerExecutor to enable future remote execution (SSH-based executor + local runtime):87+
88+
```rust89+
#[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 Model107+
108+
```sql109+
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 TEXT138+
);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 TEXT147+
);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=5000195+
- foreign_keys=ON, cache_size=-64000, mmap_size=256MB, temp_store=MEMORY196+
- Migrations via rusqlite_migration (PRAGMA user_version, no migration tables)197+
- Single Connection per invocation, no pool198+
- Long-running tasks: open/close connections around each state transition199+
- File permissions: 0600 on reckoner.db and backups200+
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 Lifecycle204+
205+
Each task gets a container with a dedicated git worktree:206+
207+
```208+
reck task my-app "add user auth"209+
210+
1. PROVISION211+
- 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_token219+
- cap_drop: ALL, security_opt: no-new-privileges220+
- network: reckoner-net (egress filtered via Squid proxy)221+
- resources: --memory 4g --cpus 4 --pids-limit 512222+
- user: 1000:1000223+
- docker start224+
225+
2. EXECUTE226+
- Generate pipeline (pas generate) OR use provided .dot227+
- pas run pipeline.dot --workdir /workspace --output-result /workspace/.reckoner/result.json228+
- Stream progress via docker logs229+
- Read result.json from volume mount230+
231+
3. LINT232+
- Run architectural linters inside container233+
- If failures: lint-fix loop (max 3 iterations)234+
- Feed remediation to PAS fixup pipeline, re-lint235+
- Record lint results in SQLite236+
237+
4. PR238+
- git add + commit inside container239+
- git push origin reckoner/feat/reck-{id}240+
- gh pr create with structured body template241+
- Record PR URL in SQLite242+
243+
5. COLLECT244+
- Logs already on volume mount (structured JSONL)245+
- Update SQLite (status=done, cost, PR URL)246+
- docker stop + docker rm247+
- git worktree remove248+
249+
Done. Container gone, worktree gone, logs preserved.250+
```251+
252+
### Git + PR Integration253+
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 clone267+
- 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 container270+
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+
```toml284+
[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+
```toml302+
[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 files322+
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 loop326+
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+
```json336+
{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 Loop364+
365+
Both toolchain and architectural linters feed into the same fix loop (max 3 iterations):366+
367+
1. Run toolchain (format โ lint โ typecheck), collect errors368+
2. Run architectural linters, collect JSON-Lines369+
3. If no failures: done370+
4. Construct fixup prompt from all errors + remediation fields371+
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 review374+
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 cost383+
384+
**Tier 2 (web UI): SQLite log store + datasette**385+
- ~10MB idle, SQL querying, web UI386+
387+
**Tier 3 (scale): VictoriaLogs + Grafana**388+
- 87% less memory than Loki, auto-indexes all fields, ~120-200MB idle389+
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 sleep398+
- Concurrent-run-safe: will not start second instance399+
- ProcessType: Background + LowPriorityIO: true400+
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 list407+
reck schedule remove entropy-gc408+
reck schedule status entropy-gc409+
reck schedule run entropy-gc410+
```411+
412+
**Security for background agents:**413+
- Read-only tools for scan/analysis phases414+
- Human approval gate before push/PR415+
- Lower budget caps than interactive tasks416+
- Dry-run mode by default417+
418+
**Failure notifications:** terminal-notifier (Homebrew) with osascript fallback.419+
420+
### Security Model421+
422+
**Container hardening:**423+
- cap_drop: ALL + no-new-privileges424+
- read_only: true root filesystem + tmpfs scratch425+
- 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 socket429+
- OrbStack VM boundary = two-layer isolation430+
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 container436+
437+
**Network:**438+
- Squid forward proxy on host with domain allowlist439+
- Allow: api.anthropic.com, api.openai.com, github.com, api.github.com, package registries440+
- Block all other outbound traffic441+
- --network none for pipeline steps that do not need network442+
443+
**Filesystem:**444+
- Worktree bind-mount (rw) โ working files only, not .git/445+
- Log volume (rw) โ named Docker volume446+
- Everything else: do not mount447+
448+
**Base image:**449+
- Pinned by SHA256 digest450+
- Claude Code install script vendored and audited451+
- All apt packages version-pinned452+
- reck doctor verifies image digest453+
454+
### CLI Commands455+
456+
```457+
reck add <git-url> # Bare treeless clone, register458+
reck remove <repo-name> # Unregister459+
reck list # List repos460+
reck sync <repo-name> # git fetch --prune461+
462+
reck task <repo> "<prompt>" # Full lifecycle463+
reck task <repo> --pipeline <.dot> # Use specific pipeline464+
reck task <repo> --spec <spec.md> # Generate pipeline from spec465+
reck task <repo> --resume <id> # Resume failed task466+
467+
reck status # All active tasks468+
reck status <task-id> # Detailed + transition history469+
reck logs <task-id> # Logs via hl470+
reck logs <task-id> --app # App logs only471+
reck logs <task-id> --lint # Lint results472+
473+
reck lint <repo> # Run arch linters474+
reck lint <repo> --fix # Linters + auto-fix loop475+
476+
reck schedule add/list/remove/status/run477+
478+
reck infra up/down/status # Observability stack (Tier 3+)479+
reck observe # Open dashboard480+
481+
reck config # Show config482+
reck init # Interactive setup483+
reck doctor # Health checks484+
reck doctor --integrity # SQLite vs filesystem consistency485+
```486+
487+
### Configuration488+
489+
```toml490+
# ~/.reckoner/config.toml491+
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 = 4504+
pids_limit = 512505+
506+
[observability]507+
tier = "files"508+
509+
[git]510+
auto_pr = true511+
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.0518+
default_max_steps = 200519+
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 = true538+
fail_on_warning = false539+
max_fix_iterations = 3540+
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 = true550+
egress_allowlist = [551+
"api.anthropic.com",552+
"api.openai.com",553+
"github.com",554+
"api.github.com",555+
]556+
```557+
558+
### Dependency Stack559+
560+
```toml561+
[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 Phases584+
585+
### Phase 1: Foundation (CLI + Repo + Config)586+
- Rust workspace: reckoner-cli, reckoner-core587+
- CLI skeleton: add, list, remove, sync, config, init588+
- SQLite with rusqlite + rusqlite_migration589+
- Config parsing (toml + serde)590+
- Git: bare treeless clone, fetch, worktree add/remove591+
592+
### Phase 2: Container Engine593+
- bollard for container lifecycle594+
- Base Dockerfile (pinned, hardened, non-root)595+
- Docker secrets, egress proxy (Squid), network setup596+
- reck doctor597+
598+
### Phase 3: Task Runner599+
- reck task full lifecycle600+
- Task state machine with transitions and audit trail601+
- PAS execution via docker exec + --output-result602+
- Log collection to JSONL, reck status/logs603+
604+
### Phase 4: Git + PR Integration605+
- Worktree per task, branch naming, commit/push/PR606+
- gh auth setup-git in entrypoint607+
- Structured PR body template608+
- Cleanup: worktree remove + branch delete609+
610+
### Phase 5: Toolchain + Linter Framework611+
- Pluggable toolchain: per-repo `.reckoner/toolchain.toml` with language auto-detection612+
- Default presets: ruff+ty (Python), biome (TypeScript), clippy+fmt (Rust)613+
- Architectural linters: JSON-Lines runner with plugin discovery614+
- Built-in linters: file-size, dependency-direction, doc-freshness, agents-md-toc615+
- Lint-fix loop (max 3 iterations) covering both toolchain and architectural linters616+
- Per-rule config in config.toml, per-repo overrides617+
618+
### Phase 6: Observability619+
- Tier 1: JSONL files + hl integration620+
- Tier 2+: optional SQLite/VictoriaLogs/Loki via reck infra621+
622+
### Phase 7: Background Agents623+
- launchd plist generation, schedule CLI624+
- Restricted tools, approval gates, lower budgets625+
- Built-in pipelines: entropy-gc, doc-gardening, quality-scan626+
627+
## Risk Analysis628+
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+
## Sources643+
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/)