Skip to content

fix(symbol-map): make the package compile without the host tree - #469

Open
yanfei0725 wants to merge 6 commits into
T-Auto:mainfrom
yanfei0725:#459
Open

yanfei0725 wants to merge 6 commits into
T-Auto:mainfrom
yanfei0725:#459

Conversation

@yanfei0725

@yanfei0725 yanfei0725 commented Oct 28, 2026 •

Copy link
Copy Markdown

这次只改一件事:让这个包脱离宿主树也能编译

原来这份源码是 source drop:src/file/symbol-map.ts 会 import '../worker-boundary.js',src/symbol-map/grammar.ts 会 import '../paths.js' —— 这些模块由宿主提供,包里没有。所以「能不能编译」只能在实际落进 dsh-ops/src/ 之后才回答,reviewer clone 下来跑 tsc 是必然失败的。

补齐五个宿主契约

包里实际只用到五处宿主能力,都做成薄契约副本:

文件 行数 提供什么
src/host/contract.ts 69 工具回执、参数归一、MODES 表
src/host/permissions.ts 35 策略判定
src/host/worker-boundary.ts 22 边界错误构造
src/adapter/dsh/types.ts 48 DSH 侧类型
grammar.ts 内联 PACKAGE_ROOT — 包根定位,不再从宿主推

authority-paths.ts 与 credential-policy.ts 原样保留 —— 它们本来就是投给宿主的 patch,不是需要补的缺口。

提交了 tsconfig.json

npm test 现在是两段:

tsc -p tsconfig.json --noEmit          零诊断
node test/verify.mjs --no-typecheck    运行时:编到临时目录,喂临时 .ts,断言符号表非空、
                                       revision 是 64 位十六进制、回执里 fileHash 与 symbols 都在

运行时那段会真正走 normalizeArguments / MODES / record / 凭据围栏这几份契约副本,不是只测引擎内核。语法包(tree-sitter*)没装时打印 SKIP 并退出 0 —— 它们在 optionalDependencies 里,未安装是正常安装态。

目录

packages/ops-symbol-map/
├── src/symbol-map/   12 个 .ts(解析、查询、缓存、快照、walk)
├── src/file/         symbol-map.ts(工具入口)、reparse.ts(重解析点)
├── src/host/         3 个契约副本
├── src/adapter/dsh/  types.ts
├── src/              authority-paths.ts、credential-policy.ts(对宿主的 patch)
├── test/verify.mjs   两段校验
├── bench/
├── tsconfig.json
└── docs/ README.md package.json

没有 .tgz、没有 .tar.gz、没有 .exe、没有 dist/、没有 node_modules/。.gitignore 只拦产物,src/ 下的 .ts 不受影响。

单文件 1000 行

最大 433 行(symbol-map/engine.ts)。全部提交在 1000 行以内。

一处需要维护者判断

契约副本意味着宿主改了签名,包内这三份要跟着改 —— 换来的是这个包能独立 typecheck。如果更希望保持「零副本、只做投放」的形态,那 verify.mjs 就得退回「先复制宿主 src 再编译」的老路,代价是 PR 无法自证可编译。我按前者处理。

@yanfei0725 yanfei0725 changed the title #459 引入基于 Tree-sitter Queries 的 Symbol Map 导航层 feat(symbol-map): ops-symbol-map 20261029 — realpath recheck, manifest, 512 default page Oct 29, 2026
@yanfei0725 yanfei0725 changed the title feat(symbol-map): ops-symbol-map 20261029 — realpath recheck, manifest, 512 default page feat(symbol-map): ops-symbol-map 20261029.3 — filtered pagination stats, realpath recheck, manifest Oct 30, 2026
@yanfei0725 yanfei0725 changed the title feat(symbol-map): ops-symbol-map 20261029.3 — filtered pagination stats, realpath recheck, manifest feat(symbol-map): ops-symbol-map 20261029.4 — dual-anchor grammar resolution Oct 30, 2026
…es/ instead of a tarball

The PR shipped ops-symbol-map-20261029.tar.gz, so the diff showed one opaque
binary and every reviewer had to unpack it to read a line of code.

- packages/ops-symbol-map/src/   engine plus the dsh-ops adapter, paths mirroring src/
- packages/ops-symbol-map/test/  verify.mjs overlays src/ on the host tree and runs tsc
- packages/ops-symbol-map/docs/  audit, technical notes, historical comparison
- drop the tarball, the duplicated root README and the root-level AUDIT file
- .gitignore: release archives and vendored .exe never enter the tree
@yanfei0725 yanfei0725 changed the title feat(symbol-map): ops-symbol-map 20261029.4 — dual-anchor grammar resolution feat(symbol-map) Oct 30, 2026
@yanfei0725 yanfei0725 changed the title feat(symbol-map) feat(symbol-map): ops-symbol-map 20261029.4 as source under packages/ Oct 30, 2026
The package was a source drop: src/file/symbol-map.ts imported
../worker-boundary.js and src/symbol-map/grammar.ts imported
../paths.js, so "does it compile" could only be answered after the
files landed inside dsh-ops/src/. A reviewer cloning the PR had no way
to typecheck it.

The five host surfaces the package actually uses are now captured
inside the package as thin contract copies — src/host/contract.ts,
permissions.ts, worker-boundary.ts, src/adapter/dsh/types.ts, and a
locally defined PACKAGE_ROOT in grammar.ts. authority-paths.ts and
credential-policy.ts stay as the host patches they always were.

tsconfig.json is committed and npm test now runs tsc --noEmit first,
then the runtime half against the compiled output. Both halves pass
with zero diagnostics. Largest file is 433 lines.
@yanfei0725 yanfei0725 changed the title feat(symbol-map): ops-symbol-map 20261029.4 as source under packages/ fix(symbol-map): make the package compile without the host tree Oct 30, 2026
@OldLigant OldLigant assigned OldLigant and unassigned OldLigant Oct 30, 2026
@OldLigant
OldLigant self-requested a review October 30, 2026 15:47
`symbol_map` was a separate package under `packages/`, built and copied in beside the host. It
is now part of the host: the engine lives in `src/symbol-map/`, the tool in `src/file/symbol-map.ts`,
and the native spawning path is gone.

- src/symbol-map/           engine, query, grammar, snapshot, cache, walk, files, types, errors
- src/file/symbol-map.ts    policy resolve, credential fence, anchor, reparse refusal, receipt
- src/file/reparse.ts       one lstat walk shared with the file worker
- src/file/worker.ts        `symbol_map` dispatches before any spawn
- src/capabilities/*        registered as a resident file tool; parameters and description added
- docs/symbol-map.md        where it lives now, the fence order, the receipt shape

The grammar (.node) is still optional: `src/symbol-map/grammar.ts` resolves it through the package
root and `vendor/deps`, and reports E_ENGINE_UNAVAILABLE rather than failing the host when absent.

Two defects found while inlining, both fixed here:

- receipt paths lost the POSIX normalisation the shipped package had; on Windows `src\inp.ts` came
  back with a backslash, which is a JSON escape the caller has to write by hand before feeding it
  to the next tool;
- `symbol_map` has to survive a `node_modules` reinstall, so the anchor list keeps `vendor/deps`.

Verified: `tsc --noEmit` clean, `node scripts/build.mjs` succeeds, `node test/symbol-map-inproc.mjs`
19/19 (map, filter, paging, fingerprint, anchor refusal, junction refusal, missing file, no session),
and the capability/catalogue/file-contract/compat gates pass. The serialized-contract hash in
`test/capabilities.test.mjs` moved only by `symbol_map` itself; the other tools still hash to the
pre-migration value.
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.

2 participants