Skip to content

fix(prompts): rule-slot sections accept string overrides (#423) - #425

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-09-13_rule-slot-strings-423
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-09-13_rule-slot-strings-423

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #423

Problem

sanitizePromptSections accepted null only for the rule slots (philosophy / howToCompress / tier2 / tier3). Kernel master (post-#269, formalized by open PRs #263/#266) ships lean's howToCompress as a condensed string (~2.5K, restoring the summary style floor lost in the #263 hallucination incident). On the next kernel bump pi would have silently dropped lean's condensed rules (falling back to the 4.5K default — silent regression) and the #403 leanPack assertion would have gone red.

Fix

  • Rule slots now accept string | null in sanitize (string = replace slot body, null = remove) — the apply path (applySectionOverrides, kernel) already treats strings as replacement, so this is a one-line contract fix
  • Tests: string override survives sanitize + replaces the slot text in buildAcpSystemPrompt; kernel-master-style condensed howToCompress flows through piAdapterSurface; junk test updated to the new contract (strings kept, non-strings still dropped)

Verification

805 tests, 0 fail (3 pre-existing skips), typecheck clean, build green. Also validated against a local kernel-integration build (master + #271 + #273): the condensed string flows into the rendered prompt.

@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Extension Artifact

Branch: 2026-09-13_rule-slot-strings-423 (3bf4300)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-425

Each push to this PR publishes a new version under the pr-425 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr425.tgz
pi install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review started. Initial finding: the branch carries two commits — the #423 rule-slot fix (bbfcc60) and an unrelated guardrails change (7deef59, refs #421, config.ts + CONFIGURATION*.md). That makes the diff off-scope for this PR; I'll verify the code, run the checks, then converge the branch so every line is #423-related (the #421 change will get its own PR so nothing is lost). Full review reply shortly.

awork and others added 2 commits September 13, 2026 18:23
…ll (refs #423)

Kernel #263/#266 lean contract ships a condensed HOW-TO-COMPRESS string in
the howToCompress slot; sanitizePromptSections was null-only and would have
silently dropped it on the next kernel bump.
…e string-replacement contract (refs #423)

sanitizePromptSections now stores replacement strings in the rule slots,
but PiPromptSections still declared them null-only, hiding the new
capability from typed consumers. Align the four rule-slot fields with
the kernel tri-state contract (string | null).
@ranxianglei
ranxianglei force-pushed the 2026-09-13_rule-slot-strings-423 branch from bbfcc60 to 3bf4300 Compare September 13, 2026 10:23
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review complete — diff converged, one small fix added directly to the branch, ready to merge.

Duplicate screening

No duplicate of the #423 fix exists. But the branch carried a second, unrelated commit (7deef59, "feat(guardrails): default tool output cap 200KB -> 50KB", refs #421) touching src/config.ts + both CONFIGURATION docs. That change already has its own PR: #426 (open, branch 2026-09-13_tool-output-default-50kb) — and #426 is the more complete version (same constant change plus the tool-guardrails.ts wiring comment, the renamed/tightened default-contract test, and a CHANGELOG entry; the bundled commit had none of those). Verdict: duplicate with a superior existing counterpart → dropped from this branch, nothing lost.

Verification of the fix itself

  • Kernel contract claim holds. Pinned acp-kernel 0.0.66, applySectionOverrides (node_modules/acp-kernel/dist/index.js:806-814): o === null → section removed; typeof o === "string" → replacement pushed; otherwise default kept. So yes — the apply path already treats strings as replacement; the sanitize side was the only broken half of the tri-state contract. One-line contract fix, correctly scoped.
  • Zero behavior change at the current pin. Inspected the pinned kernel's lean pack pi surface: every slot except acpTags is null today (howToCompress = null). This is purely forward-compat for the next kernel bump that ships the condensed ~2.5K string — exactly as described. No silent regression introduced either way.
  • Checks re-run locally on the branch: npm run typecheck clean · npm test 805 tests / 802 pass / 0 fail / 3 skipped — the same 3 pre-existing skips as master (I cross-checked skip names on both branches; an initial run showed 6 skips but that did not reproduce — transient, not PR-related) · npm run build green (794.68 KB dist).

What I changed on the branch (committed directly, per review policy)

  1. Dropped 7deef59 via git rebase --onto origin/master — see duplicate finding above.
  2. Fixed a type inconsistency the fix left behind (3bf4300): src/system-prompt.ts:14-17 still declared the four rule slots as philosophy?: null; howToCompress?: null; tier2?: null; tier3?: null; while sanitizePromptSections now stores replacement strings there (via cast). The interface lied about the new capability — typed consumers would see these fields as never-string. Widened all four to SectionOverride (string | null), matching the kernel tri-state contract and making the interface uniform. No consumer depends on the old null-only typing (checked all 6 usage sites: config/surface/user-config/prompt-pack/index). Re-ran typecheck + full suite + build after the edit: all green.

Branch state after convergence (force-pushed with --force-with-lease, CI will republish the pr-425 artifact):

3bf4300 fix(prompts): type rule-slot sections as SectionOverride … (refs #423)   ← reviewer fix
330306f fix(prompts): rule-slot sections accept string overrides … (refs #423)   ← original fix

Diff vs master is now exactly src/system-prompt.ts (+10/−4) and tests/prompt-pack.test.ts (+31/−2) — every line is #423-related. New tests are meaningful: string survives sanitize and replaces the rendered slot text (with a guard that the 4.5K default text is gone), the kernel-master-style condensed string flows through piAdapterSurface, and the junk test pins the new contract (strings kept, non-strings dropped).

Minor observations (no action needed)

  • An empty-string override now replaces a slot with "" (renders as a blank gap in the \n\n join) rather than being dropped — consistent with kernel semantics for every other section, harmless.
  • PR body says "3 pre-existing skips" — matches my verified count.

中文摘要:修复本身正确且已验证(kernel 的 applySectionOverrides 本就是 string=替换/null=删除 三态契约,当前 pin 下行为零变化,纯为下个 kernel 版本的前向兼容);发现分支里混入了与 #421 相关的无关提交,而该改动已有更完整的独立 PR #426 覆盖,故已从本分支剔除(无工作丢失);另直接在分支上补了一个小修复——PiPromptSections 四个规则槽的类型仍声明为 null-only、与新契约不符,已改为 SectionOverride。diff 现已收敛到与本 PR 目的完全相关,typecheck/805 测试/build 全绿,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

Closing as superseded by #427 — same sanitize contract fix (rule slots accept string/null), #427 adds CONFIGURATION docs + surface-config tests and is based on newer master (post-#414).

@ranxianglei ranxianglei mentioned this pull request Sep 13, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant