Commit graph

153 commits

Author SHA1 Message Date
ecd47fe3db revert fcb9c189e5
revert fix(agentic): harden TODO workspace write

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-18 11:22:27 +00:00
Codex
fcb9c189e5 fix(agentic): harden TODO workspace write
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-18 08:54:32 +01:00
Snider
60f4cb6fdb feat(agent): gpt-5.4-mini/mature pass 2
- `git add` / `git commit` fail with `Operation not permitted` on `.git/index.lock`
  - even a plain `touch .git/...` is blocked

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-18 08:34:52 +01:00
Snider
651783e1f5 feat(agent): gpt-5.4-mini/mature pass 1
Commit:

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-18 08:32:10 +01:00
Snider
43568cae01 test(agentic): cover message and dispatch sync contracts
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-17 21:01:10 +01:00
Snider
2eda43d5ad hardening(prep): fail closed on specs copy
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-17 20:38:42 +01:00
Snider
e837a284af feat(agent): RFC §9 agentic_auth_login MCP tool + dedupe tool registrations
Three load-bearing gaps between the agent RFC and the MCP surface:

- RFC §9 Fleet Mode describes the 6-digit pairing-code bootstrap as the
  primary way an unauthenticated node provisions its first AgentApiKey.
  `handleAuthLogin` existed as an Action but never surfaced as an MCP
  tool, so IDE/CLI callers had to shell out. Adds `agentic_auth_login`
  under `registerPlatformTools` with a thin wrapper over the existing
  handler so the platform contract stays single-sourced.
- `RegisterTools` was double-registering `agentic_scan` (bare
  `mcp.AddTool` before the CORE_MCP_FULL gate, then again via
  `AddToolRecorded` inside the gate). The second call silently replaced
  the first and bypassed tool-registry accounting, so REST bridging and
  metrics saw a zero for scan. Collapses both into a single recorded
  registration before the gate.
- `registerPlanTools` and `registerWatchTool` were also fired twice in
  the CORE_MCP_FULL branch. Removes the duplicates so the extended
  registration list mirrors the always-on list exactly once.
- Switches `agentic_prep_workspace` from bare `mcp.AddTool` to
  `AddToolRecorded` so prep-workspace participates in the same
  accounting as every other RFC §6 tool.

TestPrep_RegisterTools_Good_RegistersCompletionTool now asserts all
three `agentic_auth_*` tools surface, covering the new login registration
alongside provision/revoke.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 20:27:44 +01:00
Snider
5ef2aba27b fix(agent): workspace prep falls back to GOWORK search
runWorkspaceLanguagePrep now appends `GOWORK=` (empty) to the env passed
to `go work sync` so inherited `GOWORK=off` from a test runner or CI
environment doesn't short-circuit the workspace lookup. The extracted
workspace template includes a go.work referencing ./repo; without this
override the sync fails even though the file is right there.

Converged pass — no new features found this sample.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 14:13:02 +01:00
Snider
2fc0de321d feat(agent): RFC §15.5 orphan QA buffer recovery on startup
Adds `recoverStateOrphans` per RFC §15.5 — startup scans `.core/state/`
for leftover QA workspace buffers from dispatches that crashed before
commit, and discards them so partial cycles do not poison the diff
history described in RFC §7.

- `statestore.go` — new `recoverStateOrphans` wrapper around go-store's
  `RecoverOrphans("")` so the agent inherits the store's configured
  state directory
- `prep.go` — wires the recovery into OnStartup immediately after
  `hydrateWorkspaces` so the registry, queue, and buffers all come back
  into a consistent state on restart
- `statestore_test.go` — Good/Bad/Ugly coverage, includes the cwd
  redirect guard so the go-store default relative path cannot leak test
  artefacts into the package working tree

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 13:51:54 +01:00
Snider
03e5934607 feat(agent): RFC §15.5 parent workspace stats store
Adds `.core/workspace/db.duckdb` — the permanent record of dispatch
cycles described in RFC §15.5. Stats rows persist BEFORE workspace
directories are deleted so "what happened in the last 50 dispatches"
queries survive cleanup and sync drain.

- `workspace_stats.go` — lazy go-store handle for the parent stats DB,
  build/record/filter/list helpers, report payload projection
- `commit.go` — writes a stats row as part of the completion pipeline so
  every committed dispatch carries forward into the permanent record
- `commands_workspace.go` — `workspace/clean` captures stats before
  deleting, new `workspace/stats` command + `agentic.workspace.stats`
  action answer the spec's "query on the parent" use case

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 13:41:07 +01:00
Snider
eed2274746 feat(agent): pairing-code login per RFC §9 Fleet Mode
Implements `core login CODE` — exchanges a 6-digit pairing code generated
at app.lthn.ai/device for an AgentApiKey, persisted to ~/.claude/brain.key.
Pairing code is the proof, so the POST is unauthenticated.

- auth.go: AuthLoginInput/Output DTOs + handleAuthLogin handler
- commands_platform.go: login / auth/login / agentic:login CLI commands
  with cmdAuthLogin persisting the returned key
- prep.go: registered agentic.auth.login / agent.auth.login actions
- auth_test.go / commands_platform_test.go / prep_test.go: Good/Bad/Ugly
  triads per repo convention, including key persistence verification

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 12:51:17 +01:00
Snider
716546d0d5 feat(agent): workspace state mirror + ghost reap + sync queue via go-store
- prep.go TrackWorkspace mirrors into queue + concurrency store groups
  (previously only registry); hydrateWorkspaces reaps filesystem ghosts
  (dead PID → failed, persisted back to status.json) so cmdStatus and
  out-of-process consumers see coherent state (RFC §15.3)
- sync.go queue read/write goes through go-store first per RFC §16.5
  ("Queue persists across restarts in db.duckdb"), file remains fallback
  for graceful degradation
- statestore.go stateStoreGet helper for go-store-first reads
- tests/cli/restart — new CLI test for RFC §15.7 "dispatch → kill →
  restart → no ghost agents" dead-PID reap flow
- 4 new statestore tests: queue group mirror, concurrency refresh,
  sync queue persistence, fs ghost reap with disk write-back

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 12:36:44 +01:00
Snider
4684ae725a feat(agent): go-store backing for dispatch state per RFC §15
Introduce an optional go-store persistence layer for the three state
groups described in RFC §15.3 — queue, concurrency, registry — plus
runtime_state and dispatch_history used by the sync pipeline.

- statestore.go lazily opens `.core/db.duckdb` via go-store when
  available; nil-safe helpers return cleanly so in-memory/file-based
  fallbacks survive when the store cannot open (graceful degradation,
  RFC §15.6)
- prep.go tracks the store reference on the subsystem and closes it on
  shutdown; hydrateWorkspaces now consults the registry group before
  the filesystem scan so ghost agents are marked failed across
  restarts, and TrackWorkspace mirrors updates back into the cache
- runtime_state.go persists backoff + fail-count snapshots into the
  go-store runtime group so dispatch backoff survives restarts even
  when the JSON file rotates
- commit.go writes the completed dispatch record into dispatch_history
  for RFC §16.3 sync push to drain without rescanning workspaces
- statestore_test.go covers lazy-once init, restore/delete round trip,
  ghost-agent failure marking, and runtime-state replay across
  subsystem instances

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 12:17:08 +01:00
Snider
83364a6080 feat(agent): sync backoff + ledger + auto-flush loop
- sync.go: syncBackoffSchedule (1s/5s/15s/60s/5min) with per-push Attempts
  and NextAttempt honoured on retry (RFC §16.5)
- runSyncFlushLoop: ticks every minute from OnStartup when API key present,
  drains the queue without re-scanning workspaces
- SyncPushInput.QueueOnly: lets flush loop drain without triggering a full
  workspace scan (prevents duplicate pushes)
- Sync ledger at .core/sync/ledger.json: fingerprints keyed by workspace
  name + (updated_at, runs); skips already-synced workspaces until fresh
  activity
- docs/RFC-AGENT.md: synced from plans/code/core/agent/RFC.md with latest
  AgentPlan status enum, complete capability, pr.close/branch.delete,
  indexed_at/org brain fields

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 12:06:04 +01:00
Snider
edfcb1bdfe feat(agent): unblock factory dispatch, runtime-aware containers, RFC gaps
- paths.go: resolve relative workspace_root against $HOME/Code so workspaces
  land in the conventional location regardless of launch cwd (MCP stdio vs CLI)
- dispatch.go: container mounts use /home/agent (matches DEV_USER), plus
  runtime-aware dispatch (apple/docker/podman) with GPU toggle per RFC §15.5
- queue.go / runner/queue.go: DispatchConfig adds Runtime/Image/GPU fields;
  AgentIdentity parsing for the agents: block (RFC §10/§11)
- pr.go / commands_forge.go / actions.go: agentic_delete_branch tool +
  branch/delete CLI (RFC §7)
- brain/tools.go / provider.go: Org + IndexedAt fields on Memory (RFC §4)
- config/agents.yaml: document new dispatch fields, fix identity table
- tests: dispatch_runtime_test.go (21), expanded pr_test.go + queue_test.go,
  new CLI fixtures for branch/delete and pr/list

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-14 11:45:09 +01:00
Snider
db6d06ae2b merge: integrate forge dispatch + mcp changes with AX compliance sweep
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-13 09:39:41 +01:00
Snider
39914fbf14 refactor: AX compliance sweep — replace banned stdlib imports with core primitives
Replaced fmt, strings, sort, os, io, sync, encoding/json, path/filepath,
errors, log, reflect with core.Sprintf, core.E, core.Contains, core.Trim,
core.Split, core.Join, core.JoinPath, slices.Sort, c.Fs(), c.Lock(),
core.JSONMarshal, core.ReadAll and other CoreGO v0.8.0 primitives.

Framework boundary exceptions preserved where stdlib types are required
by external interfaces (Gin, net/http, CGo, Wails, bubbletea).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-13 09:32:00 +01:00
Snider
7a531d1112 perf(mcp): reduce tool count from 189 to 82
Gate non-essential MCP tools behind CORE_MCP_FULL=1 env var.
Core factory tools (dispatch, status, plan, issue, PR, scan, mirror,
watch, brain, files) always registered. Extended tools (session, sprint,
state, phase, task, template, message, content, platform, epic, remote,
review-queue, setup, metrics, RAG, webview) only when full mode enabled.

189 → 82 tools in default mode. Fixes slow MCP startup and tool
registration timeout in Claude Code.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-08 19:17:21 +01:00
Snider
5f0878d93d fix(mcp): update Subsystem interface to match mcp v0.5.1 Service API
All RegisterTools and internal register*Tool methods updated from
*mcp.Server to *coremcp.Service. Tool registration calls updated to
use svc.Server() for SDK AddTool calls. Monitor subsystem updated
to store *coremcp.Service and access Server() for Sessions/ResourceUpdated.
Tests updated to create coremcp.Service via New() instead of raw SDK server.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-07 14:11:19 +01:00
Snider
a4b72c6129 fix: migrate module paths from forge.lthn.ai to dappco.re
Replace all forge.lthn.ai import paths in Go source files with dappco.re
equivalents. Update go.mod deps to dappco.re versions as specified.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-07 13:09:47 +01:00
Virgil
4c6296c1c1 refactor(agentic): replace core path helpers
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 08:58:17 +00:00
Virgil
ce6f016d63 ax(brain): rename direct options for clarity
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 08:40:24 +00:00
Virgil
ceaa1601de refactor(agentic): improve prompt builder naming
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 07:23:08 +00:00
Virgil
b693695e41 feat(agentic): add content provider registry
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 07:18:38 +00:00
Virgil
7a034ccbe8 feat(agentic): expose setup action surface
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 06:39:02 +00:00
Virgil
613e1fc58e refactor(agentic): add namespaced action aliases
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 06:29:46 +00:00
Virgil
f6e1e64a0c feat(agentic): add namespaced template action aliases
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 05:07:54 +00:00
Virgil
c32b4de28e feat(agentic): expose generate action alias
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 05:03:08 +00:00
Virgil
d5fb2dc50b feat(agentic): add missing issue comment alias
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 04:23:14 +00:00
Virgil
f71066197d feat(agentic): schedule pr management loop
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 03:46:09 +00:00
Virgil
f198db7c68 feat(agentic): expose dispatch control actions
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 01:47:17 +00:00
Virgil
31aca2b66f fix(agentic): mark handoff sessions as handed_off
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-02 00:33:10 +00:00
Virgil
0cb648a117 feat(agentic): expose PR tools over MCP
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 23:34:05 +00:00
Virgil
43e2a14b82 feat(agentic): add completion journal commit stage
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 22:07:42 +00:00
Virgil
452c4a27c7 feat(agentic): expose prompt snapshot over MCP
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:57:55 +00:00
Virgil
bbb651797a feat(agentic): add session complete alias
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:50:36 +00:00
Virgil
43e2efe7cd feat(agentic): add prompt snapshot lookup
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:20:44 +00:00
Virgil
b0662c282b feat(agentic): add direct workspace messaging
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 21:04:39 +00:00
Virgil
a84a610ae2 feat(agentic): add synchronous dispatch surface
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:34:04 +00:00
Virgil
dfd1640d37 feat(agentic): expose completion pipeline as MCP tool
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 20:22:00 +00:00
Virgil
f4736bf759 feat(agentic): persist prompt snapshots
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 18:28:42 +00:00
Virgil
238be05fa8 feat(agentic): add issue report action
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 18:00:50 +00:00
Virgil
1cc318e2e8 feat(agentic): persist runtime backoff state
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 17:54:26 +00:00
Virgil
dfaf14f061 feat(agentic): add issue assignment action
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:50:26 +00:00
Virgil
ae910099c8 feat(agentic): add issue action aliases
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:43:47 +00:00
Virgil
4ff21338ee feat(agentic): expose PR close as MCP tool
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:38:21 +00:00
Virgil
7dde6b7769 feat(agentic): make plan delete a hard delete
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:14:16 +00:00
Virgil
ab0460da61 feat(agentic): add SetCore wiring
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 16:09:04 +00:00
Virgil
3c2ab16afb feat(agentic): add plan from issue command
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 15:42:26 +00:00
Virgil
28fbe8b988 feat(agentic): add SEO schema generation
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-01 15:34:37 +00:00