merge: isolate concurrent OpenCode chat runs

This commit is contained in:
2026-08-17 22:28:19 +08:00
34 changed files with 5159 additions and 434 deletions

View File

@@ -4,6 +4,7 @@ This file is the integrated default-branch snapshot. Feature tasks record progre
## Integrated Through
- `6504073`: AI Programming now isolates prompt lifecycle, loading and errors by OpenCode Session. Main serializes only runtime/configuration acceptance, verifies project Agent content against an owned fresh runtime generation before execution, and returns typed terminal pending responses without automatically restarting, reloading or disposing the shared runtime. A run that receives no explicit busy/assistant/terminal acknowledgement within 10 seconds ends only that Session and is never replayed automatically. The application-side isolation is verified; real bundled OpenCode/provider two-Session execution concurrency is not claimed.
- Project-cover source commit `145a6ce571d646325092d1e722282babea503954` from feature task `20260817-project-cover-upload-a6a98e56`, integrated by task `20260813-sync-push-main-9c2f71`. First submission now requires a bounded PNG/JPEG/WebP cover, shows preview/file/reselect feedback, and sends metadata plus cover through Main-owned `POST /api/projects/with-cover`; conflicts stop before version upload and existing draft/published projects remain version-only. The matching Works Square server source is `407c883` (local merge `0cedfc4`). No client package, production deployment, or real-account smoke occurred.
- `3b37ac3` / `55e61b7`: macOS Robot hotspot discovery performs one bounded worker-thread rescan after an empty or SSID-redacted CoreWLAN result; persistent SSID redaction maps to the existing permission error instead of a misleading empty-device state, while firmware and the open `Xiaozhi-*` contract remain unchanged.
- `f5d47c8` / `b6148a5`: AI Programming voice capture is available after an Agent is selected but before the lazy first OpenCode session exists; transcription fills the composer draft without creating an empty session, while runtime, loading, transcribing, busy, and recording guards remain unchanged.
@@ -42,7 +43,7 @@ Makelore 在会话恢复、登录和刷新后由 Electron Main 请求 Works `/ap
AI 学习现在是已启用顶层模块。Renderer 浏览 Works 课程、提交单课生成需求、显示任务进度并打开已安装课程;材料上传经 Main IPC 严格投影,需求最多 4,000 字,文件最多 5 个、单个 50 MiB、总计 150 MiB。Main 持有 Works Token、生成/课程下载/Agent/ASR/课堂 runtime 访问和按认证身份派生的不透明账号分区;账号切换、注销或 epoch 变化会隐藏旧本地课程、关闭旧 player server 并丢弃迟到结果。课程归档最大 512 MiB,只允许同 Works origin、最多 5 跳且不携带资源 Bearer 的下载重定向,按服务端声明大小与 SHA-256 校验后原子安装并在播放前再次校验。安装期和 player server 只允许 MIME/扩展匹配的被动图片、音视频和字体;同源 HTML/SVG/XML/脚本/PDF 被拒绝,运行时响应带 nosniff/sandbox CSP/CORP/no-store。只有显式 `readClassroom` 会注册课程;Agent/runtime 先验证调用前既存 active registration,再用无副作用 resolver 核对本地 aggregate/module,不能靠自身请求注册。HTTP URL/cookie 由短效 nonce 保护;iframe bridge 校验精确 source/origin,只允许初始 player 文档,二次导航后永久关闭。课程 aggregate `contentHash` 是云端权益/进度身份,模块 hash 只作为受控上下文。打包必须提供由固定清单与 SHA-256 验证的 OpenMAIC production Stage 产物;当前客户端自动化不等同于真实 Works 课程服务、生产播放器产物或签名安装包验收。
AI 编程首次发送在新建 OpenCode session 已知为空时不再等待冗余历史读取,prompt 可直接进入 Host API;普通历史会话仍刷新消息。Main AI proxy 只把明确的上游分组饱和投影为当前 OpenCode 的终止状态,配额耗尽保持独立终止态,通用限速继续保留 `429`。上下文压缩以每个 Session 的持久时间线事件呈现:自动与手动压缩使用不同文案,运行态原位弱化显示,完成后静态保留并可从历史恢复;`session.compacted` 只完成对应事件,只有真实 idle 才结束 run 和释放排队消息。
AI 编程首次发送在新建 OpenCode session 已知为空时不再等待冗余历史读取,prompt 可直接进入 Host API;普通历史会话仍刷新消息。每个 Session 独立持有 run、loading、error 与内部队列;一个 Session 的回复或终止不会锁住、改写或重放另一个 Session。Host 接受或用户消息落库不算启动确认,只有明确 busy/retry、assistant、question、permission 或 typed terminal event 才确认/终结启动;独立的 10 秒 watchdog 到期时仅以 `SESSION_START_UNCONFIRMED` 终止该 Session。Main 以 runtime generation provenance、Agent 内容 fingerprint 和 live registry id 共同验证项目 Agent,provider/runtime 或 Agent 未应用时在执行前返回 typed `409` 且 `promptSent:false`。普通 message、command、summarize 和后台 provider sync 不自动重启、reload 或 dispose 共享 runtime;只有显式用户 apply/lifecycle 操作可以推进运行时刷新。Main AI proxy 只把明确的上游分组饱和投影为当前 OpenCode 的终止状态,配额耗尽保持独立终止态,通用限速继续保留 `429`。上下文压缩以每个 Session 的持久时间线事件呈现:自动与手动压缩使用不同文案,运行态原位弱化显示,完成后静态保留并可从历史恢复;`session.compacted` 只完成对应事件,只有真实 idle 才结束 run 和释放排队消息。
Updater 仍由 Electron Main 选择目标 feed、记录原始诊断并保持失败语义。正式稳定源缺少对应平台 manifest 时,设置页只显示一条简洁中文提示并允许重试,不把缺包误报为已是最新版,也不向普通界面暴露堆栈、URL、路径或错误码;签名产物发布和真实升级安装仍属于外部 Release Gate。
@@ -50,6 +51,7 @@ Robot 绑定设备默认先显示“引导配网 / 已有激活码”路径选
## Recently Completed
- 2026-08-17: Integrated application-side multi-Session isolation for AI Programming. Session A may remain busy while Session B is independently accepted or terminally rejected; errors, startup deadlines and uncertain-failure cleanup stay Session-scoped. Main now fail-closes stale Agent/provider runtime state before execution, applies bounded manager/project FIFO acceptance with revocable timeouts, and never refreshes the shared runtime automatically from ordinary execution paths. Full unit, typecheck, lint, build, focused Electron E2E and independent Sol review passed; a real paid-provider/bundled-runtime concurrency smoke remains pending.
- 2026-08-17: Replaced the temporary coverless-first-create fallback with a required PNG/JPEG/WebP picker, preview, file name, reselect action, Renderer/Main signature and size validation, and one Main-owned multipart metadata-plus-cover create request. Create conflicts fail before version upload; existing project metadata and covers remain unchanged.
- 2026-08-17: Corrected macOS Robot hotspot discovery after a system-visible `Xiaozhi-*` report. CoreWLAN now gets one bounded retry when its first result is empty or all SSIDs are unavailable; a persistent non-empty redacted result becomes the existing safe permission state. Open-only filtering, firmware, Host/Renderer contracts, exact-current-SSID verification, and the system-Wi-Fi fallback are unchanged; signed-package physical smoke remains pending.
- 2026-08-17: Created merge commit `4013edc` for the reviewed per-user module-entry policy source tip `3b799af`. Main exposes only four booleans from `/api/auth/me`; missing fields remain enabled, `design` maps to `painting`, disabled root/deep/alias routes stop before module initialization, Code provider startup waits for policy hydration, terminal `401` clears both session layers, and global settings remains reachable.
@@ -109,6 +111,8 @@ Robot 绑定设备默认先显示“引导配网 / 已有激活码”路径选
- 客户端对最终构建字节的 loopback 检查没有可信 receipt,且不复刻生产 opaque-origin;服务端必须独立重算 source/built/contract、校验不可变 Release,人工审核仍不可绕过。如未来需要不可绕过的 runtime gate,必须引入可信 verifier 并绑定精确构建产物。
- AI proxy 的明确饱和 `429 → 400` 是与当前 OpenCode 重试契约匹配的内部投影;升级 OpenCode 或上游饱和错误文案变化时必须复核。不得把通用 `429` 或仅含 `rate_limit_exceeded` 的响应误分类为终止饱和。
- AI 编程压缩事件必须按 Session、run token、runtime generation 与 native Part/event identity 关联;`session.compacted` 不等于 `session.idle`,历史 hydration 不得把 completed 降回 running,失败或中止必须清理本 run 的未完成事件。
- AI 编程多 Session 隔离只证明应用提交、状态、错误、超时和队列互不污染,不证明 bundled OpenCode 或真实 provider 会并行执行两个模型 turn。任何产品或性能结论都必须保留上游可能串行、限流或拒绝的边界。
- 项目 Agent 与 provider/runtime freshness 必须在 Main 的 bounded acceptance 临界区内验证。普通 message、command、summarize 和后台同步不得自动重启、reload 或 dispose 共享 runtime;同 id 不能证明同内容已经加载,attached/unknown runtime generation 必须 fail closed。
- AI 绘画单图选择器仍精确匹配 quick reply `从作品列表选择图片`,用途再从当前 Brief medium 推断;本地化或协议文案变化可能破坏入口。扩展更多素材输入前应升级为结构化 action/purpose。
- Updater 源码错误提示不能代替发布正式签名产物;稳定 feed 缺 manifest 必须保持失败,Renderer 不得展示原始堆栈、URL、路径或错误码。升级链只有在旧版本完成发现、下载、重启和安装 smoke 后才可视为生产就绪。

View File

@@ -12,6 +12,7 @@
## Scope
- On 2026-08-17, resume the existing Integration owner after the user's explicit takeover authorization to merge reviewed AI Programming multi-Session/runtime-readiness source `6504073` into local `main`, preserve existing project-cover work, promote only the implemented application-isolation and no-automatic-runtime-refresh facts, run merged-tree verification and independent review, and keep remote push outside this resumption.
- On 2026-08-17, resume the existing Integration owner to merge the reviewed first-submission project-cover source from task `20260817-project-cover-upload-a6a98e56` into local `main` after its matching server contract is integrated, replace only the obsolete coverless-first-create limitation, preserve existing-project version-only behavior and Main-owned publishing boundaries, and keep remote push outside this resumption.
- On 2026-08-17, resume the existing Integration owner to merge reviewed macOS Robot hotspot scan source `55e61b7` into local `main`, preserve the firmware/open-SSID/Main-owned boundaries, retain signed-package physical smoke as a release gate, and keep remote push outside this resumption.
- On 2026-08-17, resume the existing Integration owner at the user's request to merge reviewed AI Programming fresh-Agent voice-input source `b6148a5` into local `main`, preserve lazy first-session creation and existing voice guards, run merged-tree verification and independent review, and keep remote push outside this resumption.
@@ -59,6 +60,7 @@
- The 2026-08-17 takeover confirmation authorizes continuing this existing Integration owner while preserving its uncommitted task history. For module access, source-task records remain read-only; the policy is a client entry/initialization gate rather than API authorization, and release acceptance requires the matching Works migration/API, a newly packaged client, and real-account four-module smoke.
- The fresh-Agent voice-input request authorizes a local `main` merge only. It does not authorize remote push, Canvas voice enablement, eager OpenCode runtime/session creation, or changes to the existing Renderer -> Host API -> Electron Main -> Works Square speech boundary.
- The project-cover request authorizes a local `main` merge only. It does not authorize remote push, client packaging, production deployment, metadata editing for existing projects, or weakening the Renderer -> Host API -> Electron Main ownership boundary.
- The multi-Session request authorizes local `main` integration of application-side Session isolation and runtime/Agent acceptance. It does not authorize a remote push, paid-provider traffic, a claim that bundled OpenCode/provider executes two model turns simultaneously, or automatic shared-runtime restart/reload/dispose. Source task records remain on feature history only.
## Project Context Loaded
@@ -106,6 +108,14 @@ Relevant understanding:
Gate result:
- Passed.
### 2026-08-17 AI Programming Multi-Session Runtime Integration Resume
- Reused the existing Integration owner after the user explicitly authorized adoption of its existing changes. Registry status confirms task `20260813-sync-push-main-9c2f71`, mode `integration`, branch `main`, worktree `D:\Datas\OthersProjects\makelore`, and the repository integration lock.
- Verified feature task `20260817-multichat-runtime-fix-f3a91c` is `ready_for_integration`, its worktree is clean, source commit `65040730ec229436b27e0e1a34ca16599b534996` is present, and its seventh independent Sol review returned Standards/Spec `PASS` after full unit, typecheck, lint, build and focused Electron E2E validation.
- Read the source outcome, follow-ups and promotion candidate against current AI Programming first-send, compaction and Main-owned runtime boundaries. No accepted ADR or peer source requires a reply-duration global lock, automatic runtime disposal, or same-id Agent freshness; the source strengthens existing Session isolation without changing product direction.
- Started a normal `--no-ff --no-commit` merge of `6504073` onto clean local `main` `b734867`; Git reported no textual conflicts. The source task record remains reachable on its source branch and is excluded from the integrated `main` tree.
- Gate result: Passed for local no-ff merge, semantic canonical promotion, proportionate merged-tree verification and independent final review. Remote push and real provider/runtime concurrency smoke remain outside this resumption.
### 2026-08-17 Fresh-Agent Voice Input Integration Resume
- Reused the existing Integration owner because it still exclusively owns clean local `main` at `9fd9a7761d3872f25e853ac1b059e55251c6ae8f`; `task_context.py touch` refreshed the reservation and registry doctor passed.
@@ -216,6 +226,13 @@ Gate result:
## Plan
### 2026-08-17 AI Programming Multi-Session Runtime Integration Plan
1. Merge reviewed source commit `6504073` into local `main` with a normal no-ff merge while preserving the current project-cover history and excluding the source-owned task record.
2. Promote the implemented per-Session startup/terminalization, Main runtime/Agent readiness, no-auto-replay and no-automatic-shared-runtime-refresh boundaries into current state, architecture, evidence and commitments without claiming upstream provider concurrency.
3. Run the focused AI Programming/Main/Renderer regression selection, full unit suite, typecheck, lint, Vite production build, focused Electron E2E, project-document gates and topology/whitespace checks.
4. Obtain an independent read-only Sol PASS/FAIL review, commit only after PASS, verify exact merge parents and keep remote push outside this request.
### 2026-08-17 macOS Robot Hotspot Scan Integration Plan
1. Merge reviewed source `55e61b7` into local `main` with a normal no-ff merge, preserving source history while excluding the source-owned task record from the final tree.
@@ -309,6 +326,10 @@ Gate result:
## Outcome
- Prepared a normal no-ff merge of reviewed AI Programming source `65040730ec229436b27e0e1a34ca16599b534996` onto local `main` `b734867`; Git reported no textual conflicts, current project-cover behavior remains present, and the source task record remains only on feature history.
- Integrated application-side per-Session run/error/queue isolation, an independent hard 10-second startup acknowledgement deadline, typed pre-send runtime/Agent pending responses, generation/fingerprint Agent readiness, bounded manager/project FIFO acceptance and timeout lease revocation. Ordinary message/command/summarize/background sync does not automatically restart, reload or dispose the shared runtime.
- Promoted the source architecture candidate into current state, data flow and module ownership, and recorded verified evidence plus the still-pending real bundled OpenCode/provider two-Session smoke. No claim of upstream simultaneous model execution was added.
- Prepared a normal no-ff merge of project-cover source `145a6ce571d646325092d1e722282babea503954` onto local `main` `da376b0bf37cdd0b5eabe7efc9f1141ae5645411` with no textual conflicts; the source feature task record remains only on the source branch.
- Reconciled the obsolete coverless-first-create rule into required first-cover atomic submission while retaining existing-project version-only behavior and the unfulfilled conditional metadata-editing commitment.
- Created normal no-ff merge commit `a5f0cf7fc4d18ee1d46aef6c177ffb4433039a4a` with project-cover integration-plan commit `da376b0bf37cdd0b5eabe7efc9f1141ae5645411` as first parent and reviewed source `145a6ce571d646325092d1e722282babea503954` as second parent.
@@ -446,6 +467,14 @@ Gate result:
## Verification
- Source closeout before integration: Main focused 164/164, full unit 176 files / 2100 tests, typecheck, full lint with zero errors and seven pre-existing warnings, `build:vite`, focused Electron E2E 1/1, project-document gates and seventh independent Sol Standards/Spec review all passed.
- Multi-Session staged merged-tree high-risk selection: 13 files / 490 tests passed, including OpenCode routes/store/panel/run-machine/client/manager, provider routes/store/settings, project config/Agent readiness, Makelore background sync and login regression coverage.
- Multi-Session staged merged-tree full unit suite: 176 files / 2106 tests passed with four workers; the additional mainline project-cover regressions remain green.
- Multi-Session staged merged-tree `pnpm run typecheck` and `pnpm run lint:check` passed; lint reported zero errors and the same seven pre-existing warnings.
- Multi-Session staged merged-tree `pnpm run build:vite` passed for Renderer, Electron Main and Preload; only existing mixed-import and chunk-size warnings remain.
- Focused Electron E2E `tests/e2e/opencode-multichat-runtime.spec.ts` passed 1/1 through the built Main/Renderer Host stub, preserving Session A busy state while Session B terminates independently without retry.
- Independent final staged-merge Sol review returned Standards `PASS`, Spec `PASS`, overall `PASS`, with no blocking findings. It independently reran 13 files / 490 tests, confirmed exact `HEAD=b734867` / `MERGE_HEAD=6504073` topology, source-task-record exclusion, no unmerged or unstaged changes, preserved project-cover behavior, canonical document consistency, and the explicit non-claim for real provider concurrency.
- Project-cover source verification: 3 focused Vitest files / 76 tests, typecheck, scoped ESLint, Vite production build, focused Electron E2E 1/1, and cross-repository Sol review all passed.
- Project-cover merged tree: 3 focused Vitest files / 76 tests, `tsc --noEmit`, scoped ESLint, Renderer/Main/Preload Vite production build, and focused Electron E2E 1/1 all passed; build emitted only the existing dynamic-import and chunk-size warnings.
- `check_project_docs.py`, task-aware `check_doc_drift.py`, and `git diff --cached --check` passed for the prepared project-cover merge.
@@ -596,6 +625,9 @@ Gate result:
## Follow-ups
- Before claiming true simultaneous model execution, run the opt-in real bundled OpenCode two-Session smoke with an explicitly configured test provider. Current automation proves application isolation, bounded failure and no replay, not provider/runtime concurrency.
- If runtime Agent edits must apply immediately, first add an upstream directory-scoped invalidation API or authoritative whole-instance quiescence oracle. Until then, retain manual restart after active replies finish and do not infer dispose/reload safety from `/session/status`.
- Before releasing the per-user module-entry policy, deploy the Works `module_access` migration and `/api/auth/me` contract, build and install a new Makelore package, then use a real account to disable Code, Canvas, Learning and Robot one at a time and smoke chooser/root/deep/alias behavior, global settings, terminal `401`, and independent server-side API authorization.
- Before releasing Learning, run a real Works account through catalog, generation/material/cancel-resume, bounded download, offline multi-module playback, progress, Agent, ASR and PBL/scoring using the exact production Stage artifact. Validate packaged loopback cookie/nonce behavior on Windows and a signed macOS build; current automation is not that acceptance.
- First-project cover upload is implemented by client source `145a6ce` and server source `407c883` / local merge `0cedfc4`; before release, deploy the server, package the client, and verify a real account/object-store flow including create conflict, cover failure, and version-upload blocking. Editing metadata on an existing draft/published project still requires a server-owned revision/ETag plus draft-only conditional write; until then existing projects remain version-only.
@@ -622,6 +654,8 @@ Gate result:
## Promotion Candidates
- The `6504073` candidate is promoted into current state, module map, data flow, evidence and commitments: per-Session run/error/startup state, hard 10-second explicit startup acknowledgement, no uncertain replay, Main-owned generation/fingerprint Agent readiness, typed pre-send runtime/config pending, bounded manager/project acceptance and no ordinary-path shared-runtime restart/reload/dispose. Real provider concurrency and immediate Agent hot reload remain explicit pending validations rather than integrated claims.
- The `3b799af` module-access candidate is promoted into current state, architecture/data flow, business rules, success criteria, evidence and commitments: Electron Main projects only four booleans from `/api/auth/me`; missing values are enabled, server `design` maps to client `painting`, disabled card/root/deep/alias entry stops before layout/module initialization, Code provider waits for policy hydration, terminal `401` clears both session layers, and `/settings` remains global. This is a client entry policy, not API authorization; deployment/package/real-account validation remains pending.
- Remote `01bee31` facts and the reviewed merge hardening were promoted into README, AGENTS, success criteria, current state, architecture/data flow, business rules, glossary, evidence and commitments: Learning is enabled but remains Main-owned, account-partitioned, bounded, artifact-verified and pending real Works/signed-package acceptance; `game-engine` is removed and planning files belong in the project root.
- Remote `26b52d7` facts were promoted into current state, architecture, domain rules, glossary, evidence, README, and release commitments: Prompt Museum remains read-only/server-driven, Quote pricing is service-owned, Canvas deletion is an explicit Workspace mutation, development is cloud-default, UI language is Chinese-only, and `game-engine` is an optional bundled Skill. Production Museum content and real-account billing/deletion acceptance remain pending commitments rather than completed evidence.