Repository navigation
fix(symbol-map): make the package compile without the host tree - #469
Open
yanfei0725 wants to merge 6 commits into
Open
yanfei0725 wants to merge 6 commits into
yanfei0725 wants to merge 6 commits into
Conversation
…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
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.
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.
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.
这次只改一件事:让这个包脱离宿主树也能编译
原来这份源码是 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.tssrc/host/permissions.tssrc/host/worker-boundary.tssrc/adapter/dsh/types.tsgrammar.ts内联PACKAGE_ROOTauthority-paths.ts与credential-policy.ts原样保留 —— 它们本来就是投给宿主的 patch,不是需要补的缺口。提交了 tsconfig.json
npm test现在是两段:运行时那段会真正走
normalizeArguments/MODES/record/ 凭据围栏这几份契约副本,不是只测引擎内核。语法包(tree-sitter*)没装时打印 SKIP 并退出 0 —— 它们在optionalDependencies里,未安装是正常安装态。目录
没有
.tgz、没有.tar.gz、没有.exe、没有dist/、没有node_modules/。.gitignore只拦产物,src/下的.ts不受影响。单文件 1000 行
最大 433 行(
symbol-map/engine.ts)。全部提交在 1000 行以内。一处需要维护者判断
契约副本意味着宿主改了签名,包内这三份要跟着改 —— 换来的是这个包能独立 typecheck。如果更希望保持「零副本、只做投放」的形态,那
verify.mjs就得退回「先复制宿主 src 再编译」的老路,代价是 PR 无法自证可编译。我按前者处理。