Skip to content

feat(setup): report optional-scope impacts instead of scope names alone - #226

Merged
eddiearc merged 2 commits into
eddiearc:mainfrom
itswl:feat/setup-optional-scope-impact
Sep 14, 2026
Merged

eddiearc merged 2 commits into
eddiearc:mainfrom
itswl:feat/setup-optional-scope-impact

Conversation

@itswl

@itswl itswl commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

What

Setup's scope reconciliation already lists which optional scopes were not granted (#211), but not what each gap costs. On a real machine that meant discovering the gaps only from the daemon log: a missing im:chat* surfaced as 成员表拉取失败, drive:drive as a failed document-comment subscription, admin:app.visibility as a failed visibility update. Filed as #225.

Change

  • src/setup/tenant-scope-grant.ts: missingOptionalScopeImpacts() groups missing optional scopes by the capability they degrade — chat info/members, chat management, document comments, visibility, employee-id signature, message search, base messaging — and falls back to a 其他权限 line for anything unbucketed, so no requested scope is silently dropped.
  • src/setup/bot-register.ts: the non-blocking optional-scope notice now prints those impact lines. The required-scope fail-closed gate and the console recovery link are unchanged.
  • Tests: test/unit/setup/tenant-scope-impact.test.mjs (grouping, declaration order, empty input, unbucketed fallback) and test/integration/setup/setup-optional-scope-report.test.mjs (required granted + every optional missing → setup completes, and the output carries the impact lines and the console link; the fixture stubs globalThis.fetch so the test stays offline).

Resulting output sketch:

Tenant scopes 对账:必需未授予=无;可选未授予=im:message, …, im:chat.members:read, …
! 可选权限未授予,setup 可继续;未授予项对应的能力不可用或降级:
  - 群与成员信息(成员姓名/群名解析):im:chat:readonly, im:chat.group_info:readonly, im:chat.members:read
  - 云文档评论事件与回复:drive:drive, docs:document.comment:read, docs:document.comment:create
  - 应用可用范围自动设为全员可见:admin:app.visibility
  …

Validation

  • bun test test/unit/setup/tenant-scope-impact.test.mjs test/integration/setup/setup-optional-scope-report.test.mjs → 3 pass / 0 fail
  • bun test test/unit/setup/ test/unit/app/setup-cli.test.mjs test/integration/setup/ → 78 pass / 1 skip / 1 fail. The failure is the known environmental setup-single-root clean-build test (it builds inside bun's 5 s test timeout; a clean build measures ~11.4 s on this machine) and is unrelated to this change.
  • bun run build ✅ · bun run typecheck ✅ · bun run licenses:check ✅ · bun run publication:check:tree
  • bun run test:unit → 894 pass / 1 skip / 4 fail on a machine with three other agents' daemons running:
    • three-Agent live acceptance … — known pre-existing environmental failure (fails on unmodified main here too);
    • Agent CLI process consumes native-shaped Codex, Claude, and Pi directory fixtures and a live reclaim guard is never stolen while its owner protects stale-lock recovery — both reproduce identically on unmodified main in the same session (7.0 s / 11.4 s against their 10 s budget), i.e. load-sensitive process/timing tests;
    • local control keeps upsert ID idempotency … — passes in isolation.
      None of the four touch this change.

Lands ahead of maintainer alignment on #225 — happy to adjust the groupings, the wording, or split out the runtime-side (status/agents) visibility as a follow-up.

Fixes #225

🤖 Generated with Claude Code

@eddiearc eddiearc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

MERGE-WITH-NITS(Fable 5.1 审合)— 文案对齐后合

可选权限从「只有名字」变成「能力影响」,必需 scope 门禁不变,方向对。「其他权限」fallback 避免漏报。

请补:1) grant-scopes.ts 旧提示行也走同一套 impact 映射;2) Owner 确认各 capability 文案(尤其 employee_id 标签);3) im:chat 不在 TENANT_SCOPES,属死条目。缺 version bump。与 #222 同改 bot-register,先 rebase/错开。

@eddiearc

Copy link
Copy Markdown
Owner

Maintainer follow-up — 缓合(独立 UX 批次)

方向可以,先别跟 runtime 修复绑在一起合

请小改后再叫我们看:

  1. 文案弱化:不要写成「能力不可用/降级」定论;改成「可能受限,实际以平台校验为准」。
  2. grant-scopes.ts 旧提示行也走同一套 impact 映射(或明确只在 bot-register 路径展示)。
  3. OPTIONAL_SCOPE_CAPABILITIES 里的 im:chat 若不在 TENANT_SCOPES,删掉或对齐,避免死条目。
  4. 表保持 display-only,不要演变成第二套能力权威。

相关:#225

@itswl
itswl force-pushed the feat/setup-optional-scope-impact branch from aa58d93 to 0d1090a Compare September 14, 2026 01:43
@itswl

itswl commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

四条已改完(head 更新为 0d1090a,已 rebase 到最新 main):

  1. 文案弱化! 可选权限未授予,setup 可继续;以下能力可能受限(实际以平台校验为准):——不再写"不可用/降级"定论。
  2. grant-scopes.ts 旧提示行已走同一套 impact 映射(原"相关能力仍不可用或未验证"替换为同一份分组列表)。
  3. 桶条目已与 TENANT_SCOPES 对账:无死条目——im:chatim:chat:create/updateim:chat.members:read/write_onlyim:chat:operate_as_ownerim:chat.group_info:readonly 等都在申请清单里;唯一未被桶覆盖的是 application:application:self_manage,归入"其他权限"一行。
  4. 保持 display-only:没有任何门禁或行为读取这张表,只用于输出。

验证:tenant-scope-impact + setup-optional-scope-report 两个测试文件 3 pass / 0 fail;build 通过。等你们安排独立 UX 批次时再看。

@eddiearc

Copy link
Copy Markdown
Owner

核对过 head 0d1090a 相对缓合四条:

  1. ✅ 文案已弱化为「可能受限(实际以平台校验为准)」
  2. grant-scopes.ts 已共用 missingOptionalScopeImpacts
  3. ✅ 桶条目与申请清单对账说明可接受(application:application:self_manage 走「其他权限」)
  4. ✅ 仍是 display-only,门禁未变

等 CI 全绿后,maintainer 侧倾向 APPROVE合入仍等 idan 明确 yes

@itswl

itswl commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

package.json 已按 Owner 政策补 bump(0.5.9 → 0.5.10,head 652b639),CI 已触发。

@itswl

itswl commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Windows gate 失败排查:CI 基础设施 403,非代码问题

Windows 11 x64 core and standalone gate 在 "Download exact Windows standalone build" 步骤就失败了:

##[error]Unable to download artifact(s): Failed to ListArtifacts: Received non-retryable error:
Failed request: (403) Forbidden: Error from intermediary with HTTP status code 403 "Forbidden"

是下载构建 artifact 被拒(GitHub Actions 基础设施抖动),测试根本没开跑;同一 run 的 source-checks 与 standalone artifact 均通过。烦请重跑该 job 一次。

itswl and others added 2 commits September 14, 2026 15:10
The scope reconciliation already listed which optional scopes were not
granted, but not what they cost: an im:chat* gap surfaces as
"成员表拉取失败" in the daemon log, drive:drive as missing document
comments, admin:app.visibility as a failed visibility update. Group the
missing optional scopes by the capability they degrade and print that
next to the scope names — in both the bot-register gate and the
grant-scopes reconciliation — keeping the freshness gate as the only
blocking requirement. The wording stays hedged ("可能受限,实际以平台
校验为准") and the table is display-only.

Bumps the package patch version (0.5.9 -> 0.5.10) per the Owner policy.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-authored-by: idan <eddiearc6@gmail.com>
@cursor
cursor Bot force-pushed the feat/setup-optional-scope-impact branch from 652b639 to 6263be6 Compare September 14, 2026 15:11
@eddiearc
eddiearc merged commit eeb3487 into eddiearc:main Sep 14, 2026
5 of 6 checks passed
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.

[Feature]: 缺可选权限时给出影响映射(哪项能力降级),而不只是 scope 名——0.5.7 上连提都不提

3 participants