Repository navigation
refactor(surface): retire host section whitelist; uniform kernel tri-state over SECTIONS-derived keys - #430
Conversation
📦 Built Extension ArtifactBranch: Option A — Install from npm PR tag (recommended)pi install npm:billion-context-pi@pr-430Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pi-pr430.tgz
pi install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 Review: PR #430 — claims independently re-verified, one gap fixed directly on the branch, ready to merge. Diff cleanliness ✅ — 5 files, 29+/13−. Every line serves the refactor or its docs/tests; no unrelated hunks, no whitespace churn. Verification (re-ran everything locally instead of taking it on faith):
Fixed directly on the branch (new commit
Minor note (not fixed, out of scope): the topmost existing Unreleased entry (#426, line 4) is missing its leading Verdict: behavior-preserving relative to master (post-#427 all 13 keys already accepted string|null; what changes is single-sourcing the key derivation, which removes the drift class that produced #423). Mergeable. 修了什么问题 / 为什么修 / 是否可以合并:PR 代码本身零修改(重构与测试全部独立复验通过),仅在 PR 分支补了一个缺失的 CHANGELOG.md 条目(commit b876682,已推送);双内核版本验证确认 3 个失败断言属 #428 发版对齐范围、与本 PR 无关,可以合并。 |
b876682 to
8575e27
Compare
8575e27 to
7f71b49
Compare
…state over SECTIONS-derived keys (#429) RULE_SLOT_KEYS/PROMPT_SECTION_KEYS duplicated the kernel's section contract, so kernel 0.0.68's null→string slot flip silently dropped lean's condensed rules (#423, symptomatic fix #427). The key set now derives from SECTIONS (pi's own builder list — host policy) and every key takes the same kernel tri-state validity (string replaces, null removes, junk dropped): no per-slot type opinions left for the kernel to outgrow.
7f71b49 to
fd0d78f
Compare
What
Retires pi's own slot-legality whitelist in
sanitizePromptSections(the structural debt #429 calls out):PROMPT_SECTION_KEYS(9 "structural" keys) +RULE_SLOT_KEYS(4 rule slots) are deleted.SECTION_KEYS, derived fromSECTIONS— pi's own builder list, i.e. pure host policy (which sections exist). Add/remove a section in one place and sanitization follows automatically.Both call sites (
src/prompt-pack.ts,src/surface.ts) keep callingsanitizePromptSections; signature unchanged.Why not literally route through kernel
sanitizePackSurfaceVerified against both 0.0.66 and 0.0.68 bundles: the kernel deliberately treats
surface.adaptersas opaque — its own packs docs say "Hosts sanitize their own sub-objects; the kernel only checks it is a plain object." And its section key space (acpTags,tools,summariesInContext,textProtocol,textTools,functionTools) does not include pi's ten extra sections (whenToCompress,multiTierIntro,throttleRetry,philosophy,howToCompress,tier2,tier3, …). Feedingadapters.pi.promptSectionsthroughsanitizePackSurfacewould drop lean pack's entire payload — #423 in reverse. So delegation at that layer is impossible by design; this PR achieves the same goal the other way: per-value validity mirrors the kernel contract exactly (no duplicated type rules), the host owns only its key space, and the kernel's ownsanitizePackSurfacealready ran inside every PackSource before pi sees a Pack — no double sanitization of pack-level fields anywhere.Tests (acceptance: pin pass-through semantics, not host whitelist)
tests/surface-config.test.ts: the old "rule slots take string or null" test becomes a uniform-contract test — everySECTION_KEYSentry accepts string and null identically, junk types and unknown keys dropped for all.tests/prompt-pack.test.ts: new test pins pass-through — a pack carrying valid tri-state values on every pi key survivespiAdapterSurfacebyte-identical.Verification
settled historyremoved,summariesInContextnull→string, header without(condensed)). Those fail on master against 0.0.68 with or without this change — they belong to release v0.1.69 #428, not here.summariesInContext, a slot shape the old whitelist never anticipated.Coordination
No version/pin changes (release territory — #428 owns the 0.0.68 bump). Test hunks are disjoint from #428's; merge order independent (clean rebase either way). After this lands, future prompt-contract changes like #265/#266 need only a pin bump on the pi side.
Fixes #429