Skip to content

feat(meetings): read the user's calendar over CalDAV, Google and Microsoft 365 - #2190

Closed
kaizawa97 wants to merge 1 commit into
kirodotdev:mainfrom
kaizawa97:pr/meetings-calendar-providers
Closed

kaizawa97 wants to merge 1 commit into
kirodotdev:mainfrom
kaizawa97:pr/meetings-calendar-providers

Conversation

@kaizawa97

@kaizawa97 kaizawa97 commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Meetings reads the user's schedule from their existing CalDAV, Google or Microsoft 365 calendar, so upcoming meetings no longer have to be created by hand.

Meetings had to be created by hand. The app never knew what was already scheduled, so being ready for the meeting that is about to start was left to the user every time. There was no way to connect a calendar at all: no provider, no credential store, and no OAuth handshake for the two providers that need one.

Why it matters

Every downstream feature is gated on knowing the schedule. Without it the app cannot pre-create a meeting, name it, attach attendees or start on time. It also blocks the calendar settings UI (#8081), which has nothing to render until a provider exists.

Not a goal

What changed (motivation → approach → change)

The app can now read events from three real calendar providers, and their credentials are kept where no agent can reach them.

Area Change
Providers providers/calendar.py adds CalDAV, Google Calendar and Microsoft 365 behind the existing CalendarProvider interface, next to none and ics. Every event goes through one build_event(), so redaction and the all-day flag are applied once for all providers. Remote fetches reuse main's vetted, address-pinned fetch path; CalDAV XML is parsed with defusedxml and DTDs refused.
Credentials credentials.py stores the CalDAV password and OAuth tokens in <crew-home>/meetings-credentials/, a top-level data-home directory.
OAuth oauth.py runs the authorization-code flow with a single-use random state, derives the redirect URI from the request's own origin (kept https behind a local TLS-terminating proxy through dashboard.origin.is_https_request), and surfaces the provider's error_description on a refused token request. Token requests follow no redirect, so a client secret cannot be sent to another host. Tokens are stored only while the connection they were started for still exists: a refresh checks the refresh token it used, and a sign-in checks the client id and a generation that Disconnect advances, so a Disconnect stays disconnected.
Paging Microsoft Graph's @odata.nextLink comes from the response body, so it is followed only when its origin (scheme, host, port) is the Graph endpoint's; the access token never goes anywhere else.
Routes routes/calendar.py adds credential save/forget and OAuth start/callback. Save, forget and start are owner-only (require_owner).

Why the credential directory is top-level: a refresh token is a live bearer credential that outlives any session. A directory nested under workspace/ would be created after a sandbox starts, and the sandbox mask only covers directories that exist at spawn. As a direct child of the data home it is precreated before every spawn and masked in every sandbox mode (sandbox.py), and file tools refuse it (security/paths.py).

The OAuth callback is not owner-gated. Its authority is the unguessable state minted by the owner-gated start. A cookie gate would refuse the provider redirect on surfaces that authenticate by token. The state is compared as bytes, so a non-ASCII value is an ordinary audited rejection rather than a 500.

The module and security specs (meetings.md, security.md) describe the new routes, providers, credential location and OAuth custody.

Backwards compatibility

Compatible: every route, file and provider here is new; the one existing contract touched, the Meetings owner gate, only adds routes to it.

Tests

  • test_meetings_providers.py — CalDAV/Google/Microsoft parsing, all-day detection for Google date-only starts and Graph isAllDay, redaction through build_event, and a Graph nextLink on another origin refused (including an explicit default port, host case and userinfo tricks).
  • test_meetings_oauth.py — state, redirect URI, token exchange and refresh, a 400 error body surfaced, a token-less body refused, a mismatched non-ASCII state refused, a refresh or a sign-in suspended across a Disconnect (or a reconnect with the same client id) not recreating the credentials, a replaced refresh token not overwritten, and a token request that is redirected refused.
  • test_meetings_calendar_routes.py — the HTTP surface, the store's location, the redirect URI behind a forwarded https, and a non-ASCII callback state rejected and audited.
  • test_meetings_owner_gate.py — save, forget and OAuth start refuse non-owners and app tokens.
  • test_sandbox_governance_mask.py — meetings-credentials is masked in every mode and precreated before the first save; the ratchets in test_sandbox_protected_name_holds.py and test_security_gate_liveness.py are re-measured for the new leaf.

Manual verification

OAuth against live Google and Microsoft tenants is not verified here: it needs registered client credentials for each. The handshake is covered at the protocol level, and redirect-URI derivation is tested against non-default ports and both loopback spellings.

Related Issues

no linked issue: part of bringing up the Meetings app's calendar support; the UI lands in #8081, which is stacked on this PR.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@kaizawa97
kaizawa97 requested a review from a team August 8, 2026 08:53
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Aug 8, 2026
@kaizawa97
kaizawa97 force-pushed the pr/meetings-calendar-providers branch from ecd492a to 28351ac Compare August 13, 2026 06:16
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Aug 13, 2026
@kaizawa97
kaizawa97 force-pushed the pr/meetings-calendar-providers branch from 28351ac to 7035762 Compare August 13, 2026 07:44
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🔴 BLOCK (blocking)

Design-level review of 8dc1f9fe8041e5c4194b23559ddcc42b530deb0a via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: BLOCK

Live Google/Microsoft OAuth is unverified end-to-end; the headline connect path rests on provider-side assumptions no test or human has exercised.

Blockers

Unverified provider handshake for the feature's core path.
The description states "OAuth against live Google and Microsoft tenants is not verified here: it needs registered client credentials for each" — so the one flow CI cannot exercise (real consent → redirect back → token exchange) has never run, and it is exactly where these providers are strictest: Entra's loopback redirect matching is spelling- and path-sensitive, a Google Desktop client's token exchange still demands the pasted client_secret, and a dashboard reached on a non-loopback host derives an http:// redirect URI both providers refuse outright. If any assumption is wrong, every user's connect attempt fails at the provider with an error the app cannot remediate, and #8081's UI stacks on a flow never proven to work.
Fix: register one free client with each provider and run connect + one sync against a live tenant; record the outcome in the PR.
Clears when: the PR records a successful live connect and calendar sync against a real Google and a real Microsoft registration (or documents the concrete provider responses observed).

Watch

The CalDAV credential is fenced at rest but not bound to a destination: calendar.source lives in the app's agent-reachable config.json (owner-gated only on the HTTP surface), and the fetch sends auth_headers={"Authorization": _basic_auth(...)} to whatever origin that URL names — so a prompt-injected agent rewriting source has the background poller deliver the user's CalDAV password to any public https host, defeating the triple-fenced store for that provider. (OAuth is unaffected: bearer tokens ride constant endpoints plus the nextLink origin check.)
Clears when: the CalDAV credential is bound at save time to the collection origin it was entered for (refusing a fetch whose configured source origin differs), or the caldav source moves into the owner-gated credential store.

[DESIGN-REVIEWED] 8dc1f9f

Description read

[DESCRIPTION-READ] b3325194356eb1b3b32edbe7379074ef019418d6ac82209799be271b90fd4b24

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — 🔴 changes requested (blocking)

Reviewed 8dc1f9fe8041e5c4194b23559ddcc42b530deb0a via the fork AI-review pipeline; updated in place on each push.

Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging.

BLOCKING -- src/kiro_crew/apps/builtins/meetings/backend/providers/calendar.py:1376 -- calendar overflow is silently discarded
if len(by_id) >= k.MAX_CALENDAR_EVENTS: break / return events[: k.MAX_CALENDAR_EVENTS]
More than 500 events -> provider truncation -> successful sync silently omits meetings.
Anchor: a-bound-bounds-every-field-it-retains
Fix: Count discarded events and report truncation once per sync.
[BLOCK-MERGE] 8dc1f9f
[GPT-REVIEWED] 8dc1f9f

Adjudication (Opus 5) — is blocking on each finding proportionate?

Harm rung: MEDIUM — a truncated CalDAV sync returns fewer meetings than the collection holds, and the list/poller cannot tell a truncated tail from events that were never on the calendar.
Conditions confirmed: the cap-and-discard is if len(by_id) >= k.MAX_CALENDAR_EVENTS: break followed by return events[: k.MAX_CALENDAR_EVENTS] (new _events_from_multistatus, patch hunk @@ -992,6 +1196,620 @@, new calendar.py:1376) with MAX_CALENDAR_EVENTS = 500 (src/kiro_crew/apps/builtins/meetings/backend/constants.py:47); no overflow count is produced or surfaced, and the downstream cache applies the same slice again silently (src/kiro_crew/apps/builtins/meetings/backend/store.py:992). The anchored rule a-bound-bounds-every-field-it-retains (AUTOSDE.yaml:972) carries blocking: true and requires at AUTOSDE.yaml:999 that "overflow is COUNTED and said out loud once per snapshot", giving the reason that a truncated tail otherwise reads exactly like a population that never named those items — precisely this finding.
Remedy cost is not weighed here: the rule's blocking: true flag is authoritative and outranks the weighing, so the fix (a discarded-count returned with the event list and stated once per sync) stands as required regardless of its threading cost.

[ADJUDICATION] 8dc1f9f total=1 uphold=1 downgrade=0
UPHOLD F1 src/kiro_crew/apps/builtins/meetings/backend/providers/calendar.py:1376 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 8dc1f9f

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed 8dc1f9fe8041e5c4194b23559ddcc42b530deb0a via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8dc1f9f

@kaizawa97
kaizawa97 force-pushed the pr/meetings-calendar-providers branch from 7035762 to 5d22109 Compare August 13, 2026 09:17
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Aug 13, 2026
@iamwhatever iamwhatever added the needs-pr-triage PR scanner: awaiting automated triage label Aug 18, 2026
@bolichen97 bolichen97 added drive-to-green PR claimed by drive-to-green pipeline and removed needs-pr-triage PR scanner: awaiting automated triage labels Aug 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: bolichen97]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author.

Assessment: GPT 5.6 flagged 3 concrete bugs (credential temp-file path gate bypass, concurrent-write race in credentials store, read-failure causing credential loss). The only CI test failure (test_subagent_scale.py::TestWaveDigest) is a pre-existing main flake unrelated to this PR. Fix plan: address the 3 GPT BLOCKING findings, rebase onto latest main, re-run CI.

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

@bolichen97
bolichen97 force-pushed the pr/meetings-calendar-providers branch from 5d22109 to 269e4a1 Compare August 18, 2026 11:52
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Aug 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: bolichen97]

Drive-to-green pass on this PR (original work by @kaizawa97, authorship preserved; head is now 269e4a107):

1. Rebased onto current main (was based on a commit from 08-13). This also absorbs the fix for the test_subagent_scale.py wave-digest flake (#3281) that failed Backend Tests shards 3.10/4 and 3.12/4 on the previous head — those failures were a pre-existing main flake, not this PR.

2. Re: the GPT 5.6 blocking review of 7035762d — that review predates the author's own amend (5d221090, pushed 09:17 UTC the same morning), which already addressed the findings: the sensitive-path gate covers the whole workspace/meetings directory (UUID temp siblings included), the credential read-modify-write is serialized under _STORE_LOCK, and unreadable-store reads raise _StoreUnreadable on the write path instead of silently rebuilding from {}. Stage-1 CI failing on the flake meant no review bot ever re-ran on that head.

3. One new fix (local GPT 5.6 review of the rebased head): the invalid/expired/forged-state rejection in handle_oauth_callback returned early without a SEL audit record — the one exit path of that handler that didn't audit, and it is precisely the anti-forgery check firing. Added audit("meetings.calendar_oauth_callback", "unknown", outcome="error", error="invalid_or_expired_state") before the return, and extended test_a_forged_callback_with_no_flow_is_refused to lock the record in. Only constant strings are logged — no query-string input is echoed into the audit trail.

4. PR description updated to remove the stale claim that defusedxml was avoided — the code (correctly) uses defusedxml with forbid_dtd=True and declares it in setup.cfg; the description now matches.

Local gates on the pushed head: isort / flake8 / mypy clean, full pytest 56380 passed. Opus 4.8 local review: NO-BLOCKING (SSRF vetting, redirect auth-drop, gate coverage, and Graph timezone handling all verified sound).

@bolichen97

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: bolichen97] — dispositions for the GPT 5.6 blocking review of 7035762d (superseded by the author's amend 5d221090 and the rebase 269e4a107):

  • Credential temp files bypass the sensitive-path gate (security.py) — fixed

The denylist entry is now the directory workspace/meetings (not the exact leaf), and _path_in_home_dirs prefix-matches children, so calendar-credentials.json.<uuid>.tmp siblings are denied. Locked in by the gate's directory-matching semantics shared with trust/profiles.

  • Concurrent credential PUT vs OAuth refresh lost-update (credentials.py) — fixed

Both write_for and clear_for run their whole read-modify-write under the module-level _STORE_LOCK (threading.Lock, correct for asyncio.to_thread workers).

  • except (OSError, ValueError): return {} erases credentials on corruption (credentials.py) — fixed

The write path calls _load_sync, which raises _StoreUnreadable on any read/parse failure other than FileNotFoundError; only the display path (_read_sync) degrades to empty, so a merge never rebuilds the file from a partial view.

  • New in 269e4a107 — the invalid-state OAuth callback rejection now writes a SEL audit record (fixed a local-review finding of the same class; see the drive-to-green comment above).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Aug 18, 2026
auto-merge was automatically disabled September 30, 2026 09:37

Head branch was pushed to by a user without write access

@kaizawa97
kaizawa97 force-pushed the pr/meetings-calendar-providers branch from ca08283 to e1c5a0c Compare September 30, 2026 09:38
@kaizawa97
kaizawa97 requested a review from a team as a code owner September 30, 2026 09:38
@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • The new secret leaf has no sandbox disposition span=42152940ca04

fixed in e1c5a0c.
The store moved to the top-level data-home leaf meetings-credentials, listed in _CREW_SECRET_LEAVES, sandbox._CREW_HIDDEN_LEAVES and sandbox._CREW_PRECREATE_HIDDEN_DIR_LEAVES.
It is masked in every sandbox mode and precreated before every spawn, so a namespace started before the first save cannot see it.
test_sandbox_governance_mask.py carries it in MASKED; TestTheMeetingsCredentialStoreIsMaskedBeforeItsFirstSave proves the precreate.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • meetings.md and the security spec are stale span=a9f68189aa82

fixed in e1c5a0c.
meetings.md lists the new routes, the five providers, the credential data layout and a Calendar credentials section.
security.md gains the meetings-credentials keystone-directory bullet. docs-lint passes.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • OAuth custody decision is undocumented span=6a9369a76a6c

fixed in e1c5a0c.
meetings.md gains an OAuth custody section: the token is consumed by the gateway's own app backend (the poller syncs with no agent session), which kiro-cli's grant store is neither reachable from nor scoped to.
It states that a token consumed by an agent session should use connections instead.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Extract fetch_vetted to dissolve an import cycle span=214431dbf094

rebutted in e1c5a0c.
There is no two-way cycle: oauth.py imports providers.calendar at module scope, and only providers.calendar reaches oauth lazily inside client factories and fetch().
Moving fetch_vetted would relocate a registered redaction-sink neighbour without fixing a defect; the stale comment in routes/calendar.py that claimed a cycle is corrected.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Credential file fence is tool-gate only span=08cf8d7834ec

fixed in e1c5a0c.
The fence is no longer tool-gate only: meetings-credentials carries the HIDDEN disposition in sandbox.py and is precreated before spawn, so a spawned shell's open() cannot reach it either.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • workspace/meetings has no OS-sandbox disposition span=1b59b76b1947

fixed in e1c5a0c.
The store is no longer under workspace/; the top-level meetings-credentials leaf is HIDDEN and precreated in sandbox.py and pinned in the MASKED table.
test_sandbox_governance_mask.py passes on POSIX in all three modes.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • The description credits base-tree hardening to this diff span=f400278c6815

fixed in e1c5a0c.
The PR description is rewritten from the current diff: the vet_unfurl_url delegation, the bypass table and the setup.cfg defusedxml declaration are pre-existing base state and are no longer claimed.
It now says only that remote fetches reuse main's vetted, address-pinned fetch path.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Calendar credentials remain readable to agent subprocesses span=263f056987ad

fixed in e1c5a0c.
The directory moved to meetings-credentials and is in the sandbox hidden and precreated-hidden leaf sets, as the finding prescribed.
A legacy file at workspace/meetings/ is moved, never copied, through no-follow directory descriptors, so a planted link at the file or its parent is not followed.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Cloud providers discard all-day semantics span=180cb23267a1

fixed in e1c5a0c.
Google derives the flag from a date-only start and Graph passes isAllDay is True; both reach build_event(all_day=...).
Tests pin both providers and the non-boolean negative case.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Three implementations ship contradicts five factories span=ce02a6fc8e74

fixed in e1c5a0c.
The module docstring now says five implementations and names Google and Microsoft.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Rewritten wholesale on the next write contradicts write refusal span=1911488f13be

fixed in e1c5a0c.
The _read_sync docstring now states the store is not self-healing: writes refuse while it is unreadable, so manual repair or replacement is required.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Token-endpoint HTTP 400 never reaches error_description span=aa459fea0ed8

fixed in e1c5a0c.
_post_token accepts 200 and 400, parses the RFC 6749 section 5.2 error body and surfaces error_description; a 400 with neither error nor access_token is refused, not stored.
Three tests cover the 400 body, the token-less 400 and a 401 still failing.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🟡 CONCERNS

Which legitimate operations does 8dc1f9fe8041e5c4194b23559ddcc42b530deb0a newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

the reviewer's own judgement; no confirmed regression

All halves of the tightening are confirmed to live outside the three adjudicated tiers; candidates.json is written with 13 boundary rows. Emitting the review.

Scope-Verdict: CONCERNS

TIGHTENING: The crew data-home keystone floor and the agent-sandbox bind mask each gained the top-level leaf meetings-credentials — _CREW_SECRET_LEAVES in src/kiro_crew/security/paths.py (expanded under both .kiro/crew and legacy .kirocrew prefixes into the is_sensitive_path read+write fence) and _CREW_HIDDEN_LEAVES plus _CREW_PRECREATE_HIDDEN_DIR_LEAVES in src/kiro_crew/sandbox.py. The one threat it refuses: the agent reading or writing the Meetings calendar credential store — per the hunk, "calendar-credentials.json in it holds a CalDAV password and the Google / Microsoft 365 OAuth refresh + access tokens", "masked here so a spawned command's open(), which never routes through that gate, cannot read a refresh token that stays valid until revoked."

ADJUDICATED: 13 candidates, 0 confirmed newly-refused
No confirmed regressions were handed to this review; the adjudication legs classify the submitted rows through the three tiers the composite declares (sensitive-bash, exfil, deny-rules), and the diff modifies none of those tiers, so the adjudicated half of this change is expected clean. The candidates were nevertheless written at the boundary: the fenced spelling meetings-credentials appearing as command DATA (grep/git grep/findstr over this repo's own source), the new test files run by name, reads of the benign siblings one token off the fenced store (calendar-cache.json in the app data tree, config.json in the exact parent directory the new leaf joins), and listings of both parent directories.

PLATFORM COVERAGE: Candidates were written in posix spellings (~-anchored paths, / separators, .venv/bin/python, grep/ls/cat) and windows spellings (%USERPROFILE%, \ separators, .venv\Scripts\python.exe, findstr/type) — paired for every operation that carries a path or executable name; no any rows carry either. This covers the diff's two platform assumptions: the leaf spec is authored with POSIX separators and re-joined per host by _leaf_segments, so the Windows-separator reads beside the fenced leaf are the spellings where an anchoring mistake would surface; and the sandbox bind-mask half exists only on Linux, so on Windows and macOS the path fence is the only layer — the sibling reads probe its boundary in both spellings. One platform question no shell candidate can answer: the Linux bind-mask itself (a mount-namespace view, not a tool-gate decision) — named below. Per-leg verdicts are the deterministic fold's to report, not this review's.

UNADJUDICATED: The entire tightening lives in guards the classifier does not adjudicate, which is why the verdict is CONCERNS rather than PASS despite an expected-empty confirmed set:

  1. The file-tool path fence (_CREW_SECRET_LEAVES → _SENSITIVE_HOME_DIRS → sensitive_path_refusal/is_sensitive_path, src/kiro_crew/security/paths.py:212,864-866). Call path: hooks.on_tool_call runs sensitive_path_refusal on every normalized tool title and on every target_paths(raw_params) path of file read/edit tools (src/kiro_crew/hooks.py:1053, hooks.py:1094-1097); the same gate backs validate_file_path, dashboard file I/O, and knowledge indexing. The deny composite the harness runs deliberately has no path tier (scripts/deny_diff.py:126-134: "No path tier: the gate reads a PATH there and a shell command is command text"), so no verdict exists for this half. Candidate legitimate inputs I would have submitted to a path-fence adjudicator: fs_read of ~/.kiro/crew/config.json and of ~/.kiro/crew/apps/meetings/data/calendar-cache.json (siblings one directory-token off the fenced leaf, in both crew-home prefixes); fs_read of a user workspace file whose basename contains the leaf string (e.g. a design note meetings-credentials.md in this repo's docs tree) to confirm the entry stays home-anchored and is not basename-matched; a directory listing of the crew home itself; and the Windows/casefolded spellings of each (_path_in_home_dirs matches casefolded, resolved and lexical forms). Reading the matcher, the entry is exact-or-os.sep-prefix under the two anchored prefixes, so I can argue — but not confirm — that none of these regress.

  2. The OS sandbox bind-mask and pre-creation (sandbox._CREW_HIDDEN_LEAVES, sandbox._CREW_PRECREATE_HIDDEN_DIR_LEAVES). Call path: sandbox spawn materializes <crew-home>/meetings-credentials before the namespace is built (_materialize_maskable_dirs) and bind-masks it in every mode, so a spawned command's open() under the leaf sees the mask. This is a runtime mount-namespace view on Linux, not a tool-call decision — nothing the shell classifier settles. Candidate legitimate inputs, in prose: the Meetings backend's own first credential save into a directory the spawn has already pre-created (the hunk states the backend "tolerates finding the directory already present and empty", and the PR's tests cover it); any in-sandbox reader of the store (the hunk asserts there is none — the gateway-side meetings/backend/credentials.py opens it directly, so unlike md-notebook no carve-out is needed); and an agent shell listing ~/.kiro/crew, which must keep succeeding with the leaf masked rather than failing on a broken mount point.

Neither gap is a demonstrated regression — the narrow entry shape and the no-in-sandbox-reader design both read as correctly scoped — but "no confirmed regressions" over guards nothing could classify is coverage this lane must not report as a pass.

[SCOPE-REVIEWED] 8dc1f9f

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 8 classified, 0 newly refused, 8 still allowed.
  • ubuntu-latest (platform posix): 8 classified, 0 newly refused, 8 still allowed.
  • windows-latest (platform windows): 5 classified, 0 newly refused, 5 still allowed.

No candidate flipped from allowed to refused.

…osoft 365

Meetings had to be created by hand, so the app never knew what was already
scheduled. This adds calendar providers -- CalDAV, Google Calendar and
Microsoft 365 -- behind the existing `CalendarProvider` seam, plus the
credential store and OAuth handshake they need. Five providers ship:
`none`, `ics`, `caldav`, `google`, `microsoft`.

Credential store (`backend/credentials.py`)

Credentials live in a TOP-LEVEL leaf of the crew data home,
`<crew-home>/meetings-credentials/calendar-credentials.json`. Not under
`app_data_dir("meetings")`, which `store.contain` opens to agent-supplied
paths; and not under `workspace/`, because the OS sandbox mask binds only
over a directory that exists at spawn time and only a direct child of the
data home can be materialised before every spawn (a nested leaf's
agent-writable parent could also be renamed out from under the mask). The
directory is registered in all three places at once: `_CREW_SECRET_LEAVES`
(agent file tools), `sandbox._CREW_HIDDEN_LEAVES` (spawned commands, every
mode) and `sandbox._CREW_PRECREATE_HIDDEN_DIR_LEAVES` (created empty at 0700
before each namespace spawn). The DIRECTORY is fenced, not the file, so the
`atomic_write` temp sibling is covered too. A store an earlier build left at
`workspace/meetings/calendar-credentials.json` is moved (never copied) on
the first read that finds the new location empty; only a regular file is
moved (lstat), and a reader that loses the move race to a concurrent reader
still reads the relocated store.

The store is read-modify-write under one lock, written through
`atomic_write(restrict_to_owner=True)` fail-closed, and refuses writes
while the file is unreadable or schema-invalid (display degrades to "not
connected"; the malformed file stays for a human to salvage). The path is
module state, not a request parameter. `GET /calendar/credentials`
publishes field names and booleans only; `PUT` is an allow-list per
provider, so a client cannot hand the app an `access_token`.

Fetch safety (`fetch_vetted`)

All outbound HTTP -- the `.ics` fetch, the CalDAV REPORT, both cloud APIs
and the OAuth token POST -- goes through one module-level gated fetch:
`link_unfurl.vet_unfurl_url` vets the address, DNS is pinned per hop,
redirects are followed manually so every hop is vetted, the body is
size-capped while streaming. `auth_headers` are dropped across a
cross-origin redirect, and a non-GET follows only the method-preserving
307/308. https-only implies port 443 at the vet boundary.

OAuth (`backend/oauth.py`)

Authorization-code + PKCE (S256), run by the gateway's app backend rather
than through kiro-cli's connections because the token is consumed by the
gateway itself (the calendar poller syncs with no agent session). Pending
flows live in memory with a TTL; `state` is compared in constant time and
the flow is consumed before the exchange; access tokens refresh early. The
token POST accepts HTTP 400 so an RFC 6749 error body (`invalid_grant`) is
read and its description surfaced. Every callback exit, including a forged
or expired `state`, writes a `meetings.calendar_oauth_callback` audit
record. The redirect URI derives from the request's own origin.

Events

Every provider funnels through `build_event`, which redacts displayed
fields once and derives `event_id` from the ORIGINAL uid; a uid the
redactor flags as credential-shaped switches to a digest-only id.
Google's date-only start and Graph's `isAllDay` set `all_day`. Graph
responses that ignore the UTC `Prefer` header are mapped through
`_WINDOWS_TO_IANA` before the UTC fallback. CalDAV Multi-Status is parsed
with `defusedxml` (`forbid_dtd=True`).

Two ratchets re-pinned for the new leaf, each with its reason recorded at
the pin: `test_security_gate_liveness._PACKAGE_LINE_BUDGET` (the fence
declaration and its comment in `paths.py`) and
`test_sandbox_protected_name_holds.EXPECTED` (a root leaf is held by its
own name only, three launcher entries per tier, like `auth-store-staging`).

Specs updated: `docs/system-specs/modules/meetings.md` (routes, provider
table, credential store, OAuth custody decision) and `security.md`
(keystone directory `meetings-credentials`).

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • OAuth wire shapes pinned only against local fakes span=14e283773a48

needs-a-decision.
The token exchange, refresh, PKCE, redirect handling, Graph paging and the Disconnect races are tested against fakes built from the providers' documented contracts; no live Google or Microsoft 365 tenant has been exercised.
Maintainer: should this backend wait for one live connect-and-sync (it needs a registered client), or is that verification owned by the stacked settings UI in #8081?

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Delete the workspace/meetings legacy migration span=94e06b90dc48

fixed in 8dc1f9f.
The migration, its descriptor-relative helpers, its tests, its log line and the spec sentences are removed; no released build ever wrote that location, so there is nothing to migrate.
The store's own link/non-directory refusal on every read and write is unchanged.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Migration with zero consumers span=73f3236227c9

fixed in 8dc1f9f.
Removed: the "earlier build" was a pre-merge revision of this PR, and main never wrote workspace/meetings/. meetings.md and security.md no longer describe a migration.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • write_for(only_if=dict) generalized for one caller span=a0540f3bba02

fixed in 8dc1f9f.
The dict is gone: write_for takes explicit only_if_refresh_token, only_if_client_id and only_if_generation keywords, one per precondition its two callers (refresh and sign-in completion) actually need.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Migration from a location that never existed on main span=7174d818bf1f

fixed in 8dc1f9f.
Removed with the migration above; the description no longer claims compatibility with an earlier location.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • credential-bearing requests are not bound to the provider origin span=45fd7b9faee9

fixed in 8dc1f9f.
Token POSTs are sent with max_redirects=0, so the form body carrying the client secret or refresh token can never follow a 307/308 to another host.
A Graph @odata.nextLink is followed only when its (scheme, host, effective port) equals MICROSOFT_EVENTS_URL's, checked before the bearer header is attached; tests cover a foreign origin, an explicit :443, host case and userinfo.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • disconnect can be undone by an in-flight authorization exchange span=45fd7b9faee9

fixed in 8dc1f9f.
OAuth start captures the client id and a per-provider generation together; Disconnect advances the generation under the store lock; completion writes only if both still match, so a Disconnect (even followed by a reconnect with the same client id) is not undone.
Tests drive a completion suspended across Disconnect and across a same-id reconnect.

@kaizawa97

Copy link
Copy Markdown
Contributor Author
  • Redirect URI loses https behind TLS termination span=d1f05980ce55

fixed in 8dc1f9f.
_redirect_uri keeps the request's host and port and switches the scheme to https when dashboard.origin.is_https_request says so, which honours X-Forwarded-Proto only from a loopback peer.
A test pins https for a loopback request carrying X-Forwarded-Proto: https.

Copy link
Copy Markdown
Contributor

Open PR triage (2026-10-05): REBASE + merge discussion with #8081

Point-in-time code-level audit of head 8dc1f9fe80 against origin/main af1eb612da. I read the merge-base diff and the current main code, not just the title or description.

Status: stale, with conflicts. The merge base is f10a74d412 (#15203), which is now 725 commits behind main. git merge-tree against main shows content conflicts in 4 files:

  • src/kiro_crew/security/paths.py: the meetings-credentials entry in _CREW_SECRET_LEAVES
  • docs/system-specs/modules/security.md
  • test/test_meetings_owner_gate.py: the GATED table
  • test/test_sandbox_protected_name_holds.py: the re-measured ratchets

sandbox.py merges cleanly. _CREW_HIDDEN_LEAVES and _CREW_PRECREATE_HIDDEN_DIR_LEAVES still exist on main, so the mask and precreate entries carry over. The ratchet counts in test_sandbox_protected_name_holds.py and test_security_gate_liveness.py need re-measuring after the rebase.

Relationships (from the code, not the topic):

Not new, but still open on this head: the GPT BLOCK (500-event CalDAV cap drops events without counting the overflow, providers/calendar.py _events_from_multistatus) and the Design BLOCK (live Google/M365 OAuth never verified). The design review's "Watch" item also still applies: the CalDAV Authorization header goes to whatever origin calendar.source names in apps/meetings/data/config.json, and nothing binds that origin to the one the credential was saved for. I'm not adding a separate request-changes, because those reviews already cover these points.

Recommendation: REBASE onto current main, then resolve or rebut the two outstanding BLOCKs.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks for the thorough work on the calendar providers and the Settings flow. We are closing #2190 and #8081 together: both branches are about 5,500 commits behind main and conflict, #8081 has an open security review (the Linux sandbox does not mask workspace/meetings for already-running namespaces), and #2190 still has open review blocks. Main now ships the .ics provider plus the calendar poller (#8080), and Google Calendar and Microsoft 365 can both publish an .ics feed, so the basic need is covered. Richer provider support is tracked in #6769 (first-party Google Workspace connectors) and #16228 (multiple calendar sources). A fresh, smaller PR on current main is welcome.

The branch is left untouched, so you can reopen this PR at any time, or open a fresh one on current main, if you want to pick it back up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants