Skip to content

feat: record Lark read identity, fall back on real document denials, and keep recovery in deferred captures - #105

Merged
qiansc merged 1 commit into
mainfrom
feat/v0.7.98
Nov 11, 2026
Merged

qiansc merged 1 commit into
mainfrom
feat/v0.7.98

Conversation

@qiansc

@qiansc qiansc commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Lark capture in bot mode did not fall back to the user when the bot could not open a document, and when capture could not acquire a document the warning said only "authorization required" without a way forward.

  • Real "cannot open this document" errors now trigger the bot → user fallback. The Docs API reports this as type: api, subtype: unknown, code: 3380004 on stderr; the read session only recognized authorization/permission_denied shapes, so CONTEXT_LARK_IDENTITY=bot never fell back on the real error.
  • The capture report records access. An optional access block (identity, fallback: {from: "bot", cause} for a bot → user fallback only, events) is written to capture-report.json. context status shows a fallback warning from the saved report (content only that user can see is now in the snapshot; later bot captures may not read it), so it stays visible after the capture finished. Reports written before this version remain valid.
  • Same-revision reuse respects identity. An unchanged revision is reused only when it was read by the same identity as the saved snapshot and nothing changed access during the read; otherwise it is captured in full so the new identity and resources are recorded. A document that keeps falling back to the same user reuses its user snapshot.
  • Deferred acquisition warnings keep their recovery. document.acquisition-unavailable now carries next, the redacted Lark error and any access events. A 3380004 body denial asks to have the document shared instead of suggesting to sign in again.
  • fetchFeishuDocSnapshot accepts an accessEvents collector so a host policy can record access changes it made during the read (for example adding the bot as a viewer).

Compatibility

  • Capture report: new optional access field; older reports parse unchanged.
  • context run capture:lark:* JSON result: new access field; the fallback diagnostic is now a warning: with the cause (was info:).
  • Deferred acquisition warning: new optional next, stderr, access_events fields.
  • Bot-mode users may now see documents captured as the user where capture previously failed.
  • No workflow, route or SDK contract changes.

Verification

  • New tests (each fails without the change): real 3380004 envelope triggers fallback; fallback recorded in report and visible in a later status read; identity-change and access-change disable same-revision reuse; repeated fallback reuses the user snapshot; report access parsing and old-report compatibility; deferred warning keeps Lark error and owner-sharing step.
  • Affected test files (Lark capture, identity, resources, snapshot bundle, availability, status): 151 pass.
  • The legacy auto user → bot switch is not recorded as a bot → user fallback (regression test).
  • tsc --noEmit, eslint on changed files (0 errors).
  • Real lark-cli 1.0.98 envelopes were recorded for the fixtures.

Checklist

  • bun run verify:full passes.
  • Lifecycle changes include route and recovery tests.
  • Published package metadata and local pack behavior were checked when affected.
  • English and Simplified Chinese user documentation remain behaviorally equivalent.
  • Runtime code remains compatible with Node.js 20+.
  • No generated output, secrets, private sources, or local workspaces are included.

🤖 Generated with Claude Code

…and keep recovery in deferred captures

- A bot that cannot open a document (Lark code 3380004) now falls back to the user in bot mode; the fallback only records bot → user.
- Capture reports record the read identity, why it fell back and access changes; status keeps showing a fallback, and same-revision reuse requires the same recorded access.
- Deferred acquisition warnings keep the next step, the Lark error and access events; a denied document asks to have it shared instead of signing in again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit ceb08ab into main Nov 11, 2026
2 checks passed
@qiansc qiansc mentioned this pull request Nov 11, 2026
5 of 6 tasks
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.

1 participant