Skip to content

fix(core): restore permission decision diagnostics - #56271

Open
ZXLyyds100 wants to merge 4 commits into
anomalyco:devfrom
ZXLyyds100:permission-diagnostics
Open

ZXLyyds100 wants to merge 4 commits into
anomalyco:devfrom
ZXLyyds100:permission-diagnostics

Conversation

@ZXLyyds100

@ZXLyyds100 ZXLyyds100 commented Oct 16, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #56247

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Restores V2 Info-level permission evaluation, ask and reply diagnostics. Authorization is unchanged; resources, rulesets, metadata, hook messages and feedback stay private.

Evaluations separate the effective and pre-hook decisions. The zero-based rule index (-1 for default) includes agent/session rules and consulted saved approvals. Asks/replies share session/request identifiers.

How did you verify your code works?

Current head: 4bb78ffad818f4148f7212e3d78a023f520f0de7 (November 4). The latest dev synchronization, validation and remaining limits are recorded in this follow-up. That updated full core run was not fully green: it recorded 7,193 passes, 36 skips and 10 failures; its baseline controls and focused rerun are disclosed in the follow-up. The zero-failure results for bfa44c2 below are historical and must not be read as results for this head. No project tests were rerun for this description clarification, and hosted workflows still require maintainer approval.

bfa44c2 merges dev at 6bac3b9, retaining Logger, upstream Schema, metadata sanitization and its encoding regression.

On macOS, Bun 1.4.2 and task-local Bash 5.3.20, with isolated HOME and temporary directories:

  • Full core suite: 6,671 pass, 43 existing skips, 0 failures.
  • Permission tests: 116 pass; randomized ten-repeat run alongside the full suite: 1,160 pass.
  • Core bun typecheck, root bun run check (34 tasks), Prettier and git diff --check: pass. Lint: 1,306 non-blocking warnings, none in the changed files.

Two initial config-discovery failures disappeared after moving TMPDIR outside personal ancestor directories, without source changes, retry flags or timeout increases. These are local results, not hosted CI.

Screenshots / recordings

No UI change. Historical boundary capture: real permission service, SQLite and file logger; synthetic fixtures, no live model or HTTP/TUI end-to-end run. Eight identical decisions: zero diagnostics before, sixteen after, no private sentinel leakage.

Before After
Before: no permission diagnostics After: permission diagnostics restored

5.8-second comparison · Runnable reproduction and original logs

Captured on 101ec31; not recaptured for this refresh.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Visual

Release illustration only, not a screenshot or runtime recording. The real historical before/after evidence and its source SHA remain above.

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" role="img" aria-label="Permission decisions emit privacy-safe diagnostics">
  <style>
    @keyframes pulse { 0%,100% { opacity:.35 } 50% { opacity:1 } }
    .signal { animation:pulse 2s ease-in-out infinite }
    @media (prefers-reduced-motion:reduce) { .signal { animation:none;opacity:1 } }
  </style>
  <g stroke="currentColor" stroke-width="1.5">
    <rect x="9" y="15" width="76" height="42" rx="8" opacity=".6"/>
    <path d="M90 36h34m-6-5 6 5-6 5" opacity=".65"/>
    <rect x="131" y="10" width="100" height="52" rx="8" opacity=".6"/>
    <path class="signal" d="M143 24h74m-74 12h56m-56 12h66"/>
  </g>
  <text x="47" y="34" text-anchor="middle" fill="currentColor" font-family="monospace" font-size="10">permission</text>
  <text x="47" y="46" text-anchor="middle" fill="currentColor" font-family="monospace" font-size="8" opacity=".65">evaluate / reply</text>
</svg>

AI assistance

Implementation, tests and this description used AI assistance. Automated self-review does not replace independent maintainer review. The verification above retains its original source head and dates; this description-only update does not claim a new project-test run.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works. I ran the #56247 reproduction (simulated model, a shell ask rule answered with Allow once) from source on the base and on this branch. On the base the log has no permission lines. With this change it gets permission evaluated, permission asking and permission replied lines tagged role=server, with matching per_… IDs and no command text or metadata. bun test test/permission.test.ts (114 pass) and the packages/core type check both pass.

The public API is unchanged: this only adds Info log lines.

The deny, ask and allow results and what the permission.evaluate hook receives are the same as before. Replies are logged only after the event is published, and error handling is unchanged.

Two small points, inline: the new tests could be simpler, and the logged rule number is hard to trace back to the user's config.

Comment thread packages/core/test/permission.test.ts Resolved
Comment thread packages/core/src/permission.ts Resolved
@ZXLyyds100

Copy link
Copy Markdown
Author

AI-assisted follow-up: merged dev (6bac3b9) in bfa44c2, resolving the Logger/Schema import conflict while preserving upstream metadata sanitization and its encoding regression. The effective PR still changes only the two permission files.

Local verification: 6,671 pass, 43 existing skips, 0 failures, plus 1,160 randomized permission tests alongside the full suite. Core typecheck, root bun run check, Prettier and git diff --check pass. The PR body records the initial fixture-isolation issue and historical media boundary.

GitHub now reports MERGEABLE; check, test and nix-eval are awaiting maintainer approval, not executed CI passes.

@ZXLyyds100

Copy link
Copy Markdown
Author

Resolved the current dev conflict in 4bb78ffad8, preserving unattended allow/deny handling and logging the final settled decision. Added regressions for both decisions without private data; the PR still changes only two files.

Permission tests: 1,330 passes across ten randomized runs. Root check: 35/35; core TypeScript: passed. The full core run recorded 7,193 passes, 36 skips and 10 failures: three shell failures reproduce on unchanged dev, and seven Session timeouts did not recur in the focused rerun. This is not a fully green core suite.

The branch is now conflict-free. Could a maintainer approve the pending workflows and review the update when convenient?

AI-assisted follow-up.

This branch has not been deployed

No deployments
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.

server: permission evaluations and asks are no longer logged in v2

1 participant