Repository navigation
fix: 接续 Node 桌面构建迁移并修复缓存与技能替换 - #114
Merged
freedomkk-qfeng merged 20 commits intoOct 10, 2026
Merged
Conversation
Add Node.js (.mjs) ports beside the existing PowerShell scripts so the Web assembly, desktop inputs, shell assembly and packaging can run without PowerShell. Shared helpers live in scripts/lib/. The .ps1 files and CI workflows are unchanged; shim conversion, test migration and the CI switch follow separately (see docs/SCRIPTS_MIGRATION.md). - scripts/local-desktop-pipeline.mjs: one-command local build, install and launch smoke (Windows x64, macOS arm64; Linux runs Web validation) - Release orchestrators accept --no-verify-snapshot for local working trees (recorded as sourceSnapshotVerified: false) and --runtime-source to reuse a verified DSH Runtime cache; defaults stay strict - dev-studio-web.mjs links the Studio profile in-process - source-receipt.json: review entries for the changed/new files Not yet validated end to end: the macOS run reached the Whisper model download; the Windows chain has not run on Windows.
assemble-macos.mjs copied only icon-blue/icon-red/dock-blue into the app payload. product.mjs resolves dock-red-1024.png at startup for the red Dock variant, so the installed app exited immediately with a missing asset error. - assemble-macos.mjs: copy all eight brand assets via the BRAND_ASSETS list, and assert that every file in brand/ is covered so a future asset cannot be dropped silently - assemble-macos.mjs: call build-dock-plugin.mjs after the plist edits and before signing; the Dock tile plugin was never compiled - assemble-macos.mjs: honour sourceAlpha (app name suffix, appId, disabled updates, and fail when Sparkle is enabled) - assemble-macos.mjs: skip the renderer step when the input is absent, matching the PowerShell behaviour - assemble-windows.mjs: same sourceAlpha handling, without which the Alpha build still emitted the GitHub update provider Verified on macOS arm64: re-assembly of the existing build workspace produced a ZIP with all eight assets, the Dock plugin, NSDockTilePlugIn set and a valid deep code signature; the extracted app installed to ~/Applications and ran without a crash report.
The audit aggregated each child directory with a spread call, so a working tree holding a large vendored subtree died with a RangeError before it reported anything. The generated directories that triggered the overflow were also reported as violations once reached, so the only way to audit a checked-out repository was to delete them first. Walk iteratively, keep one list of generated directory names driving both the traversal and the violation rule, and report what was pruned. Tests reproduce the overflow under a reduced stack and cover pruning plus a violation that must still be reported.
The release orchestrators hardcode one linear await chain each, so nothing can be re-run after a failure, nothing can overlap and every invocation rebuilds work it already did. The two platform chains have already drifted apart from each other. Add the layer they can share: stages declare the stages they consume, the parameters that change their output and the artifacts they produce. The runner orders them, runs independent ones together up to a job limit, and records a checkpoint that a later invocation re-enters. A recorded artifact that vanished or changed underneath the checkpoint stops the run instead of being trusted, and a non-empty workspace without a checkpoint is not adopted silently. The runner is platform-neutral; the orchestrator supplies the stages.
The macOS release orchestrator was a linear await chain: the order in which
steps ran was the order in which they were written, nothing recorded which
artifacts existed, and a rerun redid the whole build. This replaces that with
stage declarations the runner can order, skip and clean.
stage-runner.mjs gains three things the product tree forced:
* `mutableOutputs` — the desktop product is created by one stage and appended
to by later stages (native resources, Host modules). Its digest is not a
fingerprint, so it is verified to exist rather than to match.
* `clean` — a rerun removes what the stage owns before running it. Every
stage entry point still refuses an existing directory for direct CLI use;
the runner never trips that guard because it clears the path first.
* output ownership — two stages may not create the same tree, which would be
unordered and unsafe under parallelism.
The macOS pipeline is now three files: shared-desktop-stages.mjs holds the
spine every platform shares, macos-stages.mjs adds the native inputs, assembly,
acceptance and publish stages, and ci-eduwork-macos-release.mjs validates
arguments and writes the receipt. Platform differences enter through the stage
catalog, not through a platform branch in the orchestrator.
prepare-macos-release-inputs.mjs is split so the expensive half can be cached:
`prepare` builds a native input tree from the lock file alone, `install` copies
it into a product and checks the pinned speech model against the product's own
transcription catalog — a check that cannot run earlier, since that catalog
only exists once a product is installed.
The five failing tests in the suite (three source-reproducibility, two Web
launch) also fail on the parent commit; they are macOS /var symlink
assumptions, not regressions from this change.
Move the Windows release chain onto the same declarative catalog the macOS chain uses: native inputs, native install, desktop candidate assembly with the portable ZIP, packaged launch acceptance and publish. The orchestrator keeps only argument validation, workspace entry and the run receipt. Ownership is split so a rerun of one stage cannot destroy another's artifact: the ZIP is produced by `desktop` and copied by `publish`, and acceptance consumes it instead of packing it. Native inputs are reusable across products because `prepare` reads the pinned runtime manifests and the reviewed source catalog, while `install` is what checks the product's own transcription catalog. The Windows chain cannot be built on macOS and has never run on a Windows runner; both files say so explicitly.
Native inputs do two expensive things: download pinned archives and compile OpenSSL and whisper.cpp. Both are pure functions of data already in the repository, so both can be reused without weakening a pin. `download` gains a content-addressed layer keyed by the pinned SHA-256, which is also the integrity check. An unpinned download is deliberately not cached: without a hash there is no key, and storing an unverified response would make the cache a way around the pin. A corrupted entry is discarded rather than served. The compile layer keys on the source archive, the patch set, the target and the resolved tool versions, so a compiler upgrade invalidates it instead of silently reusing objects another compiler produced. A restored entry is re-hashed against its manifest before it is admitted, so a tampered cache cannot put different bytes into a release. Both layers live under the OS temporary directory by default, never inside the repository: the source audit rejects generated content, and a cache in the tree turns one build into the next one's failure. --cache-root overrides it.
Both were found by comparing an end-to-end run against the pre-refactor baseline, and neither would have shown up in a unit test. `native-install` rejected Python's own symlinks. The baseline extracted the Python tarball straight into `product/r/p`, so `bin/python3 -> python3.12` was created and never traversed. The prepare/install split copies a prepared tree instead, and the link-rejecting copy refused it. The runtime and the browser now use the link-preserving copy; payloads that must not depend on anything outside themselves still use the strict one. `product` pinned a file that `install-host` rewrites. `product` recorded `product/assembly.json` as an immutable output, but `install-product-host` conditionally rewrites it to record the adapter it installed, so re-entry failed with EDUWORK_MODIFIED_ARTIFACT. This is exactly what `mutableOutputs` is for: the stage now promises the tree exists, not that every byte is frozen.
The concurrency limit was a hand-passed number. Nothing in the code said how wide the pipeline could actually run, so the only safe default was one worker and a value above the real width silently bought nothing. `parallelSets` computes the waves from the declared edges — everything in a wave can run at once, and each wave depends only on earlier ones — and `maxParallelism` returns the widest one. No run can finish sooner than that, so it is the default: `--jobs 0` means "as wide as the graph allows" and an explicit number still wins. This is derived rather than written down for the same reason the decision diagram is generated rather than drawn: a hand-maintained stage order drifts from the stages.
The previous diagrams were drawn by hand and had already drifted: both stated a frozen file count that was wrong, and their stage numbering existed nowhere in the repository, so nothing could detect the difference. The generator reads the same stage catalogs the build runs, so the picture is a projection of the graph rather than a second description of it. Waves come from `parallelSets`, hashed dependencies draw solid and ordering-only edges dashed, and mutable-output stages are shaded because they decide where a later stage may legitimately append. Emitted as .drawio (the editable source of record), .mmd for text readers, and .json for tooling. A test regenerates them and fails on any difference, so a stale diagram is a failing build rather than a wrong document.
Each check replaces a failure that would otherwise surface minutes in, after downloads and compiles had already happened. Tools are probed and reported with their version. The probe only treats ENOENT as absent: `ditto --help` and `codesign --version` both exit non-zero on a healthy macOS, so a non-zero exit is not evidence a tool is missing. The upstream cache is inspected for the damage that has actually occurred — a pnpm virtual store left with build output but no `package.json`, while the bookkeeping that would trigger a reinstall still calls the tree complete. It reports and stops there: a half-installed cache is usually recoverable, and deleting someone's cache is not this script's decision. Pinned URLs are HEAD-probed, so a withdrawn release is discovered before a download rather than during one. The speech model also moves ahead of the OpenSSL and whisper.cpp compiles. It was fetched last, so a network failure discarded several minutes of build work that could not be reused.
Records the design, the verification and the limits of the restructured pipeline: the stage declarations and what each field commits to, why the cache has two layers, how artifact ownership decides the serialization, and how the parallel width is derived rather than chosen. States the limits plainly, including the one that is easy to overstate: the pipeline is not byte-reproducible, and was not before this work. Two builds of one commit differ in roughly 200 files through embedded absolute paths, timestamps and ad-hoc signatures. The Windows x64 chain is written against the same declarations but has never been executed, because it cannot be built on macOS. The document and the code both say so.
The one-command entry point gained --jobs, --reuse-workspace and --cache-root when the pipeline became a stage graph, and now preflights before the expensive work. BUILD.md described the entry point without them.
The checked-in .png was exported by hand from the .drawio, so nothing could compare it to the stages it claimed to show. That is the same failure that motivated generating the diagrams in the first place: the hand-drawn versions had already drifted by 70 files before anything noticed. - scripts/build-pipeline-diagram.mjs: emit .svg beside .drawio/.mmd/.json. The layout is the GitHub palette — a bordered header with the run summary, one labelled lane per wave, white cards, hashed dependencies solid green and ordering-only edges dashed grey, mutable-output stages in the attention colour. Descriptions are clipped to the card rather than overflowing it, which the previous 200x60 box did. - The .drawio export keeps its grid but adopts the same palette, so the two views no longer disagree about what the pipeline looks like. - tests/build-pipeline-diagram.test.mjs: compare the .svg against the stages like the other generated assets, and assert that every declared stage is drawn, both edge kinds are present, and the waves are labelled. - Delete docs/assets/build-pipeline-macos.png. The .svg replaces it and, unlike a raster, is diffable and therefore testable.
Three gaps in the checkpoint layer, all of which let a workspace be reused in a state the pipeline no longer describes. * Workspace lock. The one-owner-per-output rule is enforced inside a single process; two processes sharing one --workspace interleave stage runs and overwrite each other's records. Entry now takes an atomic lock directory with an owner record, released by `release()` and by `runStages` on both the pass and fail paths, so a failed run does not block the rerun that fixes it. A lock whose process is gone is recovered rather than honoured, and a lock held by the same process is re-entrant — the lock exists to keep a second process out, not to serialize a process against itself. `--lock-wait` bounds the wait; the default refuses immediately rather than queueing silently. * Catalog check. The checkpoint now records a digest of the stage catalog, and re-entry refuses when it differs. A deleted stage previously left its record behind forever; a stage whose *dependencies were narrowed* kept reusing a `dependenciesDigest` computed from an edge that no longer exists. Both were silent, because the recorded artifacts are still on disk. The error names the added and removed stages, and a checkpoint too old to carry the digest is refused rather than adopted. * Verification depth. `digestPath` hashes whole trees, so a GB-scale artifact cost more to check than to rebuild. Artifacts are now recorded with the depth they were checked at: `bytes` by default, falling back to the file list and sizes above `--digest-budget` (2 GiB), and `trust` only where a stage declares it. Both weaker depths are reported on every re-entry, because "admitted by size" and "checked" are not the same claim. Comparing a size digest against a bytes digest re-digests rather than reporting a difference that says nothing about the artifact. Adds 9 tests covering the refusal, the stale-lock recovery, the re-entrant case, all three catalog mismatches, the budget fallback and `trust`.
The cache defaulted to `os.tmpdir()`. On a GitHub-hosted runner that is `RUNNER_TEMP`, which is emptied at the start of every job and destroyed when the job ends, so both cache layers were silently useless in CI — the one place a cold cache costs the most. On macOS it is a long random per-user path that is also not the temporary directory most people mean. - On POSIX the default is now a flat `/tmp/eduwork-native-cache`; Windows keeps `%TEMP%`, which is the documented location there. `EDUWORK_TMPDIR` relocates the root and `EDUWORK_CACHE_ROOT` overrides the directory outright, so a CI caller can point the cache at something it actually persists (for example via actions/cache) without a code change. - Both release orchestrators and the local pipeline accept `--cache-root`, `--digest-budget` and `--lock-wait`, and set the cache root before any work starts, since the native-input stage is what reads it. - docs/NATIVE-INPUT-CACHE.md records why `$TMPDIR` was rejected rather than leaving the next reader to rediscover it.
JunieXD
marked this pull request as ready for review
October 8, 2026 16:04
This was referenced Oct 8, 2026
freedomkk-qfeng
added a commit
that referenced
this pull request
Oct 10, 2026
Preserve the cross-platform build migration and JunieXD fixes included from #114.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
接续 #76,将桌面构建入口迁移到 Node,并修复审查中确认的两处失败:原生缓存遇到单个可执行文件时中断,以及合法的机构技能替换被误报为重复技能。保留原贡献者提交
a57277d3f2713e15959702959177f2014b506479,通过 merge 与 main 对齐后增补修复,没有重写原提交历史。修复
whisper-cli调用目录读取,真实 macOS 构建报ENOTDIR。现在支持文件、目录和链接,验证输出集合、内容、执行权限和链接目标;旧格式或损坏缓存会重建,恢复失败会清理临时输出。replace: true规则:必须恰好匹配一个核心技能,移除旧项后追加完整机构定义。未声明的重名、找不到目标、歧义或重复替换仍会拒绝。已执行的验证
最终源码为
5978216d008c25e82eaad59ffcb7e2abf3fc8e41:缓存首编与恢复对照在较早的
19d9276997bf2495cc6f7d467e156954dd262f76阶段执行:使用新的输出工作目录,原生输入阶段分别约 123.2 秒和 15.0 秒;恢复后的内容、类型、权限和链接目标与首编一致。这组数字仅说明该阶段的缓存效果,不能作为最终5978216候选的两次对照测量;最终提交另外完成了上述完整构建和 15.1 秒的缓存命中验证。最终候选 ZIP SHA-256:
35d68df94d03849cced8cb4b6a1c0ba0bd07f3ba098aedd17a44ff0db30a67d5。验证边界和已知问题
Windows/Linux 的完整原生构建和运行尚未验收。模型回归连接本机合成服务,未验证外部模型服务或机构 SSO;合成静音转录验证执行链路,不评价语音识别准确率。缓存格式升级后,旧条目首次使用会重建一次。
原生目录选择本次验收失败:并发请求能打开多个选择窗口;macOS 选择器由独立
osascript进程打开,没有归属 EduWork 主窗口。为继续工具和重启回归,在应用退出后通过官方支持的可编辑 JSON 配置准备合成测试工作区。上述工具回归通过不代表原生目录选择通过。本 PR 的相关模块与 main 使用的锁定实现一致,构建修复没有修改它们;这两项既有问题将单独跟进。两处确定的构建失败已解决,Node 构建和缓存目标已通过上述 macOS 实际构建与客户端回归。远端代码与已验收源码逐文件一致;
local-web、macOS/Windowsnative-host和windows-extractor四项自动 CI 全部通过,GitHub 确认可合并且无冲突。在上述验证边界内,现在建议合并这条接续 PR。