Skip to content

Add Microsoft 365 actions, approvals, and delegated workflow execution - #1497

Merged
Paul Lizer (paullizer) merged 15 commits into
Developmentfrom
paullizer-sharepoint-file-sync
Sep 20, 2026
Merged

Paul Lizer (paullizer) merged 15 commits into
Developmentfrom
paullizer-sharepoint-file-sync

Conversation

@paullizer

@paullizer Paul Lizer (paullizer) commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add separate Microsoft 365 Calendar, Email, OneDrive, and SharePoint Online (SPO) actions with delegated access, live file RAG, and cloud-aware Copilot Retrieval/Graph selection. No PAYG, workspace file sync, or Azure AI Search ingestion is introduced.
  • Unify source-sharing, extended-analysis, and workflow Run as decisions across chat, Profile, Approvals, and notifications. Sharing covers retained evidence as well as answers; published copies remain governed by conversation access.
  • Add durable conversation evidence, staged analysis, approval-aware continuations, encrypted workflow connections, and claimed mail/calendar delivery. Revalidate capabilities and identities, preserve completed work, and prevent replay of uncertain side effects.
  • Preserve existing combined Graph action editing while blocking new creation, cloning, restoration, and settings-based resurrection. Update documentation and regressions; application version is 0.261.034.

Interactive reconnect (f5f25690): adds Profile > Settings > Microsoft 365 chat connection > Reconnect Microsoft 365 for chat, even when credentials already exist or no request is paused. Fresh state/nonce/PKCE sign-in replaces the cache only after same-account verification; failures preserve the old cache. Profile reconnect does not replay past requests or change workflow connections or sharing approvals. Graph bearer-token HTTP 401 responses now preserve scopes/source for the existing chat sign-in continuation. Policy denial, throttling, service/configuration failures, and expired temporary download links remain distinct.

Important unresolved retrieval configuration: read-only investigation of the latest screenshot identified model_context_unavailable, not expired Microsoft credentials. The selected gpt-5.6-terra catalog record has no declared context/output token limits. Reconnecting does not fix that separate model-budget issue; this change neither invents limits nor bypasses the safety bound. Details are in M365_CHAT_RECONNECT_RECOVERY_FIX.md.

Consent callback (98c4b0ab): accepts additional previously consented permissions in successful token responses while requiring every requested grant. The outbound scope allowlist, configured cloud matching, and narrow workflow authorization remain unchanged.

Connection onboarding (26e44a23): binds selected actions before kernel loading, offers Connect in chat before model execution when delegated access is missing, and resumes the original conversation. Reuses /getAToken, fixes HTTPS callbacks and exact stale-CSRF recovery, and uses source-level consent bundles with Commercial/Government/custom-cloud support.

Streaming and CodeQL (bdb668af, 1883af6e, c23e32c1): fixes unsupported Cosmos replacement arguments and async streaming context lifetime; removes public workflow diagnostics, protects historical projections, clarifies control flow, and removes the execution/connection import cycle. Four intentional Protocol/facade notes are documented and their review threads were answered/resolved without global suppression.

Target: Development in microsoft/simplechat.

Setup: interactive chat and Profile chat reconnect use /getAToken and the server-side login session, without Key Vault or a saved workflow connection. Unattended workflows separately require /api/m365/connections/callback, explicit Run as consent, and a dedicated Key Vault encryption key referenced by M365_WORKFLOW_TOKEN_KEY_SECRET_NAME. Bootstrap provisions m365_connections and m365_execution_runs with /user_id partitions. See docs/explanation/features/MICROSOFT_365_ACTIONS.md.

Deployment: 0.261.034 is committed and pushed for user-managed deployment. This session has not rebuilt/restarted the test app or changed tenant permissions/Key Vault credentials. The inspected deployment's workflow-only callback and encryption-key reference still require administrator setup for unattended workflows.

Linked issue

Refs #1493. Related sync/external-tab work in #954 and #956 remains separate.

Release Notes & Latest Features

  • New Feature
  • Bug Fix
  • UI Enhancement
  • Breaking Change
  • Internal only

Compatibility: no new combined Graph actions; workflows require an explicitly selected, consenting Run as account. Selecting Calendar or Email requests its supported operation permission bundle, shown by Microsoft before consent; disabled action capabilities and outgoing-delivery reviews still apply. Existing narrower connections are not silently upgraded.

Is this visible to end users?

  • Yes
  • No

