Commit Graph

336 Commits

Author SHA1 Message Date
alan f37f96265f android: retain aggregated file patches 2026-10-18 16:25:38 +01:00
alan 52110fdbed Merge branch 'main' into pill-run-decision 2026-10-18 15:53:29 +01:00
alan 72781260b1 test: preserve UI diff fixture recovery 2026-10-18 15:53:24 +01:00
alan 27108bcc0c Merge branch 'main' into manager-skill-bootstrap 2026-10-18 15:23:27 +01:00
alan cb29ba69f4 Merge branch 'main' into pill-run-decision 2026-10-18 15:23:16 +01:00
alan acadbaeb9c android: preserve run detail pill correction 2026-10-18 15:23:16 +01:00
alan 27a2e52376 Guard chat bootstrap transitions
Use conditional durable phase transitions and affected-row checks so only the request that reserves each phase can create or activate a manager chat session. Record duplicate ownership conflicts without repeating external work, and cover the reservation and restart state in pipeline and server tests.

Checked packaged templates and authoring skill references: the existing task commit already packages the dedicated manager skill and installer inventory; this transition-race fix requires no further template or reference update. Shared documentation remains untouched; the task note is docs/notes/manager-skill-bootstrap.md.
2026-10-18 15:23:07 +01:00
alan 18e7d073a6 Harden paged chat history loading
Close the per-thread history loading gate before launching requests, make live/history part reconciliation linear, and reject duplicate history envelope fields.

Complete task-owned history paging work remains preserved in the preceding recovery commit. Checked packaged templates and packaged authoring skill references: neither needs an update; docs/notes/large-chat-history.md records the stale shared documentation.
2026-10-18 15:21:09 +01:00
alan 5d76cf7885 Merge main into pill-run-decision for Android recovery 2026-10-18 15:06:52 +01:00
alan 94a22c46d7 android: preserve run summary title and changes work 2026-10-18 15:06:45 +01:00
alan c78c6ca4ff android: preserve run decision pill work 2026-10-18 15:05:30 +01:00
alan 1c89414896 Merge commit '4b66e608' into manager-skill-bootstrap
# Conflicts:
#	internal/opencode/chat_v2_test.go
2026-10-18 15:03:46 +01:00
alan ff1775e11f Merge branch 'main' into large-chat-history 2026-10-18 15:03:22 +01:00
alan ab9181eee9 Preserve manager skill bootstrap work 2026-10-18 15:03:22 +01:00
alan 998da0e7af WIP preserve large chat history recovery 2026-10-18 15:03:18 +01:00
alan 4b66e60829 Land guarded model delivery stabilization 2026-10-18 14:50:52 +01:00
alan 2cdb9a9e93 Stabilize guarded model delivery
Add validated OpenCode-only delivery capabilities, canonical linked-worktree access checks, isolated candidate verification, and guarded main settlement.

Wire the bounded reconnect-foreground controlled HTTP fixture through ordinary server construction so target verification obtains server-controlled provenance and rejects unknown or incompatible fixture evidence.

Checked packaged templates and packaged authoring skill references; no updates are needed because this draft-only infrastructure activates no definition. Recorded the stale reference and activation guidance in docs/notes/delivery-stabilization.md for the docs fold.
2026-10-18 14:50:18 +01:00
alan 66b5f60b28 Merge preserved connection reconnect baseline 2026-10-18 13:44:20 +01:00
alan 61ab1e65f9 Merge background shell visibility reconciliation 2026-10-18 12:55:07 +01:00
alan e9d902213e Preserve background shell visibility across readback races
Reconcile authoritative shell snapshots with bounded lifecycle journals so concurrent exits and creates cannot be overwritten, coalesce observation setup, and retain verified ownership across reconnects. Add deterministic reconciliation and cancellation regressions plus stable limited-visibility handling.\n\nChecked packaged templates and authoring skill references: none need updating. The task-owned docs note records the stale shared chat documentation for docs-fold; shared documentation was not edited.
2026-10-18 12:54:36 +01:00
alan f91145001a Merge main into connection reconnect delivery 2026-10-18 12:37:24 +01:00
alan 3c47b08d98 Restore connections on app foregrounding
Add a process-lifecycle foreground reconnector and pure recovery policy, wiring repository recovery through the validated saved endpoint. Include lifecycle-process and focused unit coverage while preserving explicit Disconnect and stale socket callback guards.

Checked packaged templates and packaged authoring skill references: neither documents Android connection lifecycle behavior, so neither needs updating. Shared android README changes are recorded in docs/notes/foreground-reconnect.md for the docs-fold writer.
2026-10-18 12:37:20 +01:00
alan 101e5e8dfe Merge stage-exclusive resource waiting 2026-10-18 12:31:49 +01:00
alan 0bc89547e1 Merge main into stage-exclusive resource waiting 2026-10-18 12:30:35 +01:00
alan 9130ae8c7a Add stage-exclusive resource waiting
Add durable FIFO capacity-one resource leases for executable stages, including cleanup-confirmed release, conservative restart quarantine, queue state events, and CLI/TUI/Android waiting presentation. Add scheduler, cleanup, protocol, client, and Android coverage plus a proposed Android v3 resource draft.

Checked packaged templates and authoring skill references: neither needs updating in this item. The per-item docs note records the shared documentation that docs-fold must update; no shared README or packaged reference was edited.
2026-10-18 12:30:30 +01:00
alan c72193a641 Merge automatic connection recovery safeguards 2026-10-18 12:28:03 +01:00
alan e8fdc87170 Merge main into connection recovery 2026-10-18 12:27:32 +01:00
alan 269a8d65bb Guard socket recovery from stale callbacks
Serialize socket replacement and callbacks so a superseded socket cannot clear or regress the active connection, and make reconnect backoff safe after a successful open. Add focused recovery regression coverage.\n\nChecked packaged templates and packaged authoring skill references; neither needs updating for this Android transport-only change.
2026-10-18 12:27:24 +01:00
alan 88595ebd55 Land scoped stage artifact access 2026-10-18 12:03:02 +01:00
alan 31aec05f99 Scope stage artifact access by run visit
Derive validated same-run visit artifact capabilities in the runner and pass them to OpenCode and Pi clients. Permit supported file tools to read completed prior visits and write only the current visit, preserving workspace, secret, database, and shell restrictions.\n\nChecked packaged templates and authoring skill references: neither needs updating in this item; docs/notes/scoped-artifact-access.md records the shared documentation staleness for the docs-fold writer.
2026-10-18 12:02:37 +01:00
alan dbff7f9a47 Merge stage deadline diagnostics distinguishing active overruns from transport failures 2026-10-18 11:17:09 +01:00
alan 31d8f4a6d5 Distinguish active stage deadlines from harness transport failures
Identify configured attempt expiry during V2 active-session idle waits and retain bounded phase, timeout and session diagnostics without claiming a lost response. Preserve genuine operation failures, error identities, redaction, cleanup and admitted-work replay protections. Add stage regressions and scratch-server CLI/websocket retention coverage.

Checked packaged templates in examples and the pipeline template generator: none needs updating because timeout configuration and contracts are unchanged. Checked packaged authoring skill references: debugging.md needs a STAGE DEADLINE playbook and clarified transport guidance. Recorded that stale shared documentation in docs/notes/stage-timeout-diagnostics.md for docs-fold; shared documentation was deliberately not edited.

Verification: go build ./...; go vet ./...; go test ./...; go test -count=1 ./internal/server ./internal/stage ./internal/pipeline ./internal/protocol; go test -count=1 -run TestStageDeadlineDiagnosticThroughCLIAndWebsocket -v ./internal/server; gofmt -l .; git diff --check. All passed. Live-provider behavior not tested; no deploy or deployed-service restart.
2026-10-18 11:17:01 +01:00
alan b93eee234c session export: write only session.html, retire the markdown export
Merge session-html-only: a stage's session is exported as one html file and the
markdown export is retired from the wire, the store, the server evidence and
every listing (app, TUI, web spike). The packaged authoring references and a
docs note travel with it.
2026-10-18 10:08:02 +01:00
alan 70529926cc Merge main into session-html-only: combine the html-only session export with chat-tool-group and chat-activity 2026-10-18 10:06:54 +01:00
alan 95362134aa session export: write only session.html, retire the markdown export
A stage's session was exported twice, as session.md and session.html, and both
files were presented. It is now one html file; the markdown export is retired.

- internal/stage/session_export.go: ExportSession renders and writes exactly one
  file, session.html, via writeSessionFile; renderSessionMarkdown and its helpers
  are gone; SessionExportResult carries HTML/HTMLBytes only. The source read, the
  8 MiB source / 2 MiB rendered bounds, the truncation banner, the
  never-overwrite rule and the honest empty-session handling are unchanged.
- internal/protocol/runs.go: SessionExport drops markdown/markdown_bytes (a
  record written before the change still decodes; unknown fields are ignored),
  and adds LegacySessionMarkdownArtifact with RunStep.PresentedArtifacts(), the
  one Go rule that hides the retired session.md from every artifact listing.
- internal/server/runner.go: evidence.Markdown/MarkdownBytes are no longer copied.
- internal/tui: the artifacts panel, the recorded count and the per-visit summary
  derive from PresentedArtifacts(), so the terminal never lists session.md.
- web/src/app.js: the spike's renderArtifacts applies the same filter.
- android: the Session section is the html export alone in a WebView — SessionView,
  the Markdown/HTML toggle and the session markdown path are removed;
  presentedArtifacts(step) filters the retired session.md out of the per-visit
  gallery, the run gallery and its count, the verdict/selection lists and the
  timeline indicator; data/protocol SessionExport drops the markdown fields.
- Tests pin the single html file, prove no session.md is written and that a
  pre-existing one is neither overwritten nor presented, and prove a legacy
  export record still loads and its session.md is hidden.

The legacy session.md of an older run stays on disk (dated evidence); it is only
no longer produced and no longer presented.

Checks (macOS, Go 1.24, Android Gradle 8.11.1, 18 Oct 2026): gofmt -l . prints
nothing; go build ./... && go vet ./... clean; go test ./internal/... ./cmd/...
-> 19 packages ok, 0 failures; node --check web/src/app.js ok and node --test
web/test -> 20/20; gradle --offline --no-daemon :app:assembleDebug
:app:testDebugUnitTest -> BUILD SUCCESSFUL.

Packaged references checked: internal/author/skill/references/delivery.md and
operations.md both described the session.md+session.html pair, so both are
updated here to describe the single session.html export and the retired, hidden
session.md. README.md and internal/author/skill/SKILL.md carry no session.md
reference and install.go's managed inventory is unchanged (no reference added or
removed). docs/notes/session-html-only.md records the remaining stale shared
documentation (docs/stage-artifacts.md, docs/app-integration-verification.md) for
the docs-fold writer; shared docs are not edited by this item.
2026-10-18 10:06:49 +01:00
alan 51a2ba43c4 Merge chat-tool-group: one tool-call summary chip per turn, opening the call list 2026-10-18 09:59:25 +01:00
alan 194540b768 Merge main into chat-tool-group: combine the tool-call summary chip with the chat-activity feature
Brings the tool-call summary chip (7fbbd95) together with main's chat in-flight
state and background-process surface (7b0dc94). Both edit ChatFormat.kt and
ChatTranscript.kt; the merge combined them cleanly (no conflict markers) — the
chip's live gating (live = streaming, toolStartedAt) now sits alongside main's
turn-phase labels and background-process bar, and both sides' pure helpers
coexist.

Re-ran the repository checks on the resolved tree: gradle --offline --no-daemon
:app:testDebugUnitTest :app:assembleDebug => BUILD SUCCESSFUL; JUnit XML
aggregate classes=70 tests=680 failures=0 errors=0 skipped=0.
2026-10-18 09:59:13 +01:00
alan 7fbbd95374 chat: one tool-call summary chip per turn, opening the call list
The chat transcript no longer renders a chip per tool call: `ToolCalls`
(`android/.../ui/chat/ChatToolCalls.kt`) now draws a single summary chip
reading `N tools called` (`1 tool called` for one) as the turn's only
tool-call surface. While the turn streams the chip shows the call count
growing and the existing spinner while any call is in flight, plus the
existing `· long` mark for a running call past `TOOL_LONG_RUNNING_MILLIS`;
both are gated on the turn still streaming (`live = streaming` in
`AgentTurnItem`), so a settled chip never spins or fakes a long mark.

Tapping the chip opens the existing `ToolPanel` as a popup listing every
call of the turn, in the order the agent made them: one independently
collapsible row per call naming it, showing its one-line detail, its
`+N -M` edit stat and its duration, expanding in place to the
pretty-printed INPUT, the synthesised edit diff, then the ERROR block for
a failed call or the OUTPUT (`(no output)` when empty). The list is
bounded by the new `TOOL_PANEL_MAX_HEIGHT_DP` (`Dimens.kt`, purpose-named)
and scrolls inside the panel, so many calls never grow the popup past the
window nor re-flow the transcript. The chip announces the count ("N tool
calls, expand for details") through the app's accessibility treatment.

Pure logic lives in `ChatFormat.kt` (`toolCallsLabel`,
`toolCallsAnnouncement`, `toolCallCount`, `toolsRunning`, `toolCallRow`)
with unit cases added to the existing `ChatFormatTest`; no raw dimension
was introduced, so `DimensTest` is unchanged.

Checked for staleness: the packaged authoring skill references
(`internal/author/skill/references/`) and the packaged templates carry no
Android-chat content, so neither needs updating — this change is
`android/`-only. The shared docs this change makes stale
(`android/README.md`'s "Tool-call chips and the expandable panel" section
and `docs/chat-verification.md`'s tool-chip row) are recorded in
`docs/notes/chat-tool-group.md` for the single `docs-fold` writer rather
than edited here.
2026-10-18 09:58:28 +01:00
alan 7b0dc94d37 Merge chat-activity: name the chat's in-flight state and surface background processes
Brings in the turn-phase label (Thinking…/Running a tool…/Waiting…) derived
purely from the stream, and end-to-end surfacing of the agent's shell commands
as a 'shell' chat_event kind with a retained, resumable background-process
indicator in the app.
2026-10-18 09:46:13 +01:00
alan 7d9490bba1 chat: name the in-flight state, and surface background processes
Two gaps in the chat's in-flight feedback.

The turn indicator no longer reads a bare `Working…` for every state. A new
pure derivation (TurnPhase/turnPhase/turnPhaseLabel in ui/chat/ChatFormat.kt)
labels the headline from evidence already on the wire: `Thinking…` while text
or reasoning deltas are still arriving (within TURN_THINKING_WINDOW_MILLIS),
`Running a tool…` while calls are in flight, `Waiting…` otherwise. No
percentage, ETA or invented progress.

The agent's shell commands are now surfaced end to end as their own frame kind,
so a background process (a dev server, a watching build) that outlives its tool
call is visible and clears when it exits.

Server:
- protocol/chat.go adds ChatEventShell, ChatShell (id, status, command, *int
  exit — a pointer so exit 0 is not "absent") and ChatEventFrame.shell.
- opencode/chat.go maps shell.created/shell.exited through a new exported
  ChatStreamState, attributing created via info.metadata.sessionID and exit via
  the ids the stream already surfaced; another session's or an unattributed
  shell is ignored, an id-less shell fails the stream. No cwd/file/credential is
  carried.
- server/chat_hub.go retains still-running shells (chatShellLimit plus the
  shared byte cap) and drops them on exit; chat_stream.go replays them on
  chat_subscribe, the shell half of the resume (a shell is not a turn, so the
  message snapshot cannot carry it).

App:
- data/protocol/Chat.kt adds ChatShell, ChatEventFrame.shell, EVENT_SHELL,
  SHELL_RUNNING/SHELL_EXITED.
- ui/chat/ChatStore.kt stamps ChatThread.lastDeltaAt on each delta (cleared when
  the turn settles) and keeps ChatThread.shells across a chat switch; a shell
  never marks the thread running. streamResumed drops shells so the subscribe
  replay re-syncs the still-running ones.
- ui/chat/ChatTranscript.kt: RunningIndicator prints the phase label; a new
  always-visible BackgroundProcessBar names each running shell.
- ui/chat/ChatConversationPane.kt shows the bar whenever a shell is running,
  whether or not a turn is.

Tests extend the server's event mapping (opencode/chat_v2_test.go,
server/chat_test.go) and the app's pure folds (new
ui/chat/ChatInFlightStateTest.kt, 15 tests), pinning the shell mapping, the
other-session rejection and the "background process outlives the turn" state.

Checked and intentionally unchanged:
- No packaged OpenCode skill reference documents either surface.
  internal/author/skill/references/operations.md describes the brokered chat_*
  protocol in prose without naming frame kinds or the app indicator, so it stays
  correct as-is; no reference was added, so install.go's managed inventory needs
  no change.
- This repository has no packaged templates directory.
- Shared docs are not edited here per the map: docs/notes/chat-shell-background
  -process.md records what is now stale in docs/cli.md and android/README.md for
  the docs-fold writer.

Verification (this session): gofmt -l clean, go build ./... and go vet ./... OK.
Android unit suite and the on-device capture were run in the preceding review
stage; see the note for the live-verification limitation.
2026-10-18 09:45:28 +01:00
alan 5a4cfc2e9c Merge run-title-framing: title the task, not the framing 2026-10-18 02:52:32 +01:00
alan 9565adc5f5 Merge main into run-title-framing: bring the run-title framing fix onto current main
Combines the summarise title-framing change (titleInstruction reword plus the
detachFramingEcho normalisation and its tests) with main's
docs/app-integration-verification.md addition. No conflicts: the two touched
disjoint files. `go build ./... && go vet ./...`, `gofmt -l internal/summarise/`
and `go test ./...` all pass after the merge.
2026-10-18 02:52:27 +01:00
alan c88bb27775 summarise: title the task, not the framing
Run titles were intermittently a sentence about the input rather than a
title for the task ("The untrusted data asks what 2+2 is…"), because the one
fixed instruction began "Summarise the untrusted data below…" and invited the
model to describe the data whenever the prompt read like an instruction or a
question.

