Repository navigation
fix(history): resolve bounded default context for argument-free dispatch - #16
Merged
Merged
Conversation
…-free dispatch A keybinding invokes `query-transcript`/`query-commands` with an empty args table, so the plugin returned E_HISTORY_SCOPE_MISMATCH and no entry surface appeared. The public Lua surface exposes no focus getter, and reading `workspace.list`/`panel.*` would require workspace.read/panel.focus — a capability widening this package must not take. Resolution rule: explicit scope/bounds always win unchanged; when they are absent the plugin reads its declared, capability-neutral settings context (`default_panel`/`default_workspace`; empty string means unset) and applies the shipped row/byte caps (16/4096). A configured bound outside 1..cap falls back to the shipped cap; explicit over-bound requests still deny. With no valid scope axis the typed E_HISTORY_SCOPE_MISMATCH denial is preserved. - bitty-plugin.toml: add `[settings]` with the four declared keys; keep the capability set byte-identical. - lua/history/init.lua: add resolve_scope/resolve_bounds and wire them into M.query before validation; validate_scope/validate_query stay unchanged. - tests: empty-args dispatch produces entries for the configured focused panel, explicit scope wins, no context still denies, malformed default fails closed, defaults stay inside caps (3 of 5 fail pre-fix). - SDK pin: 0a9487f (open PR head) -> 3ea8e58 (merged main; history surface plus declared-settings lint/mock support, PR #152). - README/TODO synchronized; stale compat/pin/verification prose fixed. Task: CTX-0005
Contributor
Author
|
Independent review by a separate review subagent: APPROVE.
GitHub rejects a formal approval from the authoring account, so this review is recorded here and in |
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.
Priority: P1 | Area: plugin | Labels: fix,P1,area:plugin | Milestone: v0.1.0 | RFC: RFC-0004 | Task: CTX-0005
Closes #15
Problem
A keybinding invokes
bitty-terminal.history:query-transcript(andquery-commands) with an empty args table. The plugin required an explicitpanel/workspace scope and explicit row/byte bounds, so it returned
{ok=false, code=E_HISTORY_SCOPE_MISMATCH}before any host call and no entrysurface appeared. There was no settings fallback.
Issue #12 (compat floor) is closed and unrelated; no newer history issue
covered this defect, so #15 tracks it. (An identical report briefly landed in
bitty-plugins#100 by mistake and is closed as a pointer.)
Resolution rule
scope.panel/scope.workspacepresent, and anyrow_count/max_bytespresent,travel the previous path: the unchanged
validate_scope/validate_querychecks, then the host's grant/scope/bound gate (over-bound still denies,
never clamps).
[settings]context:default_panel/default_workspace(empty stringmeans unset). Wildcard/blank/control/over-long ids fail closed as
E_DEF_INVALID. KV never resolves an extent (the caller namespace is thescope).
row_count/max_bytessettings only insidethe accepted 1..16 / 1..4096 caps; an out-of-window configured value falls
back to the shipped cap (16 / 4096), so a local default can never become an
over-bound request.
E_HISTORY_SCOPE_MISMATCHdenial.Why settings and not a focus getter: the public Lua surface exposes no focus
read, and
workspace.list/panel.*would requireworkspace.read/panel.focus. The task and this package forbid widening capabilities (andreading outside the granted history scope), so the sanctioned host context is
the declared settings namespace. The capability set is byte-identical to
main; the host still intersects every query scope with the granted scope.Change
bitty-plugin.toml:[settings]with exactlydefault_panel,default_workspace,row_count(16),max_bytes(4096). No capabilitychange.
lua/history/init.lua:M.resolve_scope/M.resolve_bounds, wired intoM.querybefore validation.validate_scope/validate_queryunchanged.tests/history.test.ts: 5 new regressions (3 fail pre-fix):E_HISTORY_SCOPE_MISMATCH;E_DEF_INVALID;0a9487f(open PR head) ->3ea8e58(mergedmain; historysurface from #144 plus declared-settings lint/mock support from #152), so
the manifest
[settings]declarations are enforced by the linter and themock.
Validation
just check— exit 0: prettier, markdownlint, metadata, hygiene, portablepaths, manifest lint (0 errors), luaparse + control, bun 49 pass / 0 fail.
bun test tests/history.test.ts -t "bounded default context"— 5 pass;against
origin/main'sinit.luathe empty-args, malformed-default, andcap regressions fail as expected.
bunx --bun luaparse@0.3.1 --file lua/history/init.lua— clean.bun run bitty-plugin-lint bitty-plugin.toml— valid (0 errors, 3 expectedhigh-risk consent warnings).
gitleaks detect --source .— no leaks.just actionlint— clean.Risk
Values-plane only: settings supply convenience defaults and grant no
authority; the host intersects every scope with the grant and enforces
capture/rate/bounds. No capability, source, or export change. The SDK pin bump
is required for the declared-settings gate and is a merged
maincommit.Requested labels:
fix,P1,area:plugin; milestonev0.1.0.