* fix(copy): six places the UI told the operator something untrue Each was re-confirmed against current main before touching it — several were found two days and ~40 PRs ago and could have been fixed or moved since. - /download understated every artifact by 25-35%: "~80 MB" for a .deb that is 100 MB, "~98" for a 124 MB .dmg, "~81" for a 109 MB .exe. The numbers are retyped by hand each release and had drifted silently. Dropped rather than corrected. Re-typing them fixes today and guarantees they are wrong again at the next release — the same rot as the 0.8.19 pin in desktop/README and the Whisper model sizes. A live check would need network in the unit suite, which is offline-only here (desktop-release-drift shells out to git, not HTTP), and a network dependency inside verify is its own hazard. The notes keep what is stable: package manager, Apple Silicon, x64. - "Launch Claude Code" launched whatever agent was selected. BootstrapModal POSTs `agent: agentId` (claude/codex/gemini/grok/cursor), so choosing Codex ran Codex under a button naming Claude. DoneStep now takes the real label. - "Settings → Agent tokens" linked to /settings with no fragment and landed on Profile. SettingsTabs names #agent as the intended anchor and its own comment calls the fragment-less case "a silent dead-end in the new-user funnel". - Appearance claimed another device "starts on Auto again". ThemeProvider sets defaultTheme="dark". - Privacy omitted Crew from the PIN-gated list — it lives under (private)/ and every /api/crew/* route calls requirePrivateApiAccess — and described the TTL as "30 minutes of activity" when private-zone-token stamps it once at verify. - ecosystem.studioUrl pointed at /studio, which 404s, and loki-core.ts injects that string into Loki's grounding preface: the assistant was telling operators to go to a dead page. /create is the verified surface. Also: profileUrl pointed at /profile/mao-nakamoto — the retired pseudonym, in a URL, rendered on the PUBLIC /support page under a card titled "Cato", with a config key literally named `mao`. The key is now `cato`. The URL is NOT a guess: every /profile/* path on orangecat.ch redirects to login, and OrangeCat's own source carries no owner-username constant, so the real handle is unverifiable from here. It points at the verified OrangeCat home with a comment to repoint it once the handle is known — swapping a wrong name for a broken link would not be an improvement. Worth noting: test-no-retired-name.sh matches the spaced form, so the slug `mao-nakamoto` passed every previous sweep. Widening it is a separate change. verify: exit 0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs: five documents that would send an agent the wrong way Docs an agent reads before acting, each contradicting the code it describes. Every claim re-checked against current main first. connection-presence.md — the dangerous one. Step 6 "Cutover" instructs: "drop the heartbeat setInterval in the runner and the heartbeat branch in the web online check. Presence is purely connection-based." The shipped rule is the OPPOSITE and deliberately so. applyHeartbeatExpiry() in src/lib/builder-presence.ts requires connection AND a fresh heartbeat, because a connection lost to a DB blip — or a half-open socket the bridge never sees close — pins connected=true until the bridge restarts, and Control then asserted "this computer online" for a laptop shut for days. An agent executing step 6 would delete the expiry and bring that back. Struck through rather than deleted, with the reasoning, so the decision stays legible: the plan was sound, reality disagreed, the code won. The same table claimed the heartbeat pusher timer was "removed"; desktop/src/main/pusher.ts:369 still runs it. self-improvement-plan.md — its load-bearing premise is false. "prompt_history has no runId" and "Phase 0 (the runId FK) is DEFERRED … add the column when Phase 3 revives". The column and its index shipped: src/db/schema/prompt-history.ts:34,42. An agent picking this up would re-add an existing column. Superseded note plus two strike-throughs. master-plan-2026-07.md and AUDIT_REPORT_2026-07-13.md — both still name Stripe as the revenue rail and file CONFIRMED-HIGH bugs against stripe/webhook routes. Stripe went in #508: no src/app/api/stripe/, no stripe dependency. Bannered rather than rewritten — a dated plan that was right when written is worth reading; what it needs is a header naming which premises died. debt-reduction-roadmap.md — linked from README as current, describes the retired beacon popup as live architecture across ~11 sections, and had 35 file links hardcoded as /home/g/dev/loki/... — absolute paths into one machine's home directory, broken for every other reader of a public repo. Bannered; all 35 rewritten repo-relative. branding-design.md — what an agent reads before touching UI, and four of its anchors pointed at things that do not exist: desktop/src/renderer/ (deleted in v0.7.4; HANDOFF.md says "DO NOT bring it back"), SidebarBrand.tsx, and the mark's SSOT, which moved to src/config/brand-mark.ts. Also "the 1845-line globals.css", which is 6073 — the count is dropped rather than corrected, because a number retyped into prose rots by definition. verify: exit 0. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
11 KiB
Loki Debt Reduction Roadmap
STATUS — partly superseded (added 2026-09-22). This roadmap is linked from the README as current, so read this first:
- The Beacon sections are obsolete. The beacon popup was retired on 2026-06-11 (
2391c6f7) and its remains were deleted in #804:scripts/beacon.py,POST /api/beaconand thebeacon_sessionstable are gone, and/beacon/live404s. Anything below that treats Beacon as live architecture — "stabilize Beacon as a client", "the always-on-top desktop overlay" — describes something that no longer exists. What replaced it is Fleet Runner'snotifyOnIdle+ autopilot dispatch.- Its file links were absolute paths into one machine's home directory and were broken for every other reader; they are now repo-relative.
The non-Beacon debt items have not been re-checked against current main.
Purpose
This document turns the current architectural concerns into an execution roadmap for reducing code debt and making Loki viable as a startup-grade product.
The standard is no longer "works for me locally." The standard is:
- understandable by a new engineer
- auditable in production
- portable across users and machines
- adaptable across agent vendors
- cheap to extend without multiplying hidden complexity
Debt Themes
The main debt is concentrated in four categories.
1. Split orchestration authority
The product loop is currently spread across:
- local hooks and
/tmpsignals - Beacon desktop UX
- Loki browser UX
- direct injection routes
- partial orchestration adapters
This creates duplicated behavior and weak ownership.
2. Claude-era semantics leaking into product logic
Examples:
claude-*sentinel compatibility paths- prompt-key compatibility mappings
- session handoff assumptions baked into route logic
These are acceptable as migration artifacts, not as architecture.
3. State assembled from multiple partial truths
Current state is inferred from:
/tmpfiles- process scanning
- session markdown files
- DB fallbacks
- latest orchestration run rows
That is survivable in migration, but expensive as a long-term model.
4. UI behavior duplicated across surfaces
The browser and Beacon both contain:
- prompt selection UX
- countdown behavior
- continue semantics
- state presentation logic
That should become one decision engine with multiple renderers.
Operating Rule
The target architecture is:
- local runtime detects
- adapters translate
- Loki decides
- UI surfaces render
Anything that does not fit that rule is debt.
Delete
These are the things to remove as independent concepts.
Delete independent prompt semantics outside Loki
Why:
- prompt meaning must have one SSOT
Targets:
- direct prompt semantics embedded in Beacon file-reading logic in scripts/beacon.py
- any remaining Claude-only prompt meaning outside src/lib/orchestration/intents.ts
Action:
- Beacon may render prompt choices, but must not define prompt meaning
Delete top-level route dependence on raw runtime semantics
Why:
- routes should not be the primary interpreter of local vendor artifacts
Targets:
- direct ready/closing/closed interpretation in src/app/api/control/route.ts
- direct prompt/run semantics in src/app/api/inject/route.ts
Action:
- move interpretation behind orchestration state services and adapter ingestion
Delete duplicated countdown authority
Why:
- only one place should decide auto-continue timing and default behavior
Targets:
- browser countdown in src/components/control/project-card-helpers.tsx
- Beacon countdown logic in scripts/beacon.py
Action:
- keep one policy engine; treat UI countdowns as renderers only
Merge
These concepts exist more than once and should be unified.
Merge prompt metadata and intent presentation
Current split:
- prompt config in src/lib/agent-config.ts
- orchestration intents in src/lib/orchestration/intents.ts
- control button labels/groups in src/config/control-intents.ts
- Beacon prompt metadata loading in scripts/beacon.py
Problem:
- prompt text, prompt identity, intent identity, and UI grouping are related but split
Merge target:
- one canonical intent registry
- one adapter rendering layer for agent-specific prompt text
- one presentation config for UI ordering and labels
Merge runtime state ingestion
Current split:
- fast-state reading in src/lib/control-fast-state.ts
- slower control aggregation in src/app/api/control/route.ts
- orchestration run persistence in src/db/queries/orchestration-runs.ts
Problem:
- multiple code paths interpret the same project lifecycle differently
Merge target:
- one runtime-ingestion module
- one derived-state module
- one API response assembler
Merge project identity handling
Current split:
- DB user projects
- projects conf parsing
- owned-PTY tab listing (
listOwnedTabs,src/lib/agent-execution/owned.ts)
Targets:
Merge target:
- project ID is canonical
- tab/session names are runtime bindings
Stabilize
These are worth preserving, but they need firmer boundaries.
Stabilize Beacon as a client, not a brain
Keep:
- the interruption UX
- always-on-top desktop overlay behavior
- fast decision surface
Do not keep:
- separate prompt authority
- separate orchestration semantics
- separate countdown decision logic
Target role:
- Beacon becomes a Loki-controlled desktop client
Stabilize adapter contracts
Keep building on:
- src/lib/orchestration/contract.ts
- src/lib/orchestration/adapters.ts
- src/lib/orchestration/runners/openclaw.ts
Needed:
- explicit event ingestion contract
- explicit state derivation contract
- explicit close/continue capabilities
Stabilize session handoff
Keep:
- the habit of forcing end-of-run summaries
Current locations:
Needed:
- one parser
- one writer contract
- structured summary artifact, optionally mirrored to markdown
Stabilize control-panel rendering
Keep:
- the project card structure
- the lifecycle banners
- the operator affordances
Needed:
- render derived orchestration state, not inferred adapter truth
Defer
These are useful, but should wait until the core architecture is cleaner.
Defer broad multi-agent generalization
Do not build a speculative framework for many future vendors yet.
Reason:
- Claude, Codex, and OpenClaw already provide enough concrete needs
Defer deep UI redesign
Do not spend cycles polishing visual redesigns until:
- orchestration truth is stable
- Beacon/browser duplication is resolved
- policy and event history exist
Defer advanced portfolio automation
Examples:
- autonomous project prioritization
- budget-aware runtime scheduling
- cross-project queue optimization
These are valuable later, but they sit above unresolved state and policy debt.
Ruthless Priorities
If time is limited, do these in order.
Priority 1: Unify orchestration authority
Implement:
- one state model
- one event model
- one policy engine
Files to center:
Priority 2: Introduce event log and derived state
Implement:
- orchestration events table
- ingestion from current
/tmpand session signals - state reducer
Result:
- raw runtime files become adapter inputs, not product truth
Priority 3: Collapse prompt and intent duplication
Implement:
- one intent registry
- one UI metadata layer
- one adapter rendering path
Result:
- Beacon and Loki render the same choices from the same source
Priority 4: Reframe Beacon
Implement:
- Beacon reads Loki-owned state/prompt/policy contract
- Beacon sends actions back through Loki
Result:
- keep the good UX without keeping split product logic
Priority 5: Remove route-level lifecycle interpretation
Implement:
- services for state derivation
- thinner API routes
Result:
- fewer bugs from inconsistent state assembly
30-Day Execution Plan
Week 1
- define canonical orchestration event types beyond run rows
- add DB schema for orchestration events
- define one project runtime binding model
Week 2
- build event-ingestion service for current local signals
- derive current control state from events plus live runtime facts
- refactor
/api/controlto consume derived state
Week 3
- unify prompt/intents/presentation registry
- refactor control UI to consume unified intent metadata
- make Beacon consume the same prompt metadata contract
Week 4
- move countdown/default-action policy into one backend-owned policy path
- make browser and Beacon render the same decision
- document remaining
dotfilesresponsibilities and remove semantic leakage
File-Level Guidance
Highest-risk files
- src/app/api/control/route.ts
- src/app/api/inject/route.ts
- src/lib/agent-config.ts
- src/lib/control-fast-state.ts
- scripts/beacon.py
Reason:
- these currently carry the most cross-boundary semantics
Current extraction status
Implemented:
dotfilesstop and notification hooks now delegate to scripts/agent-hook-bridge.sh- shared runtime hook utilities now live in scripts/agent-hook-lib.sh
dotfilesBeacon now delegates to scripts/beacon.py
Still a shim:
dotfilesremains the place where Claude registers hook entrypointslib.shindotfilesstill exists as compatibility/runtime residue- local hooks only signal lifecycle (start/stop/handoff); since 2026-09-11 all injection goes through runner-owned PTYs (node-pty) — there is no zellij path left for a hook to call, and no terminal adapter to make neutral
Good foundation files
- src/lib/orchestration/contract.ts
- src/lib/orchestration/intents.ts
- src/db/schema/orchestration-runs.ts
Reason:
- these are already moving toward neutral orchestration concepts
Decision Test
Before merging any change, ask:
- Does this add a second source of truth?
- Does this place product semantics in runtime glue?
- Does this make Beacon and Loki diverge more or less?
- Does this make routes thinner or fatter?
- Can a new engineer explain where the truth lives after this change?
If the answers move in the wrong direction, the change should not merge.