Skip to content

chore(release): consolidate the OPS-PTC 18-card release with #1002–#1008 (#1000) - #1033

Merged
Nicholas023 merged 101 commits into
mainfrom
release/consolidate-1023-1008
Nov 20, 2026
Merged

Nicholas023 merged 101 commits into
mainfrom
release/consolidate-1023-1008

Conversation

@Thatgfsj

@Thatgfsj Thatgfsj commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1032, #870, #409, #581, #744, #669, #576, #579, #842, #873, #928, #939, #788, #874, #968, #764, #934, #962, #701, #753, #929, #966
Refs #958, #828, #771, #814, #750, #836, #897, #1000

What was wrong

按仓库约定「同一批改动 PR 数量过多、存在合并冲突时经确认合并为一个 PR 统一合并」,本 PR 把共同构成 0.4 OPS-PTC 构建阶段的 8 个 PR 合并为一个可评审变更,并在统一构建阶段只跑一次 CI:

原 PR 分支 覆盖
#1023 release/ops-ptc-18-cards OPS-PTC 18 张卡(D1–D5 / V1–V5 / P1–P8),52 commits
#1002 fix-shell-runtime-local shells:MSYS 共享段、Niubash 边界、full-access 投影(#870, #409, #581, #958, #828, #771)
#1003 fix-workspace-wsl-local workspace:云占位符与 WSL 重定向器(#744, #669, #576, #814)
#1004 fix-session-lifecycle-local shells:会话生命周期内 Bash 发布一致性(#579, #842, #873, #928, #750)
#1005 fix/file-edit-pdf files:渲染读取回填编辑、经典 xref 间接 /Length(#939, #788)
#1006 fix/windows-metadata-asar windows:可恢复扩展属性、ASAR 成员路径诊断(#874, #836)
#1007 fix-publication-ptc-local publication:deferred 指向 loader、执行器失败 fail-open(#968, #764, #934, #962)
#1008 fix/guidance-integration integration:旧宿主诊断、内置预设 ops_status、batching 教学改走工具结果(#701, #753, #929, #966, #897)

8 个分支各自对 main@58f6e281 可合,但两两之间在 docs/CHANGELOG.md、src/publication/{ptc,registrar,replacements}.ts、src/consumer/mount.ts、test/resident-switch.test.mjs 上有 12 处文本冲突。其中教学通道是真冲突,不是排版问题:#1008 把一次性教学从 step-tail(写入 logged history 的 user 消息,触发 #929 自持循环)改到工具结果的 additionalContexts;#1023 的 P7 卡(#998)建立在「教学进入历史」之上并加了压缩后短提醒。#1023 的说明本身已标注「两者不应盲合,若 #1008 先合,P7 需 rebase 到 ephemeral 通道」。本 PR 按该说明取了 ephemeral 通道。

The change

分支 = origin/main (58f6e28) 依次 merge 7 个 fix 分支,最后 merge release/ops-ptc-18-cards;12 处冲突在 merge 过程中语义化解决,收成一个 merge commit(6c770080)。

冲突决议:

文件 决议
docs/CHANGELOG.md 双方 ## [Unreleased] 条目并集去重(823 行,无重复行)
src/consumer/mount.ts 取 release 的 ptc = mountPtc(...) 句柄,同时保留 fix 的 keepOfficial: () => bashUnavailable(#962)
src/publication/registrar.ts 保留 fix 的 deferred advisor 循环(#968)+ release 的 PUBLICATION_GRANT_REVOKED 判定(#997)
src/publication/replacements.ts 两处都保留:#962 的 per-agent fail-open latch(tools/post-execute)与 release 的隐藏名系统提示退休(system-prompt/assemble)是两个并列 handler
src/publication/ptc.ts 保留 release 的 surfaceFor / renderBatchingGuidance(P1)与 P5 四类裁决;把 #1008 的 #929 ephemeral 教学嫁接到该 surface 上(contributor batching-guidance:lesson,投递点即 latch);把 #968 的 deferredRejection(带可执行 nextAction)并入 !selected 分支,使 SDK_NOT_LOADED 同时点名 ops_load_sdk;移除 P7 的 step-tail provider 与 COMPACTED_TEACHING_REMINDER
test/resident-switch.test.mjs 保留 ephemeral 通道断言;release 的 P1 只读/无 loader 教学断言改为从首个 root run_code 结果的 additionalContexts 读取

跨分支的语义整合(不是文本冲突但同属并集):

为让统一 PR 真的跑通 CI,又补了 5 个构建/平台修复(均为合并体特有的红,不是新行为):

  1. rust-lint:三个 native 分支的合并代码未格式化,cargo fmt 统一;ea.rs 的 0xC000_191 改为 0x0C00_0191。
  2. rust-lint(Windows clippy):windows-metadata 测试里 1 处 needless borrow、3 处 vec!、1 处 unusual byte grouping,按 clippy 建议修正(无行为变化)。
  3. validate(POSIX 腿):fix(shells): classify MSYS section failures and arm the Niubash boundary in confined modes (#870, #409, #581, #958, #828, #771) #1002 新增的三个 Niubash 套件只在 Windows 跑,gate 的按平台允许跳过名单没有它们,于是 4 个 POSIX 腿把它们判成「不该跳过」并因 DSH_OPS_REQUIRE_RUNTIME=1 变成失败;把三个名字加进 ALLOWED_SKIPS(与 windows-security 同类)。
  4. validate(darwin 腿):file_path_tests 的 ASAR 用例直接用 temp_dir(),macOS 的 /var -> /private/var 让 checked_leaf 先撞上符号链接组件而报 PATH_RESTRICTED;先 canonicalize 根目录再走。
  5. validate(win32 腿):Windows 会额外发布 Bash 工具(ops_bash),PTC 套件的等级枚举漏了它;同时 canonical-file-runtime 把含反斜杠的路径直接拼进正则、workspace-reparse-ready 用 icacls 处理 junction(icacls 跟随重解析点,而 Get-Acl 读的是点本身)。分别改为:枚举时剔除 shell 工具、转义正则、用 Set-Acl 安装受保护 DACL。

刻意没做:没有保留 P7 的压缩短提醒(依赖历史可见性,ephemeral 通道下无法成立;违规时的逐条短提醒仍在),没有改任何工具 schema 或参数语义。

Validation

四目标矩阵与所有 gate 作业在本 PR 的 pull_request run 上跑。

$ npm run build
build: bundled 11 browser modules (102001 bytes)
build: generated PTC declarations for 18 capabilities (121119 bytes)
build: compiled src/ to lib/ and copied 60 assets

$ npm run check:size
check-file-size: 865 code file(s) checked, all at or under 1000 lines (longest: native/crates/ops-files/src/file_single.rs (930))

$ npm run validate:manifest
validate-manifest: all 92 checks passed

$ node scripts/verify-gate.mjs --skip-install --keep-going
272 suites passed, 7 failed; skipped: ... (本机缺 npm bundled tar / PowerShell,与基线同红)
  275 suites passed, 4 failed(修 gate 跳过名单后); skipped: niubash-security-host, result-storage-cache-prep, shells-*, tui-host, tui-native, windows-security (all allowed)

本机 4 个失败均为环境缺失(release-tar-modes、niubash-consumer、niubash-payload-integration 需要 npm bundled tar;pwsh-upgrade 需要 PowerShell),#1023 的对照记录里它们在纯净 origin/main 上同样红;CI(Linux/macOS/Windows)上这些套件全部执行并通过。定向读数:

resident-switch            all 28 checks passed
prompt-injection           all 10 checks passed
prompt-ephemeral-teaching  all 2 checks passed
ptc-declaration-surface    all 11 checks passed
ptc-config-truth           all 13 checks passed
ptc-full-disclosure        all 8 checks passed
ptc-two-tier-matrix        all 16 checks passed
ptc-cost-accounts          all 2 checks passed
settings-disclosure-e2e    all 3 checks passed

撤回本次实现会变红的断言(行为级):ephemeral 契约在 test/prompt-ephemeral-teaching.test.mjs;#968 的可执行 nextAction 在 ptc-declaration-surface;两级披露矩阵在 ptc-two-tier-matrix;P1 的只读/无 loader 教学渲染在 resident-switch。

$ gh run view <run-id> --json url,event,conclusion --jq '"\(.url) \(.event) \(.conclusion)"'
$ gh run view 44759217026 --json url,event,conclusion --jq '"\(.url) \(.event) \(.conclusion)"'
https://github.com/T-Auto/dsh-ops/actions/runs/44759217026 pull_request success

Environment

Linux x64 / Node.js v24.21.0 / 基于上游 origin/main@58f6e281;本地源码构建(npm ci --ignore-scripts、npm run build、npm run build:ptc,linux-x64 worker sha256 13e2bd42…)。

合并后处理

Nicholas023 and others added 30 commits November 14, 2026 05:19
A scope without the loader was still taught to call `tools.ops_load_sdk`,
so every such session spent a round trip on a call that cannot succeed and
failed with "is not a function".

The guidance and the `bypass` notice now render from the surface the scope
actually publishes:

- a loader-less scope gets a direct-call step in place of the load step, its
  table row, and any fenced example that teaches loading, and says so when
  nothing is published at all;
- the file-work line names only the file APIs that are loadable or resident,
  never the shell it just accused, and a read-only policy drops the mutating
  APIs from that list;
- the surface is resolved per agent at delivery time, so a narrow pool or a
  read-only session is never told to load what it cannot reach.

The loader-present path is byte-identical for a full pool. Two limits are
documented in the reference: the shipped lesson itself is substituted only
when the loader is absent, and the lists follow the configured pool and the
read-only policy without the per-agent ownership narrowing.

Closes #922
`hideOfficialTools` was inert for every PTC-based preset: `replacementTargets`
gated the file targets behind `plan.nativeFiles`, and PTC plans declare
`nativeFiles: false`, so the target map only ever contained the Windows shell
names. The PTC projection kept the official `read`/`glob`/`grep` SDK bindings
next to the `ops_*` ones.

The replacement controller now receives a `PtcServability` accessor from
`mountPtc`: `servable` is the set of raw APIs the publisher itself would admit
for the agent (`permitted ∧ (resident ∨ allowedApis)`), and `isPtc` is the same
per-activation presentation predicate the publisher already uses. The shadow
`when` hides an official name only when it is a reviewed replacement, the
activation is PTC, the name is servable, and the publisher registered a
counterpart. A presentation probe failure keeps the official tool (fail-open),
because a rejected `when` fails the whole step resolve on this host.

Both the built-in mode gate and the integration path now include the PTC
presentation. `write`/`edit`/`read_image` stay visible.
…nders (#814)

A foreground command that outlived its timeout is promoted to a host job, and the render offered job_output/job_kill as if the kill stopped one command. The host's subprocess and job layer actually terminates the whole tree, so daemons the command started and left attached to its pipes (an adb server, a dev-server watcher) went down with it. The host layer owns that semantics and this repository cannot fix it; the render now states what a job kill reaches and how to keep daemons out of the blast radius.
…870)

A default DSH_HOME (~/.dsh) inside a home workspace made every full-access Niubash call refuse with 'the prepared payload must be outside the session workspace'. The boundary exists so confined workspace labeling and write gating never reach an executable through the workspace or a junction into it; full access runs without confinement and is not a security boundary against the account, so the refusal only removed a working configuration.
…vailable (#409)

msys-2.0.dll prints a per-user section conflict as 'CreateFileMapping S-<user SID>.<n>, Win32 error 5.  Terminating.' with no 'fatal error' prefix, so the restricted-token runtime failure reached the model as a bare non-zero exit and read like a command or denial problem. Classify that message like the signal-pipe failure: EXECUTOR_UNAVAILABLE with sandbox.runnerFailed, never a user authorization denial. The proxy still arms only new objects; a foreign DACL is not rewritten.
A report described ops_bash children still carrying the restricted Low token (S-1-16-4096) in danger-full-access while the host pwsh ran Medium. The projection chain (standing policy, per-call approval, the full-access short-circuit and the skipped confine) checks out in this repository, and a full-access child reports the caller's own integrity label here, so the failure did not reproduce. Lock the boundary with a guard that fails when full access ever routes through confinedBash or sandbox.confine, and document the whoami /groups token comparison for the next report.
…tes (#744)

A OneDrive workspace root carries IO_REPARSE_TAG_CLOUD with no target, and the bootstrap's ancestry walk refused any reparse point before the DACL decision could run, so every workspace-write tool failed on an otherwise ready folder. The reparse check moves to the single branch that actually writes the DACL: an already-ready root answers without any tag inspection, the cloud-files family (Microsoft's 0x90000000-0x9FFFFFFF band) passes because a placeholder keeps a real directory entry behind the point, and every other tag fails closed with the tag named, read through FSCTL_GET_REPARSE_POINT on the point itself. Unreadable points fail closed too.
A husky v9 hook with the shebang #!/usr/bin/env sh failed under the niu-Git command while the same script with #!/bin/sh ran. The interpreter lookup happens inside the niu-Git payload, which this repository cannot patch, so the entry documents the diagnostic pair and the shebang workaround and marks the root cause unresolved-upstream.
…ws Terminal (#828)

Each ops_bash call flashed a console window on Windows 10 when Windows Terminal was the default terminal. Niubash is a console-subsystem binary launched without an interactive parent, and the Windows-10 terminal hand-off re-creates a visible console per call; no dsh-ops setting controls console hosting, and the shipped binary cannot be patched here. Record the default-terminal comparison as the diagnosis and mark the hidden-console build upstream work.
A Defender or ESET event removed only niu.exe from an otherwise complete payload, so selection failed with the member-level diagnostic from #844. The quarantine is an external security-product decision: collect the matching threat event, restore the pinned tree with provision-shells, and if an allow-list is chosen target the fixed prepared location. No repository behaviour claims to prevent it.
#669)

The WSL 9P redirector (\\wsl.localhost and \\wsl$) exposes no NTFS security descriptor, so the bootstrap's Get-Acl threw on every WSL workspace and all of run_code died in workspace-write mode. Exactly those two Microsoft-fixed prefixes now answer ready before Get-Item or Get-Acl is touched, decided by the pure classifier Get-DshOpsWorkspaceNtfsState. This is a prefix decision, not a catch that swallows ACL errors: every other path keeps its existing behaviour and a real ACL failure there still fails closed; authority inside the distribution remains its own uid/gid mapping.
…rences (#958, #828)

Review follow-up: the shebang and console-flash entries stated upstream mechanisms as established facts. Separate what the reporter observes (the two-shebang comparison, the default-terminal comparison) from the attributed mechanism, which this repository cannot verify inside the upstream payloads, so both entries point a diagnosis instead of claiming a proven root cause.
…669)

The redirector prefix decision ran before Get-Item, which turned '9P has no NTFS ACL' into 'the workspace need not exist': a nonexistent-distro path answered ready. The decision now runs after the existence and container validation and before Get-Acl, so a missing path fails exactly like any other missing workspace and a live 9P root still answers ready without reaching Get-Acl. The live end-to-end case becomes an explicit DSH_OPS_TEST_WSL_DISTRO opt-in that registers only after probing the provider, reports not-run without counting it as passed, and runs before the negative case because touching a nonexistent distribution leaves the redirector unable to answer valid paths for under two seconds.
The tag classifier accepted the whole 0x9xxxxxxx band on the high nibble alone, which is wider than the issue's proven family and let unproven tags through before a DACL write. The rule is now the exact family shape: (Tag -band 0xFFFF0FFF) -eq 0x9000001A, i.e. IO_REPARSE_TAG_CLOUD, CLOUD_ROOT, CLOUD_ON_DEMAND and family members sharing 0x9000?01A; 0x9FFFFFFF and a 0x9 tag whose low 16 bits are not ?01A are pinned as negative cases. Decimal literals keep the Windows PowerShell 5.1 unsigned arithmetic working. Docs state the precise family instead of the reserved band, and the same three files also carry the post-review wording that the 9P allowance runs after existence validation (#669).
A registered-but-unselected pool API answered direct dispatch with PUBLICATION_GRANT_UNAVAILABLE (retry: never) on the file-lease path and a bare POLICY_DENIED on the PTC-only path, neither naming the loader. The registrar lease contract gains an optional deferred() advisor that pool publications supply; both paths now answer SDK_NOT_LOADED with a next action naming ops_load_sdk and the raw name, and stay silent when the current policy cannot load the API. Loader-less scopes still register nothing from the pool (#887).
An unselected discovery capability answered direct dispatch with PUBLICATION_GRANT_UNAVAILABLE on the shared-file lease path and POLICY_DENIED on the provider path, with a next action that never mentioned the selector. Both paths now answer CAPABILITY_NOT_SELECTED with a select: query pointer; read-only scopes that can never select a mutating capability keep the generic refusal, and a committed selection stops answering with the deferred rejection.
…ve (#962)

A pwsh shadow kept the official tool hidden even when the replacing Bash executor was dead, and a consumer whose Bash slot never resolved an executor still hid the official tools behind a foreign same-name registration. Replacement shadows now lift per agent once a counterpart call settles with an unrecoverable Bash preparation failure (runtime missing, IPC mismatch, lifecycle lock busy, cache unusable, incompatible build), and mountConsumer keeps the officials admitted when its own Bash slot never resolved. Staging interruptions that the next call repairs keep the shadow.
The retained file/shell row rendered its table from the root registration view, so a registered-but-unadmitted tool - a replacement shadow on a host whose definition reads ignore when - could appear in the read_image row while the step excluded it. The row now reads the calling scope admitted view with the step tool set and falls back from context.agent to context.scope. Host-side sections that read registrations directly remain an upstream boundary.
…call (#576)

Each optional WSL read drove one wsl.exe invocation per Windows drive mapping, one more for the payload sha256, and a final one for the worker, so a small read paid four WSL startups for one result. Preparation is now a single fixed /bin/sh -c script: the text is a constant and every drive root and the payload path travel as positional arguments, so no Windows path can alter the command shape. The wslpath mappings are still resolved anew per call, the payload digest must still match the packaged receipt, and a refused mapping (exit 9), refused digest (exit 8) or failed spawn still falls back to the Windows worker exactly as before.
A no-entitled-grant call consulted only the first same-agent grant
carrying a deferred() advisor; when that advisor answered undefined or
threw, the caller got the generic PUBLICATION_GRANT_UNAVAILABLE even
though a later grant could point at ops_load_sdk or ops_discover_tools.
One entry can hold several same-agent file leases (a PTC pool grant and
a discovery pool grant for the same public name), so the consultation
now walks every same-agent advisor in grant order, returns the first
outcome that carries an error, falls through undefined and throwing
advisors, and keeps the honest generic denial when none can help.
Regression: publication-registrar gains a three-advisor ordering test
plus first-wins and helpless controls.
This was referenced Nov 20, 2026
@Thatgfsj
Thatgfsj deleted the release/consolidate-1023-1008 branch November 20, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants