Skip to content

chore(edge/windows): inline comment context (cleanup PR1/PR2 ADR refs) - #230

Draft
anrenlx2025 wants to merge 3 commits into
ongridio:mainfrom
anrenlx2025:feat/windows-inline-adr-context
Draft

anrenlx2025 wants to merge 3 commits into
ongridio:mainfrom
anrenlx2025:feat/windows-inline-adr-context

Conversation

@anrenlx2025

Copy link
Copy Markdown
Contributor

Cleanup-only follow-up to PR1 #228 + PR2 #229. Inlines comment context that previously referenced internal ADR codes.

Why

PR1 and PR2 comments referenced ADR-0XX / MVP-X #XX / issue #XX / W[1-5] / dogfood / CR4 / YAGNI codes that point to internal design docs not in this repo. Reviewers flagged these as dead references. This PR removes the codes and leaves the surrounding explanatory text intact.

Scope

32 files, +120 / -240 lines. Comments only — zero functional change.

Files touched (comment cleanup):

  • cmd/ongrid-edge-supervisor/* (6 files)
  • internal/edgeagent/supervisorhealth/* (2 files)
  • internal/edgeagent/upgradebundle/* (3 files)
  • internal/edgeagent/upgrademachine/* (21 files, including testdata)

Stacked on #229

This PR's branch includes commits b705400 (PR1) + 2e1b996 (PR2) + b6d4351 (this cleanup). Once #228 + #229 merge, this PR auto-rebases and the diff collapses to the cleanup only.

Verification

  • GOOS=linux go build ./... — clean
  • GOOS=windows go build ./cmd/ongrid-edge-supervisor/... ./internal/edgeagent/{config,dpapi,edgedirs,install,supervisorhealth,upgradebundle,upgrademachine}/... — clean
  • Unit tests pass: cmd-supervisor + supervisorhealth + upgradebundle + upgrademachine
  • grep -E "ADR-0[0-9]+|MVP-[0-9]|issue #[0-9]+|W[1-5]|dogfood|YAGNI|CR4" — zero matches across changed files

Roadmap

anrenlx added 3 commits July 19, 2026 20:06
为 Windows edge agent 奠定平台基础,包含:

- internal/edgeagent/dpapi: DPAPI CRYPTPROTECT_LOCAL_MACHINE 加密 + round-trip 验证
- internal/edgeagent/edgedirs: Windows 平台目录抽象(InstallDir / DataDir / StageDir / LogDir)
- internal/edgeagent/install: supervisor --install 入口拆分为 SecretStore / ServiceController / EnvWriter 三接口,支持 schtasks SYSTEM 身份执行
- internal/edgeagent/config: secrets.enc 加载 + token 轮转周期检查(默认 90 天)
- internal/edgeagent/host_files: 平台抽象(owner_windows / owner_unix / times_windows)

本 PR 仅加新文件,不改 main.go / config.go / tunnel/*。后续 PR 将引入:
- PR2: cmd/ongrid-edge-supervisor(Windows Service 包装 + worker 监控)
- PR3: upgradebundle + upgrademachine(rename-aside 自升级机制)
- PR4: Windows host skills + plugins(hostmetrics/logs Windows 分支)

测试:dpapi + install + config 单元测试通过;GOOS=linux + GOOS=windows 双向编译通过。
引入 Windows edge supervisor(Windows Service 包装层)+ rename-aside 自升级机制,
对称消费 PR1 scaffolding(DPAPI/edgedirs/install)。

包含:

- cmd/ongrid-edge-supervisor: Windows Service 入口(main/service/worker/upgrade_windows/install_windows)
  - supervisor.exe --install/--uninstall/--upgrade 子命令
  - worker 进程生命周期管理(启动/监控/重启)
  - schtasks SYSTEM 身份执行 DPAPI install
- internal/edgeagent/supervisorhealth: supervisor 健康检查 + health.json 写入
- internal/edgeagent/upgradebundle: bundle 下载 + SHA256 校验 + 健康标记写入
- internal/edgeagent/upgrademachine: 深模块 rename-aside 自升级状态机
  - Machine 接口(4 个):ProcessController / State / IPC / Manifest
  - supervisor self-swap(运行中 .exe 自我替换)
  - W1-W5 加固:orphan worker race / Defender 锁文件 / brick rollback / SCM recovery / pending bundle 解压

依赖:PR1 ongridio#228(DPAPI + install + edgedirs)

验证:
- GOOS=linux + GOOS=windows 双向编译通过
- 单元测试:cmd-supervisor + supervisorhealth + upgradebundle + upgrademachine 全部通过
- upgrademachine 含 10 循环稳定性 + 并行 race condition 测试

后续:PR3 将加 Windows host skills + plugins Windows 分支(hostmetrics/logs/skill/quota)。
PR1 (ongridio#228) + PR2 (ongridio#229) 推送后发现注释含内部死引用(upstream 无对应文档),
此 follow-up 把它们清理掉:

清理范围:
- ADR-0XX / ADR-033 U3 I2 / ADR-035 Q7 C5 / ADR-037 A2 CR4 等内部 ADR 编号
- MVP-1/2/3 + ongridio#4/ongridio#7/ongridio#9/ongridio#13/ongridio#18-1/ongridio#20/ongridio#21/ongridio#23 等内部 issue 编号
- W1-W5 加固编号(保留具体描述,仅删编号)
- dogfood / P5 dogfood / YAGNI / 对抗式审核 等内部审核术语
- CR4 子编号

仅注释改动,零功能变化。32 文件 / +120 / -240。

验证:
- GOOS=linux + GOOS=windows 双向编译通过
- 单元测试全部通过(cmd-supervisor + supervisorhealth + upgradebundle + upgrademachine)
- grep 完整性扫描零匹配(ADR/MVP/#issue/dogfood/YAGNI/CR4 全清)
@anrenlx2025
anrenlx2025 requested a review from singchia as a code owner July 19, 2026 12:56
anrenlx2025 pushed a commit to anrenlx2025/ongrid that referenced this pull request Aug 7, 2026
upstream tail_file_test.go 第 114 行用 hardcoded "/tmp/..." 作为不存在的绝对路径,
在 Windows 上 /tmp/... 不是 absolute(Windows 需要 C:\ 前缀),filepath.IsAbs
返回 false → 测试期望 err==nil 但实际返回 "path must be absolute" → FAIL。

改用 filepath.Join(os.TempDir(), "...") 拼路径:
- Linux/macOS: /tmp/this-file-does-not-exist-ongrid-test
- Windows:     C:\Users\<user>\AppData\Local\Temp\this-file-does-not-exist-ongrid-test

两平台都满足 filepath.IsAbs,测试达到原意图(验证 file-not-found 错误)。

独立于 Windows edge PR 链(PR1 ongridio#228 / PR2 ongridio#229 / cleanup ongridio#230 / PR3 待开),
对所有平台有益,可立即 merge 到 main。
@anrenlx2025
anrenlx2025 marked this pull request as draft August 7, 2026 09:56
@anrenlx2025

Copy link
Copy Markdown
Contributor Author

关闭此 PR — 它当前形态包含 PR #228(已合并)+ PR #229(OPEN)+ cleanup commit 的累积内容,mergeable 永远为 UNKNOWN。

cleanup commit b6d43514 本身有独立价值(清理 #229 supervisor 代码注释中的内部 ADR/issue 编号,+120/-240 行),但需要 #229 先合并才有上下文。

计划:等 PR #229 合并后,从 [upstream/main + #229] base 拉新分支重做 cleanup,开独立小 PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant