Skip to content

feat(web): expose project trust diagnostics - #392

Open
testikun wants to merge 1 commit into
openpi-dev:mainfrom
testikun:codex/issue-343-trust-diagnostics
Open

feat(web): expose project trust diagnostics#392
testikun wants to merge 1 commit into
openpi-dev:mainfrom
testikun:codex/issue-343-trust-diagnostics

Conversation

@testikun

@testikun testikun commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

The Trust work tracked by #343 needs more than a compact label: operators must be able to distinguish the active Session authority from the current Pi ProjectTrustStore decision. Treating a changed stored decision as an immediate authority change would be unsafe and inaccurate.

Value

Authenticated Web clients can explain trusted, explicitly denied, restricted, and unknown states while showing when a Session refresh is required for a changed Pi decision to take effect.

Approach

  • Add a pure Trust projection that keeps Pi ProjectTrustStore and the active Session SettingsManager as separate facts.
  • Report canonical workspace, presence of trust-gated project resources, stored trusted/denied/undecided decision, active Session trust, derived state, and refresh-required evidence.
  • Read all facts from Pi-owned APIs; do not persist a Web permission policy.
  • Fail closed to unknown when the workspace is unbound or Pi facts cannot be read.
  • Expose authenticated GET /api/trust.

This is distinct from #360 compact snapshot state. It adds no trust-changing action or browser confirmation flow.

Validation

  • bun run check
  • bun run test: 1244 passed, 0 failed, 1 skipped; Vitest 30 passed
  • focused Trust, Pi runtime, and Web Host tests: 42 passed
  • git diff --check

Impact

  • User-visible behavior: authenticated API consumers can inspect the active Trust boundary; no UI changes.
  • Model-visible context/tools: none.
  • Runtime/lifecycle: read-only Pi ProjectTrustStore and SettingsManager inspection.
  • Persisted config/data: none.
  • Compatibility/risk: additive optional controller method and endpoint; unavailable integrations return an explicit 501 response.

Related to #343.

@testikun

testikun commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

CI context: both Linux Node jobs reach the pre-existing packed standalone Web CLI smoke, install the tarball, and then the server exits before announcing its origin (kill: No such process). Windows and the other checks pass. This matches the independently reproduced fresh-install peer-dependency failure tracked in #328, where npm selects Pi 0.85.0 and @earendil-works/pi-server cannot be resolved. Evidence: #328 (comment)

This PR does not change package metadata, CLI startup, or peer-dependency resolution. Its local check, focused tests, full Node suite, and Vitest suite pass as recorded in the PR body.

@tt-a1i tt-a1i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

#360 完整,差一个真实 store 测试

fail-closed unknown、stored vs session 分开、refreshRequired、没有写路径,这些都对。#360 把 restricted/undecided 压成 untrusted,请用这份。

应修:getProjectTrustStatus() 只在 host 测试里 mock controller,没有对过真实 ProjectTrustStore。请补一条。

CI 红是共享打包 Web 冒烟,不当成本 diff 的缺陷。

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.

2 participants