- Rename the fixed prompt `instruction` → `titleInstruction` and reword it to
  ask unambiguously for a short title of the task ("Write a short title, a few
  words, for the task below. Reply with only the title…"), still followed by
  "The following is untrusted data:".
- Add a bounded, conservative `detachFramingEcho` normalisation applied in
  `Title` and `VerdictReason`: a leading clause that names the framing ("The
  untrusted data…", "This prompt…", "The user asks…") is stripped to its
  substantive remainder, and a line that is pure framing falls back to the
  prompt's first line (`Title`) or `NoSummary` (`VerdictReason`).
- Extend tests with the two reported echo shapes (instruction-style and
  question-style prompts) plus the injection-resistance case, which still
  passes: the prompt is appended verbatim once after the untrusted-data label
  and never replaces the instruction.

Trust boundary unchanged: source still labelled untrusted data, one tool-free
generation, hard timeout, never blocks or fails run creation; the title is
never empty.

Checks: `go build ./... && go vet ./...` clean, `gofmt -l internal/summarise/`
prints nothing, `go test ./...` ok.

Docs/templates check: no packaged template (`examples/*.md`) mentions title
generation, so none needs updating. The packaged authoring skill reference
`internal/author/skill/references/operations.md` (lines ~91-95) describes the
title as generated "from its prompt by the shared summariser" and is now stale
(it does not mention that the summariser is asked for a title of the task nor
the framing-echo normalisation); per the maintenance rules that shared document
is left to the single `docs-fold` writer and the staleness is recorded in
`docs/notes/run-title-framing-echo.md` instead. `README.md` and `docs/cli.md`
stay true, and no `internal/author/install.go` managed inventory entry changes.
2026-10-18 02:52:15 +01:00
alan e270dca077 Merge verify-gaps: record the four end-to-end verification gap checks against the deployed server 2026-10-18 02:47:20 +01:00
alan f43115ef0a Merge branch 'main' into verify-gaps 2026-10-18 02:46:48 +01:00
alan db313336b2 docs: record the four end-to-end verification gap checks (run 340)
Add a dated follow-up section to docs/app-integration-verification.md that
closes the four claims the first pass left unproven, each with the command or
capture that proved it against the deployed server (0d1ddc7) on the Pixel 9 Pro
XL 47241FDAS00DLK:

- Chat reply arrives: a throwaway session showed the assistant reply `Done.`
  rendering live, and the close-a-chat flow left the session `closed=true`
  server-side.
- Live pushed run events: disproven on this build. Runs 341/342/343 never
  appeared or advanced without a manual `Refresh runs`; only a local elapsed
  timer ticked. Consistent with the run-event push-hub defect fixed on main by
  cff6f4d, absent from the deployed 0d1ddc7. Recorded as a defect with exact
  reproduction, not an app defect.
- Disconnected state: the closed-port state and the restore to
  ws://10.0.0.75:8080/connect were both captured and Settings verified after.
- Wide windows: the covered-pane region is a constant 553 px at depths 1-3 and
  at 2000x2244 and 2076x2152; `wm size reset` left no override.

Checked for staleness from this change: it touches no source or resource file,
so no packaged template or packaged authoring skill reference
(internal/author/skill/references/) depends on it - none references this
document and none needs updating.

Report-only: the untracked scratch directory .gaps-tmp/ is deliberately left
uncommitted.
2026-10-18 02:46:46 +01:00
alan 7b8ba6745d Merge runevent-snapshot: write a subscribe snapshot in full before its ack
The run-event hub seeded a new subscription by sending every matching run
through the subscription's bounded 32-frame channel and only then acking. A
snapshot larger than that buffer tripped the drop-a-slow-subscriber policy on
the snapshot itself, so the remaining snapshot frames, the ack and every later
delta were lost while the websocket stayed open - the client could not tell it
had been unsubscribed. The snapshot and the ack now go straight out on the
subscribing connection, deltas emitted meanwhile are held and released in order
before the writer goroutine starts, and the drop policy now applies only to
deltas. Guarded by TestRunEventSubscribeSnapshotLargerThanBuffer.
2026-10-18 02:24:38 +01:00
alan cff6f4dfac server: write a subscribe snapshot in full before its ack
handleRunEvents seeded a new subscription by pushing every matching run
through the subscription channel (runEventSubscriberBuffer = 32) and only
then acked. sendMessage is a non-blocking send that closes the
subscription when the channel is full, so a snapshot larger than the
buffer dropped the subscription it was seeding: the remaining snapshot
frames hit the closed-done early return, the ack was never sent, and no
later delta could arrive. The connection stayed open, so the client could
not tell it was no longer subscribed. This was the app's only
subscription - AppViewModel subscribes with a blank workspace, matching
every run - so the app's live state froze.

The subscription now starts in a snapshot phase. The subscribing
connection itself writes the snapshot frames via writeSnapshot (one
direct write per frame, outside the bounded channel, so the drop policy
cannot fire on them) and the ack, and ready then moves any deltas held
meanwhile into the channel in order and starts the writer goroutine.
sendMessage holds deltas in a bounded pending queue while snapshotting
instead of closing, so the drop-a-slow-subscriber policy still applies,
but only to deltas. Ordering is snapshot, ack, then deltas; a write
failure or a listRuns error closes the subscription instead of leaving
it registered.

Numbers reported by this run: the probe against the deployed server saw
blank-scope frames=2 ack=0 (scoped frames=1 ack=0) because the snapshot
was ~252 frames into a 32-frame buffer; the scratch-server probe with the
fix saw 40 snapshot frames, ack=1 and a delta after a run transition.
Guarded now by TestRunEventSubscribeSnapshotLargerThanBuffer (seeds 40
finished runs, asserts every snapshot frame, the ack strictly after them,
and a terminal delta for a run started after subscribing), which fails
against the previous runevents.go.

Checked for staleness: the packaged templates and the packaged authoring
skill references internal/author/skill/references/ carry no run-event
subscription contract (their "snapshot" mentions are the workspace-change
snapshots in operations.md), and README carries none either, so none of
them needs updating. No UI surface changed.

Checks run before committing: gofmt -l . prints nothing, go build ./...,
go vet ./..., go test ./... (all packages ok), go test -race
./internal/server (ok).
2026-10-18 02:23:58 +01:00
alan 0d9430e4ad Merge docs-event-driven: rewrite the workflow docs for the agent-driven model (no driver, no poll loop, no lanes) 2026-10-18 01:51:09 +01:00
alan 93dc0103c3 Merge main into docs-event-driven: bring the agent-driven workflow docs onto current main 2026-10-18 01:50:59 +01:00