Is this admin-facing (Admin Settings, governance, deployment, config)?

  • Yes
  • No

Should this become a Latest Feature card?

  • Yes
  • No
  • Already added

Screenshot needed for the card?

  • Yes
  • No
  • Attached

Version bump

  • application/single_app/config.py VERSION third segment bumped, or not needed because this is docs-only
  • deployers/version.txt bumped, or not needed because deployers/ was not changed

Application advanced from 0.261.028 through the feature/remediation fixes to 0.261.034. Latest patch adds interactive reconnect and Graph authentication recovery. No deployer files changed.

Testing / validation

  • Reconnect backend integration: 580 passed, 157 subtests passed. Focused optimized run: 201 passed, 107 subtests passed. Final entrypoint rerun: 78 passed, 107 subtests passed.
  • Real-module normal/optimized web/scheduler cold imports: 13 passed. Route policies: 12 checks passed. Documentation surface/site checks: 13 checks passed; regenerated inventory remains unchanged.
  • Isolated Azure Playwright-ready M365 UI suite: 98 passed in local Chromium, covering reconnect with/without cached credentials, source selection, independent workflow controls, callback/query cleanup without replay, errors, and Commercial/Government/custom authorities. JavaScript syntax and whitespace checks pass.
  • Real MSAL tests preserve old credentials on failed/wrong-account reconnect and publish only verified caches. Real Semantic Kernel tests preserve the exact sign-in wait/scopes and do not replay completed tools. Provider tests distinguish Graph 401 from 403/429/503, model errors, and expired download URLs.
  • Earlier consent-scope qualification: 268 passed, 149 subtests passed; optimized 86 passed, 130 subtests passed. Earlier onboarding: 559 passed, 114 subtests passed, plus 62 UI tests. Earlier streaming/Cosmos: 571 passed, 96 subtests passed, using real Cosmos SDK/RequestsTransport and Semantic Kernel streaming with external I/O isolated.
  • Earlier CodeQL analysis on c23e32c1 reduced 31 PR findings to four intentional notes. Workflows on bdb668af and 26e44a23 also passed. These are historical results, not a claim about CI on the latest head.

Live evidence: Azure telemetry and the existing shared browser reproduced the earlier missing-action/callback issues. The consent incident showed successful Microsoft token exchange followed by local scope rejection. For the latest screenshot, extracted diagnostic codes were model_context_unavailable and earlier invalid_query; a correlated Graph search returned 200. No live token bodies or document contents were retrieved for diagnosis, and temporary log downloads were removed.

Known pre-existing tests: three unchanged grounding tests have stale call-count/incomplete AST fixtures against original head b8a75418; an unchanged chat-reattach test asserts historical version 0.239.191 exactly. They were not edited to conceal failures.

Not performed: live end-to-end qualification of the newly deployed 0.261.034 reconnect flow or live Government/custom-cloud, Copilot, and Key Vault qualification. The user handles deployment before live retesting. Reconnect does not resolve the separate missing model-budget configuration.

Documentation

  • Release notes updated, or not needed
  • Feature documentation updated, or not needed
  • Fix documentation updated, or not needed

Feature, source-action, Profile, workflow, admin, and chat-control documentation is updated. Versioned fixes cover CodeQL, Cosmos/streaming, onboarding, consent-scope responses, and M365_CHAT_RECONNECT_RECOVERY_FIX.md. Release notes remain unchanged per the prior request; a Latest Feature card is not included.

Security checklist

  • New Flask routes include @swagger_route(security=get_auth_security()) and Blueprint/user guards
  • Settings sent to non-admin frontends use sanitize_settings_for_user()
  • Browser runtime assets are local; no CDN JavaScript
  • No credentials, secrets, or local artifacts are committed
  • Interactive consent binds current user, tenant, state, nonce, PKCE, sources, and a server-owned callback
  • Reconnect status reveals no cache/token material and is not presented as remote health
  • Profile repair never replays a request or changes workflow grants; extra token scopes do not expand application authorization

Introduce separate Calendar, Email, OneDrive, and SharePoint Online actions with delegated retrieval, source-sharing approvals, retained conversation evidence, and explicit workflow Run as authorization.

Retire new combined Graph actions, enforce live capability checks, add cloud-aware retrieval and durable continuation safeguards, and document setup for version 0.261.029.

Refs #1493

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@github-advanced-security github-advanced-security AI 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.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

…indings

Remove provider exception text from public alert decisions and historical run/notification projections. Preserve waiting responses, exception identity, budget retry behavior, and expected Cosmos outcomes. Add regression coverage and bump the app to 0.261.030. Refs #1493; CodeQL remediation for #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move immutable context and fingerprint primitives below execution and connection owners. Inject the live Run as validator from both web and scheduler bootstrap, fail closed before credentials when unconfigured, and preserve pre/post-refresh checks. Add cold-import and revocation coverage and document the four intentional CodeQL findings. Refs #1493; remediation for #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread application/single_app/conversation_memory_storage.py
Comment thread application/single_app/conversation_memory_storage.py
Comment thread application/single_app/conversation_memory_storage.py
Comment thread application/single_app/functions_conversation_memory.py
Record the passing implementation-head CodeQL analysis, the concrete Protocol implementations and public exception consumers, and individual replies resolving all four remaining Advanced Security review threads. Documentation only; no runtime or version change. Refs #1493 and #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove unsupported partition_key arguments from conditional Cosmos replacements while preserving body-derived partition routing and ETag checks. Keep async agent stream pulls and cleanup in one isolated context, preserve approval/sign-in handling, and log terminal failures safely. Add real-SDK and Semantic Kernel regressions and bump the application to 0.261.031. Refs #1493; follow-up for #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bind the selected source actions before kernel creation and pause for explicit delegated consent before model execution. Add session-bound PKCE sign-in through the registered login callback, resume the original chat, fix HTTPS callback construction and stale-CSRF recovery, and simplify Profile to source-level permission bundles. Preserve workflow Run as, action capabilities, and Commercial/Government/custom-cloud routing. Add backend and browser regressions; bump the app to 0.261.032. Refs #1493 and #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Validate that token responses contain the requested grants without applying the outbound scope allowlist or request-count limit to extra prior consent. Share the check across chat and workflow callbacks, retain cloud-qualified matching and narrow workflow authorization, and add real-MSAL regressions for Commercial, Government, and custom clouds. Bump the app to 0.261.033 and document the observed post-consent failure. Refs #1493 and #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Provide a separate Profile chat reconnect using the current user's verified PKCE flow without requiring a pending request or workflow configuration. Preserve the old cache on failure, avoid replay from Profile, and pass exact source scopes from Graph 401 responses into chat continuation. Keep policy, model-budget, service, and download-link errors distinct. Add backend/UI coverage and bump the app to 0.261.034. Refs #1493 and #1497.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Account for all 75 models with source-backed capacities, scoped profiles, explicit unknowns, and independent per-field resolution. Advance the application to 0.261.035.

Refs #1493

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Separate model capacity from Response Length, preserve inherited metadata across editor saves, and expose safe validation errors without leaking credentials.

Refs #1493

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Carry immutable budget metadata into actual Semantic Kernel requests, M365 streaming and resumed execution, retained-file analysis, and compatible tabular batching. Preserve provider-specific accounting and reject mismatched or oversized requests with actionable errors.

Add real-catalog, real-agent, SDK wire-payload, context-isolation, and no-replay regressions. Refs #1493.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve MCP remote-only authorization and scoped legacy management alongside M365 source validation, durable Graph migration receipts, and model-budget integration. Resolve eight conflicts, add cross-feature regressions, and advance the application to 0.261.036.

Refs #1493, #1497

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread application/single_app/functions_m365_agent_continuation.py Fixed
Comment thread application/single_app/route_backend_plugins.py Fixed
Use explicit discard bindings for unused preparation results and an explicit absent-record state for Cosmos 404 handling. Preserve effective budgets and legacy action rejection, with focused normal/optimized regressions. Advance application version to 0.261.037.

Refs #1493, #1497; CodeQL alerts 2781 and 2748.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add authoritative live/history cards for manual and delayed mail/calendar actions, shared-viewer projections, owner review and reconnect recovery. Unify conditional send/cancel claims and safe lifecycle cleanup; document retained draft behavior and recovery semantics. Bump application version to 0.261.038.

Refs #1493

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread application/single_app/route_backend_control_center.py Fixed
Address review comment 4055671401 by preserving the document cleanup call without assigning its ignored return value. Add focused cleanup-order and audit regressions, document the disposition, and bump the app to 0.261.039.

Refs #1493

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@paullizer
Paul Lizer (paullizer) merged commit f1be106 into Development Sep 20, 2026
12 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.

2 participants