Add delegated Calendar operations with atomic event retries
Expose current-grant calendar listing, event reads, strict free/busy and event creation through the shared Oficina connection. Keep content sealed, reminders transactional, and busy expansion bounded across civil-time transitions.
Co-Authored-By: Codex <codex~paul@keymail.dev>
19 files changed,
+1,117
−11
Makefile+2 −2cmd/calendar-contract/main.go+22 −0cmd/calendar/main.go+2 −1docs/superpowers/specs/2026-09-02-calendar-design.md+42 −0go.mod+14 −2go.sum+24 −0internal/calendar/agent_access.go+125 −0internal/calendar/agent_access_test.go+297 −0internal/calendar/agent_boundaries_test.go+172 −0internal/calendar/agent_create.go+152 −0internal/calendar/agent_migrations/migrations/0001_event_receipts.sql+5 −0internal/calendar/agent_operations.go+52 −0internal/calendar/agent_read.go+69 −0internal/calendar/app.go+9 −0internal/calendar/config.go+2 −1internal/calendar/credits/notices.json+99 −0internal/calendar/credits_inventory_test.go+2 −1internal/calendar/routes.go+4 −0internal/calendar/store_slots.go+23 −4
CI passed — run details
diff --git a/Makefile b/Makefile| index 814f9b4..38da1ec 100644 |
| --- a/Makefile |
| +++ b/Makefile |
| @@ -1,5 +1,5 @@ |
| export GOTOOLCHAIN := go1.26.5 |
| -export GOPRIVATE := $(GOPRIVATE),amadan.net/oficina/estilo.git |
| +export GOPRIVATE := $(GOPRIVATE),amadan.net/oficina/estilo.git,amadan.net/oficina/agent-access.git |
| APP := calendar |
| @@ -160,6 +160,6 @@ credits: |
| go build -o "$$notices_tmp/notices" amadan.net/oficina/estilo.git/cmd/oficina-notices; \ |
| GOOS=linux GOARCH=arm64 CGO_ENABLED=0 "$$notices_tmp/notices" \ |
| -package ./cmd/calendar -lucide -onest \ |
| - -exclude amadan.net/oficina/estilo.git,amadan.net/oficina/home/connect,amadan.net/oficina/home/handoff,amadan.net/rastrillo/native/server \ |
| + -exclude amadan.net/oficina/agent-access.git,amadan.net/oficina/estilo.git,amadan.net/oficina/home/connect,amadan.net/oficina/home/handoff,amadan.net/rastrillo/native/server \ |
| > "$$notices_tmp/notices.json"; \ |
| mv "$$notices_tmp/notices.json" internal/calendar/credits/notices.json |
diff --git a/cmd/calendar-contract/main.go b/cmd/calendar-contract/main.go| new file mode 100644 |
| index 0000000..4414746 |
| --- /dev/null |
| +++ b/cmd/calendar-contract/main.go |
| @@ -0,0 +1,22 @@ |
| +// Command calendar-contract exports the live delegated operation schemas. |
| +package main |
| + |
| +import ( |
| + "amadan.net/oficina/calendar/internal/calendar" |
| + "encoding/json" |
| + "fmt" |
| + "os" |
| +) |
| + |
| +func main() { |
| + operations, err := calendar.AgentContracts() |
| + if err != nil { |
| + fmt.Fprintln(os.Stderr, "Could not export Calendar operation contracts.") |
| + os.Exit(1) |
| + } |
| + encoder := json.NewEncoder(os.Stdout) |
| + encoder.SetIndent("", " ") |
| + if encoder.Encode(operations) != nil { |
| + os.Exit(1) |
| + } |
| +} |
diff --git a/cmd/calendar/main.go b/cmd/calendar/main.go| index 9a9493c..0c99bbc 100644 |
| --- a/cmd/calendar/main.go |
| +++ b/cmd/calendar/main.go |
| @@ -66,7 +66,8 @@ func main() { |
| DEK: os.Getenv("CALENDAR_DEK"), |
| Mailer: mailer, |
| AllowedAddresses: os.Getenv("CALENDAR_ALLOWED_ADDRESSES"), |
| - Logger: logger, |
| + AgentIssuer: os.Getenv("CALENDAR_AGENT_ISSUER"), AgentTeam: os.Getenv("CALENDAR_AGENT_TEAM"), |
| + Logger: logger, |
| }) |
| if err != nil { |
| logger.Error("build app", "err", err) |
diff --git a/docs/superpowers/specs/2026-09-02-calendar-design.md b/docs/superpowers/specs/2026-09-02-calendar-design.md| index 46df778..8d76baa 100644 |
| --- a/docs/superpowers/specs/2026-09-02-calendar-design.md |
| +++ b/docs/superpowers/specs/2026-09-02-calendar-design.md |
| @@ -307,3 +307,45 @@ value is a dedicated 32-byte connection key, separate from event encryption. |
| Partial configuration refuses startup. Without these values, local sign-in keeps |
| its existing routes and behavior. The shared Home connection package supplies the |
| proof flow and account screens; Calendar keeps its own page shell and grants. |
| + |
| +## Delegated agent operations (implementation draft, 2026-10-24) |
| + |
| +Paul authorized one browser-approved Oficina connection with an Oficina-owned |
| +implementation pending Rastrillo convergence. Calendar's opt-in adapter uses |
| +`CALENDAR_AGENT_ISSUER` and `CALENDAR_AGENT_TEAM`, requires configured Home, and |
| +refuses partial configuration before opening storage. The bearer-only API sits |
| +outside browser session/CSRF routes. Credentials are verified online for this |
| +app's audience, then the opaque Home subject resolves to an existing admitted |
| +local person; no identity or calendar is provisioned by an agent request. |
| + |
| +The initial explicit operations are `calendar_list`, `calendar_get_event`, |
| +`calendar_free_busy` (`calendar:read`) and `calendar_create_event` |
| +(`calendar:write`). Every operation names this instance's configured team and |
| +uses current calendar grants. A row outside the person's grants remains a 404. |
| +Free/busy reads the strict recurrence path, fails closed when expansion cannot |
| +be completed, and accepts a half-open interval of at most 31 days. All-day busy |
| +time follows the person's configured zone. |
| + |
| +Create requires an explicit writable calendar ID and a nonzero UUID `client_id`. |
| +It records wall-clock dates/times and an explicit IANA time zone for timed events; |
| +ambiguous or nonexistent DST wall times are refused. All-day ends are exclusive. |
| +The initial create operation makes a single event without recurrence or attendees. |
| +It applies the person's existing default reminder, but sends no invitations and |
| +reports `invitations_sent: false`. It does not guarantee that a slot is free. |
| + |
| +The event, default reminder and retry receipt commit in one transaction, taking |
| +the writer reservation before rechecking the calendar grant. Receipt coordinates |
| +bind Home subject, client, team and UUID with a purpose-separated keyed digest; |
| +content is another keyed digest. Receipt storage contains only these digests and |
| +the event ID, never a readable title, place, note or address. Changed retry fields |
| +conflict; deletion never causes a replay to recreate the event. Replays still |
| +check current calendar access. Arguments, results and credentials stay out of |
| +logs. The API, suite CLI and MCP share these same app operations. |
| + |
| +GPT-6 Astra independently approved this implementation and amendment on |
| +2026-10-24 after fixes for explicit zones, bounded all-day expansion, skipped |
| +civil dates and midnight gaps. Focused race tests pass. Nine effective adverse |
| +mutations fail their selected tests, including both local admission checks |
| +removed together (removing only the redundant outer check remains safely denied). |
| +Full CI and deployed canary review remain required before merge. This amendment does not authorize external attendee invitation |
| +mail or change Calendar's established data custody rules. |
diff --git a/go.mod b/go.mod| index 7cca2e8..32e7f21 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -25,7 +25,7 @@ require ( |
| github.com/gobwas/httphead v0.1.0 // indirect |
| github.com/gobwas/pool v0.2.1 // indirect |
| github.com/gobwas/ws v1.4.0 // indirect |
| - github.com/google/uuid v1.6.0 // indirect |
| + github.com/google/uuid v1.6.0 |
| github.com/jinzhu/inflection v1.0.0 // indirect |
| github.com/jinzhu/now v1.1.5 // indirect |
| github.com/keymaildev/signin v0.1.1 // indirect |
| @@ -42,11 +42,23 @@ require ( |
| modernc.org/sqlite v1.55.0 // indirect |
| ) |
| -require amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 |
| +require ( |
| + amadan.net/oficina/agent-access.git v0.0.0-20261024224328-3966c68144d1 |
| + amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 |
| +) |
| require ( |
| amadan.net/rastrillo/rastrillo/money v0.1.0 // indirect |
| + github.com/google/jsonschema-go v0.4.3 // indirect |
| + github.com/modelcontextprotocol/go-sdk v1.7.0 // indirect |
| + github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect |
| + github.com/segmentio/asm v1.1.3 // indirect |
| + github.com/segmentio/encoding v0.5.4 // indirect |
| + github.com/yosida95/uritemplate/v3 v3.0.2 // indirect |
| golang.org/x/mod v0.38.0 // indirect |
| + golang.org/x/oauth2 v0.35.0 // indirect |
| + golang.org/x/sync v0.22.0 // indirect |
| + golang.org/x/time v0.15.0 // indirect |
| ) |
| tool amadan.net/rastrillo/rastrillo/cmd/rastrillo |
diff --git a/go.sum b/go.sum| index 5322bf1..0f96e41 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,3 +1,5 @@ |
| +amadan.net/oficina/agent-access.git v0.0.0-20261024224328-3966c68144d1 h1:GknXgICfFlRNJTwXrZRdeTRS6DtQ37b3e7COQX/IxAs= |
| +amadan.net/oficina/agent-access.git v0.0.0-20261024224328-3966c68144d1/go.mod h1:Ph9PIa3VE1IEaUzZiQH6D+IQ6HThWWGfVr0ecMMgrFA= |
| amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 h1:bVscoa9fH5LdLDjlyecZhrX7JzWPT0blb57MH0FIm2U= |
| amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c h1:3yxO2D8BxDLMGfFV2o6Sp9Z91yLnjDCIuRKHVWORa8A= |
| @@ -20,6 +22,8 @@ github.com/chromedp/chromedp v0.14.2 h1:r3b/WtwM50RsBZHMUm9fsNhhzRStTHrKdr2zmwbZ |
| github.com/chromedp/chromedp v0.14.2/go.mod h1:rHzAv60xDE7VNy/MYtTUrYreSc0ujt2O1/C3bzctYBo= |
| github.com/chromedp/sysutil v1.1.0 h1:PUFNv5EcprjqXZD9nJb9b/c9ibAbxiYo4exNWZyipwM= |
| github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8= |
| +github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= |
| +github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= |
| github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= |
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= |
| github.com/go-chi/chi/v5 v5.3.2 h1:5YQkICvTCSZ25hoRsyJazN0scjzKGiu4VAUc7H1o1nY= |
| @@ -34,6 +38,12 @@ github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= |
| github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= |
| github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs= |
| github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc= |
| +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= |
| +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= |
| +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= |
| +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= |
| +github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0= |
| +github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= |
| github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= |
| github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= |
| github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= |
| @@ -52,18 +62,30 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE |
| github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
| github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= |
| github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= |
| +github.com/modelcontextprotocol/go-sdk v1.7.0 h1:yqjY2dsbKAC0LSuWZVBMrHgiG8ukXv6NRo0JiALay44= |
| +github.com/modelcontextprotocol/go-sdk v1.7.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= |
| github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= |
| github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= |
| github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw= |
| github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= |
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= |
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= |
| +github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= |
| +github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= |
| +github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= |
| +github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= |
| +github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0= |
| +github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0= |
| github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= |
| github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= |
| +github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= |
| +github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= |
| golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= |
| golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= |
| golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= |
| golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= |
| +golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= |
| +golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= |
| golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= |
| golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= |
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| @@ -71,6 +93,8 @@ golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= |
| golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= |
| golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= |
| golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= |
| +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= |
| +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= |
| golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= |
| golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= |
| gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= |
diff --git a/internal/calendar/agent_access.go b/internal/calendar/agent_access.go| new file mode 100644 |
| index 0000000..e39cf19 |
| --- /dev/null |
| +++ b/internal/calendar/agent_access.go |
| @@ -0,0 +1,125 @@ |
| +package calendar |
| + |
| +import ( |
| + "context" |
| + "embed" |
| + "encoding/json" |
| + "errors" |
| + "io/fs" |
| + |
| + access "amadan.net/oficina/agent-access.git" |
| + "amadan.net/oficina/home/connect/linkstore" |
| + "amadan.net/rastrillo/rastrillo/migrate" |
| +) |
| + |
| +//go:embed agent_migrations/migrations/*.sql |
| +var agentMigrations embed.FS |
| +var agentSchema = func() *migrate.Set { |
| + sub, err := fs.Sub(agentMigrations, "agent_migrations") |
| + if err != nil { |
| + panic(err) |
| + } |
| + return migrate.MustFromFS(sub, "calendar_agent_access") |
| +}() |
| + |
| +func validateAgentConfig(cfg Config, home bool) error { |
| + if cfg.AgentIssuer == "" && cfg.AgentTeam == "" { |
| + return nil |
| + } |
| + if !home || cfg.AgentTeam == "" { |
| + return errors.New("calendar: agent access requires Home and a team") |
| + } |
| + if _, err := access.NewRemoteVerifier(cfg.AgentIssuer, cfg.Origin+"/api/v1"); err != nil { |
| + return errors.New("calendar: invalid agent access configuration") |
| + } |
| + return nil |
| +} |
| +func (a *App) wireAgent() error { |
| + if a.cfg.AgentIssuer == "" { |
| + return nil |
| + } |
| + verifier, err := access.NewRemoteVerifier(a.cfg.AgentIssuer, a.cfg.Origin+"/api/v1") |
| + if err != nil { |
| + return err |
| + } |
| + return a.mountAgent(verifier, a.cfg.AgentTeam) |
| +} |
| +func (a *App) mountAgent(verifier access.Verifier, team string) error { |
| + if _, err := migrate.Apply(context.Background(), a.db, agentSchema); err != nil { |
| + return err |
| + } |
| + registry, err := access.NewRegistry(a.agentOperations(team)...) |
| + if err != nil { |
| + return err |
| + } |
| + a.agent = registry.HTTP(access.VerifyFunc(func(ctx context.Context, token string) (access.Principal, error) { |
| + p, err := verifier.Verify(ctx, token) |
| + if err != nil { |
| + return access.Principal{}, err |
| + } |
| + if _, err = a.agentPerson(ctx, p, team); err != nil { |
| + return access.Principal{}, err |
| + } |
| + return p, nil |
| + })) |
| + return nil |
| +} |
| +func (a *App) agentPerson(ctx context.Context, p access.Principal, team string) (Person, error) { |
| + allowed := false |
| + for _, t := range p.Teams { |
| + allowed = allowed || t == team |
| + } |
| + if !allowed || p.Subject == "" || p.Client == "" || p.Grant == "" || a.home == nil { |
| + return Person{}, access.Fail("forbidden", "This connection cannot access Calendar.") |
| + } |
| + linked, err := a.home.bridge.Resolve(ctx, p.Subject) |
| + if errors.Is(err, linkstore.ErrStorage) { |
| + return Person{}, access.Fail("unavailable", "Account verification is unavailable.") |
| + } |
| + if err != nil { |
| + return Person{}, access.Fail("forbidden", "Link an admitted Calendar account to Home first.") |
| + } |
| + var person Person |
| + if err = a.db.G.WithContext(ctx).First(&person, linked.ID).Error; err != nil { |
| + return Person{}, access.Fail("unavailable", "Account verification is unavailable.") |
| + } |
| + if person.ID != linked.ID || person.Address != linked.Label || !a.home.admitted.allows(person.Address) { |
| + return Person{}, access.Fail("forbidden", "This account cannot access Calendar.") |
| + } |
| + return person, nil |
| +} |
| +func agentFailure(err error) error { |
| + if err == nil { |
| + return nil |
| + } |
| + var failure access.Failure |
| + if errors.As(err, &failure) { |
| + return failure |
| + } |
| + if errors.Is(err, ErrNotFound) { |
| + return access.Fail("not_found", "This calendar or event is unavailable.") |
| + } |
| + if errors.Is(err, ErrReadOnly) { |
| + return access.Fail("forbidden", "This calendar is read-only.") |
| + } |
| + if _, ok := Invalid(err); ok { |
| + return access.Fail("invalid", "Check the event fields and explicit time zone.") |
| + } |
| + return access.Fail("unavailable", "Calendar is unavailable. Try again.") |
| +} |
| +func (a *App) agentGuard(team, scope string, fn func(context.Context, access.Principal, Person, json.RawMessage) (any, error)) func(context.Context, access.Principal, json.RawMessage) (any, error) { |
| + return func(ctx context.Context, p access.Principal, raw json.RawMessage) (any, error) { |
| + var in struct { |
| + Team string `json:"team"` |
| + } |
| + if json.Unmarshal(raw, &in) != nil || in.Team != team || !p.Allows(team, scope) { |
| + return nil, access.Fail("forbidden", "This connection cannot access that team.") |
| + } |
| + person, err := a.agentPerson(ctx, p, team) |
| + if err != nil { |
| + return nil, err |
| + } |
| + out, err := fn(ctx, p, person, raw) |
| + return out, agentFailure(err) |
| + } |
| +} |
diff --git a/internal/calendar/agent_access_test.go b/internal/calendar/agent_access_test.go| new file mode 100644 |
| index 0000000..c59a5b7 |
| --- /dev/null |
| +++ b/internal/calendar/agent_access_test.go |
| @@ -0,0 +1,297 @@ |
| +package calendar |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "net/http/httptest" |
| + "os" |
| + "path/filepath" |
| + "slices" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + access "amadan.net/oficina/agent-access.git" |
| +) |
| + |
| +func linkedCalendarAgent(t *testing.T) (*homeRouterFixture, *access.Principal, Person, int64) { |
| + t.Helper() |
| + f := newHomeRouterFixture(t) |
| + f.local(t) |
| + if w := f.do("GET", "/day/2026-09-10", ""); w.Code != 200 { |
| + t.Fatal(w.Code) |
| + } |
| + if w := f.do("GET", "/account/home", ""); w.Code != 200 { |
| + t.Fatal(w.Code) |
| + } |
| + start := homeRedirect(t, f.do("POST", "/account/home", "")) |
| + if homeRedirect(t, f.exchange(t, start, "opaque-agent-alice")) != "/account/home/confirm" { |
| + t.Fatal("link confirmation missing") |
| + } |
| + homeRedirect(t, f.do("POST", "/account/home/confirm", "")) |
| + p := &access.Principal{Subject: "opaque-agent-alice", Client: "agent-one", Grant: "grant-one", Teams: []string{"acme"}, Scopes: []string{"calendar:read", "calendar:write"}} |
| + if err := f.app.mountAgent(access.VerifyFunc(func(context.Context, string) (access.Principal, error) { return *p, nil }), "acme"); err != nil { |
| + t.Fatal(err) |
| + } |
| + person, err := f.app.agentPerson(t.Context(), *p, "acme") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + cal, err := f.app.store.DefaultCalendarID(t.Context(), person.ID) |
| + if err != nil || cal == 0 { |
| + t.Fatal(cal, err) |
| + } |
| + return f, p, person, cal |
| +} |
| +func calendarAgentCall(a *App, name string, input any) *httptest.ResponseRecorder { |
| + raw, _ := json.Marshal(input) |
| + r := httptest.NewRequest("POST", homeTestOrigin+"/api/v1/operations/"+name, strings.NewReader(string(raw))) |
| + r.Header.Set("Content-Type", "application/json") |
| + r.Header.Set("Authorization", "Bearer fixture") |
| + w := httptest.NewRecorder() |
| + a.agent.ServeHTTP(w, r) |
| + return w |
| +} |
| +func eventAgentInput(cal int64) map[string]any { |
| + start := time.Now().UTC().Add(48 * time.Hour).Truncate(time.Minute) |
| + return map[string]any{"team": "acme", "calendar_id": cal, "client_id": "44fca936-6f81-4132-9184-f22c61b7a478", "title": "agent_title_52503a8dbf90435a", "location": "agent_location_cf2759ea1ee54b60", "notes": "agent_notes_40b3d60d9d284695", "start_local": start.Format(LayoutLocal), "end_local": start.Add(time.Hour).Format(LayoutLocal), "tz": "UTC"} |
| +} |
| +func TestAgentEventRetryPermissionsAndSealing(t *testing.T) { |
| + f, p, person, cal := linkedCalendarAgent(t) |
| + input := eventAgentInput(cal) |
| + first := calendarAgentCall(f.app, "calendar_create_event", input) |
| + if first.Code != 200 { |
| + t.Fatal(first.Code, first.Body.String()) |
| + } |
| + var receipt struct { |
| + ID int64 `json:"id"` |
| + URL string `json:"url"` |
| + Sent bool `json:"invitations_sent"` |
| + } |
| + if json.Unmarshal(first.Body.Bytes(), &receipt) != nil || receipt.ID == 0 || receipt.Sent || receipt.URL != homeTestOrigin+fmt.Sprintf("/events/%d", receipt.ID) { |
| + t.Fatal("bad receipt") |
| + } |
| + var group sync.WaitGroup |
| + for range 5 { |
| + group.Go(func() { |
| + w := calendarAgentCall(f.app, "calendar_create_event", input) |
| + if w.Code != 200 || w.Body.String() != first.Body.String() { |
| + t.Errorf("retry %d", w.Code) |
| + } |
| + }) |
| + } |
| + group.Wait() |
| + input["title"] = "changed" |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 409 { |
| + t.Fatal("changed retry", w.Code) |
| + } |
| + input["title"] = "agent_title_52503a8dbf90435a" |
| + var count int64 |
| + if err := f.app.db.G.Model(&Event{}).Count(&count).Error; err != nil || count != 1 { |
| + t.Fatal("duplicate event", count, err) |
| + } |
| + if err := f.app.db.G.Model(&Reminder{}).Count(&count).Error; err != nil || count != 1 { |
| + t.Fatal("default reminder not atomic/idempotent", count, err) |
| + } |
| + if err := f.app.db.G.Model(&ReminderQueue{}).Count(&count).Error; err != nil || count != 1 { |
| + t.Fatal("reminder queue", count, err) |
| + } |
| + read := calendarAgentCall(f.app, "calendar_get_event", map[string]any{"team": "acme", "id": receipt.ID}) |
| + if read.Code != 200 || !strings.Contains(read.Body.String(), input["title"].(string)) { |
| + t.Fatal("read created event", read.Code) |
| + } |
| + for _, column := range []string{"title", "location", "notes"} { |
| + if found, _ := f.app.GrepDatabaseForTest(t, input[column].(string)); found { |
| + t.Fatal("plaintext event content", column) |
| + } |
| + } |
| + if _, err := f.app.db.Writer().Exec("PRAGMA wal_checkpoint(TRUNCATE)"); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, column := range []string{"title", "location", "notes"} { |
| + if found, _ := f.app.GrepDatabaseForTest(t, input[column].(string)); found { |
| + t.Fatal("plaintext checkpointed content", column) |
| + } |
| + } |
| + coordinate, _ := json.Marshal([]string{p.Subject, p.Client, "acme", input["client_id"].(string)}) |
| + expected, err := f.app.store.seal.Fingerprint("agent.event.coordinate.v1", string(coordinate)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var saved string |
| + if err = f.app.db.Writer().QueryRow("SELECT coordinate FROM calendar_agent_events WHERE event_id=?", receipt.ID).Scan(&saved); err != nil || saved != expected { |
| + t.Fatal("receipt identity binding", err) |
| + } |
| + rows, err := f.app.db.Writer().Query("SELECT name FROM pragma_table_info('calendar_agent_events') ORDER BY cid") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var columns []string |
| + for rows.Next() { |
| + var name string |
| + if err = rows.Scan(&name); err != nil { |
| + t.Fatal(err) |
| + } |
| + columns = append(columns, name) |
| + } |
| + err = rows.Err() |
| + rows.Close() |
| + if err != nil || !slices.Equal(columns, []string{"coordinate", "content", "event_id"}) { |
| + t.Fatal("extra receipt retention", columns, err) |
| + } |
| + // Existing access must be rechecked even for an otherwise valid retry. |
| + if err = f.app.db.G.Model(&Grant{}).Where("person_id=? AND calendar_id=?", person.ID, cal).Update("role", RoleViewer).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 403 { |
| + t.Fatal("read-only retry", w.Code) |
| + } |
| + if err = f.app.db.G.Where("person_id=? AND calendar_id=?", person.ID, cal).Delete(&Grant{}).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, op := range []string{"calendar_create_event", "calendar_get_event"} { |
| + args := input |
| + if op == "calendar_get_event" { |
| + args = map[string]any{"team": "acme", "id": receipt.ID} |
| + } |
| + if w := calendarAgentCall(f.app, op, args); w.Code != 404 { |
| + t.Fatal("lost grant disclosed event", op, w.Code) |
| + } |
| + } |
| + if err = f.app.store.ensureGrant(t.Context(), cal, person.ID, RoleOwner, person.ID); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = f.app.store.DeleteEvent(t.Context(), person.ID, receipt.ID); err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 404 { |
| + t.Fatal("deleted event replay", w.Code) |
| + } |
| + if err = f.app.db.G.Model(&Event{}).Count(&count).Error; err != nil || count != 1 { |
| + t.Fatal("deleted event recreated", count, err) |
| + } |
| +} |
| + |
| +func TestAgentIdentityScopeAndCalendarIsolation(t *testing.T) { |
| + f, p, _, cal := linkedCalendarAgent(t) |
| + input := eventAgentInput(cal) |
| + other, err := f.app.store.EnsurePersonSetup(t.Context(), "replacement@example.test") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + otherCal, err := f.app.store.DefaultCalendarID(t.Context(), other.ID) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + input["calendar_id"] = otherCal |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 404 { |
| + t.Fatal("foreign calendar write", w.Code) |
| + } |
| + input["calendar_id"] = cal |
| + list := calendarAgentCall(f.app, "calendar_list", map[string]any{"team": "acme"}) |
| + if list.Code != 200 { |
| + t.Fatal(list.Code) |
| + } |
| + var result struct { |
| + Calendars []struct { |
| + ID int64 `json:"id"` |
| + } `json:"calendars"` |
| + } |
| + if json.Unmarshal(list.Body.Bytes(), &result) != nil { |
| + t.Fatal("list JSON") |
| + } |
| + for _, c := range result.Calendars { |
| + if c.ID == otherCal { |
| + t.Fatal("foreign calendar listed") |
| + } |
| + } |
| + original := *p |
| + for _, change := range []func(){func() { p.Subject = "unlinked" }, func() { p.Scopes = []string{"calendar:read"} }, func() { p.Teams = []string{"other"} }, func() { p.Client = "" }, func() { delete(f.app.home.admitted.addrs, "alice@example.test") }} { |
| + change() |
| + w := calendarAgentCall(f.app, "calendar_create_event", input) |
| + if w.Code != 403 { |
| + t.Fatal("unauthorized create", w.Code) |
| + } |
| + *p = original |
| + f.app.home.admitted.addrs["alice@example.test"] = struct{}{} |
| + } |
| + var count int64 |
| + if err = f.app.db.G.Model(&Event{}).Count(&count).Error; err != nil || count != 0 { |
| + t.Fatal("denial wrote event", count, err) |
| + } |
| + if err = f.app.db.G.Model(&Person{}).Count(&count).Error; err != nil || count != 2 { |
| + t.Fatal("request provisioned person", count, err) |
| + } |
| + p.Teams = []string{"acme", "other"} |
| + input["team"] = "other" |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 403 { |
| + t.Fatal("cross instance team", w.Code) |
| + } |
| + r := httptest.NewRequest("GET", homeTestOrigin+"/api/v1/operations", nil) |
| + for _, c := range f.cookies { |
| + r.AddCookie(c) |
| + } |
| + w := httptest.NewRecorder() |
| + f.app.agent.ServeHTTP(w, r) |
| + if w.Code != 401 { |
| + t.Fatal("cookie authorized API", w.Code) |
| + } |
| +} |
| + |
| +func TestAgentTimesAndFreeBusyFailClosed(t *testing.T) { |
| + for _, tc := range []struct { |
| + local, zone string |
| + want bool |
| + }{{"2026-10-25T01:30", "Europe/Dublin", false}, {"2026-03-29T01:30", "Europe/Dublin", false}, {"2026-04-05T01:45", "Australia/Lord_Howe", false}, {"2026-10-25T03:30", "Europe/Dublin", true}, {"2026-10-25T01:30", "UTC", true}} { |
| + if got := agentUnambiguous(tc.local, tc.zone); got != tc.want { |
| + t.Fatal(tc, got) |
| + } |
| + } |
| + f, _, person, cal := linkedCalendarAgent(t) |
| + input := eventAgentInput(cal) |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 200 { |
| + t.Fatal(w.Code, w.Body.String()) |
| + } |
| + start, _ := ToUTC(input["start_local"].(string), "UTC", false) |
| + rangeInput := map[string]any{"team": "acme", "start": time.Unix(start-60, 0).UTC().Format(time.RFC3339), "end": time.Unix(start+7200, 0).UTC().Format(time.RFC3339)} |
| + busy := calendarAgentCall(f.app, "calendar_free_busy", rangeInput) |
| + if busy.Code != 200 || !strings.Contains(busy.Body.String(), time.Unix(start, 0).UTC().Format(time.RFC3339)) { |
| + t.Fatal("missing busy event", busy.Code, busy.Body.String()) |
| + } |
| + // An imported recurrence outside the supported subset cannot imply free time. |
| + event, err := f.app.store.CreateEvent(t.Context(), person.ID, EventInput{CalendarID: cal, Title: "unsupported recurrence", StartLocal: input["start_local"].(string), EndLocal: input["end_local"].(string), TZ: "UTC", RRule: "FREQ=HOURLY"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err = f.app.db.G.Model(&Event{}).Where("id=?", event.ID).Update("rrule_foreign", true).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := calendarAgentCall(f.app, "calendar_free_busy", rangeInput); w.Code != 503 { |
| + t.Fatal("incomplete recurrence reported free", w.Code) |
| + } |
| + input["start_local"] = "2026-10-25T01:30" |
| + input["end_local"] = "2026-10-25T02:30" |
| + input["tz"] = "Europe/Dublin" |
| + input["client_id"] = "7c27948d-9082-42f8-bc12-e3c39bb7479e" |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 422 { |
| + t.Fatal("ambiguous create", w.Code) |
| + } |
| +} |
| + |
| +func TestAgentConfigurationRefusesBeforeStorage(t *testing.T) { |
| + for _, cfg := range []Config{{AgentTeam: "acme"}, {AgentIssuer: "https://connect.example.test"}, {AgentTeam: "acme", AgentIssuer: "http://insecure.test"}} { |
| + cfg.Env = "development" |
| + cfg.Origin = homeTestOrigin |
| + cfg.DBPath = filepath.Join(t.TempDir(), "refused.db") |
| + app, err := New(cfg) |
| + if err == nil { |
| + app.Close() |
| + t.Fatal("accepted incomplete agent config") |
| + } |
| + if _, err = os.Stat(cfg.DBPath); !os.IsNotExist(err) { |
| + t.Fatal("opened storage before refusing") |
| + } |
| + } |
| +} |
diff --git a/internal/calendar/agent_boundaries_test.go b/internal/calendar/agent_boundaries_test.go| new file mode 100644 |
| index 0000000..6db78ba |
| --- /dev/null |
| +++ b/internal/calendar/agent_boundaries_test.go |
| @@ -0,0 +1,172 @@ |
| +package calendar |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "net/http" |
| + "net/http/httptest" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +func TestAgentLongAllDayBusyWorkIsBounded(t *testing.T) { |
| + f, _, person, cal := linkedCalendarAgent(t) |
| + if _, err := f.app.store.CreateEvent(t.Context(), person.ID, EventInput{CalendarID: cal, Title: "millennial all-day commitment", AllDay: true, StartLocal: "0001-01-01", EndLocal: "9999-12-31", Kind: KindCommitment}); err != nil { |
| + t.Fatal(err) |
| + } |
| + from := time.Date(2026, 10, 24, 0, 0, 0, 0, time.UTC) |
| + to := from.Add(24 * time.Hour) |
| + spans, err := f.app.store.BusyFor(t.Context(), person, from.Unix(), to.Unix(), nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + // The extended one-day window occupies at most five civil dates, not |
| + // every date in the stored event. This asserts work size, not wall time. |
| + if len(spans) == 0 || len(spans) > 5 { |
| + t.Fatal("unbounded materialization", len(spans)) |
| + } |
| + response := calendarAgentCall(f.app, "calendar_free_busy", map[string]any{"team": "acme", "start": from.Format(time.RFC3339), "end": to.Format(time.RFC3339)}) |
| + if response.Code != 200 || !strings.Contains(response.Body.String(), from.Format(time.RFC3339)) { |
| + t.Fatal("bounded response incomplete", response.Code, response.Body.String()) |
| + } |
| + input := eventAgentInput(cal) |
| + input["tz"] = "Local" |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 422 { |
| + t.Fatal("machine-local time accepted", w.Code) |
| + } |
| +} |
| + |
| +func TestAgentEventTransactionRollsBackReminderFailure(t *testing.T) { |
| + f, _, _, cal := linkedCalendarAgent(t) |
| + _, err := f.app.db.Writer().Exec(`CREATE TRIGGER reject_agent_reminder BEFORE INSERT ON reminder_queues BEGIN SELECT RAISE(ABORT,'fixture'); END`) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := calendarAgentCall(f.app, "calendar_create_event", eventAgentInput(cal)); w.Code != 503 { |
| + t.Fatal("partial effect reported success", w.Code) |
| + } |
| + for _, table := range []string{"events", "reminders", "reminder_queues", "calendar_agent_events"} { |
| + var count int |
| + if err = f.app.db.Writer().QueryRow("SELECT COUNT(*) FROM " + table).Scan(&count); err != nil || count != 0 { |
| + t.Fatal("partial event transaction", table, count, err) |
| + } |
| + } |
| +} |
| + |
| +func TestAgentMountedRouteUsesBearerAndRearms(t *testing.T) { |
| + f, p, _, cal := linkedCalendarAgent(t) |
| + // The production route constructor must mount the same checked handler |
| + // outside browser CSRF and inside the scheduling response hook. |
| + scheduler := newScheduledWork(f.app.store.nextDueAt, false, nil) |
| + recorder := &scheduleRecorder{} |
| + scheduler.capability = func(context.Context) error { return nil } |
| + scheduler.armed = func(context.Context) (remoteSchedule, error) { return remoteSchedule{}, nil } |
| + scheduler.put = func(ctx context.Context, _ string, at time.Time, _ string) error { return recorder.write(ctx, at) } |
| + scheduler.remove = func(context.Context, string) error { return nil } |
| + if _, err := scheduler.sync(true); err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(scheduler.close) |
| + f.app.scheduled.close() |
| + f.app.scheduled = scheduler |
| + f.app.mux = f.app.routes(f.app.h, f.app.auth, f.app.home.admitted, f.app.cfg.Origin) |
| + raw, _ := json.Marshal(eventAgentInput(cal)) |
| + r := httptest.NewRequest(http.MethodPost, homeTestOrigin+"/api/v1/operations/calendar_create_event", strings.NewReader(string(raw))) |
| + r.Header.Set("Content-Type", "application/json") |
| + r.Header.Set("Authorization", "Bearer fixture") |
| + w := httptest.NewRecorder() |
| + f.app.mux.ServeHTTP(w, r) |
| + if w.Code != 200 { |
| + t.Fatal("mounted bearer operation", w.Code, w.Body.String()) |
| + } |
| + // The loop is paused: the POST must queue a wake before the test drains it. |
| + if len(scheduler.wake) != 1 { |
| + t.Fatal("agent route omitted scheduler wake") |
| + } |
| + if _, err := scheduler.sync(false); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(recorder.snapshot()) == 0 { |
| + t.Fatal("agent-created reminder did not arm a wake") |
| + } |
| + p.Teams = []string{"other"} |
| + if w := calendarAgentCall(f.app, "calendar_list", map[string]any{"team": "other"}); w.Code != 403 { |
| + t.Fatal("configured team lost") |
| + } |
| +} |
| + |
| +func TestAgentBusyCrossesSkippedCivilDate(t *testing.T) { |
| + loc, err := Zone("Pacific/Apia") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + first := time.Date(2011, 12, 29, 0, 0, 0, 0, loc) |
| + end := time.Date(2012, 1, 1, 0, 0, 0, 0, loc) |
| + from := time.Date(2011, 12, 28, 0, 0, 0, 0, time.UTC) |
| + to := from.AddDate(0, 0, 6) |
| + e := EventView{Event: Event{AllDay: true, TZ: "Pacific/Apia"}, OccStartUTC: first.Unix(), OccEndUTC: end.Unix()} |
| + spans, err := allDayBusy(e, "UTC", time.UTC, from.Unix(), to.Unix()) |
| + if err != nil || len(spans) != 3 { |
| + t.Fatal("skipped local date expansion", len(spans), err) |
| + } |
| + for i, span := range spans { |
| + want := time.Date(2011, 12, 29+i, 0, 0, 0, 0, time.UTC) |
| + if span.StartUTC != want.Unix() || span.EndUTC != want.AddDate(0, 0, 1).Unix() { |
| + t.Fatal("civil date moved", span) |
| + } |
| + } |
| +} |
| + |
| +func TestAgentRechecksLinkAndLocalAdmission(t *testing.T) { |
| + f, _, person, cal := linkedCalendarAgent(t) |
| + input := eventAgentInput(cal) |
| + if w := calendarAgentCall(f.app, "calendar_create_event", input); w.Code != 200 { |
| + t.Fatal(w.Code) |
| + } |
| + if err := f.app.db.G.Model(&Person{}).Where("id=?", person.ID).Update("address", "removed@example.test").Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := calendarAgentCall(f.app, "calendar_list", map[string]any{"team": "acme"}); w.Code != 403 { |
| + t.Fatal("changed unadmitted identity", w.Code) |
| + } |
| + if err := f.app.db.G.Model(&Person{}).Where("id=?", person.ID).Update("address", person.Address).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := calendarAgentCall(f.app, "calendar_list", map[string]any{"team": "acme"}); w.Code != 200 { |
| + t.Fatal("restored identity", w.Code) |
| + } |
| + if _, err := f.app.db.Writer().Exec("DELETE FROM home_identity_links"); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, name := range []string{"calendar_list", "calendar_create_event"} { |
| + args := input |
| + if name == "calendar_list" { |
| + args = map[string]any{"team": "acme"} |
| + } |
| + if w := calendarAgentCall(f.app, name, args); w.Code != 403 { |
| + t.Fatal("unlinked request", name, w.Code) |
| + } |
| + } |
| + var count int |
| + if err := f.app.db.Writer().QueryRow("SELECT COUNT(*) FROM home_identity_links").Scan(&count); err != nil || count != 0 { |
| + t.Fatal("link recreated", count, err) |
| + } |
| + if err := f.app.db.Writer().QueryRow("SELECT COUNT(*) FROM events").Scan(&count); err != nil || count != 1 { |
| + t.Fatal("unlinked request changed events", count, err) |
| + } |
| +} |
| + |
| +func TestAgentBusyMidnightGapFailsClosed(t *testing.T) { |
| + f, _, person, cal := linkedCalendarAgent(t) |
| + if err := f.app.db.G.Model(&Person{}).Where("id=?", person.ID).Update("zone", "America/Santiago").Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := f.app.store.CreateEvent(t.Context(), person.ID, EventInput{CalendarID: cal, Title: "all-day commitment", AllDay: true, StartLocal: "2026-09-06", EndLocal: "2026-09-07", Kind: KindCommitment}); err != nil { |
| + t.Fatal(err) |
| + } |
| + w := calendarAgentCall(f.app, "calendar_free_busy", map[string]any{"team": "acme", "start": "2026-09-06T00:00:00-04:00", "end": "2026-09-07T00:00:00-03:00"}) |
| + if w.Code != 503 { |
| + t.Fatal("midnight gap was not a closed failure", w.Code, w.Body.String()) |
| + } |
| +} |
diff --git a/internal/calendar/agent_create.go b/internal/calendar/agent_create.go| new file mode 100644 |
| index 0000000..9cccf88 |
| --- /dev/null |
| +++ b/internal/calendar/agent_create.go |
| @@ -0,0 +1,152 @@ |
| +package calendar |
| + |
| +import ( |
| + "context" |
| + "database/sql" |
| + "encoding/json" |
| + "strconv" |
| + "time" |
| + |
| + access "amadan.net/oficina/agent-access.git" |
| + "github.com/google/uuid" |
| + "gorm.io/gorm" |
| +) |
| + |
| +type agentEventInput struct { |
| + Team string `json:"team"` |
| + ClientID string `json:"client_id"` |
| + CalendarID int64 `json:"calendar_id"` |
| + Title string `json:"title"` |
| + Location string `json:"location"` |
| + Notes string `json:"notes"` |
| + AllDay bool `json:"all_day"` |
| + StartLocal string `json:"start_local"` |
| + EndLocal string `json:"end_local"` |
| + TZ string `json:"tz"` |
| + Kind string `json:"kind"` |
| + Status string `json:"status"` |
| +} |
| + |
| +func (a *App) agentCreateEvent(ctx context.Context, principal access.Principal, person Person, raw json.RawMessage) (any, error) { |
| + var in agentEventInput |
| + if json.Unmarshal(raw, &in) != nil { |
| + return nil, access.Fail("invalid", "Invalid event input.") |
| + } |
| + uid, err := uuid.Parse(in.ClientID) |
| + if err != nil || uid == uuid.Nil || len(in.ClientID) != 36 { |
| + return nil, access.Fail("invalid", "Supply a nonzero UUID client_id.") |
| + } |
| + event := EventInput{CalendarID: in.CalendarID, Title: in.Title, Location: in.Location, Notes: in.Notes, AllDay: in.AllDay, StartLocal: in.StartLocal, EndLocal: in.EndLocal, TZ: in.TZ, Kind: in.Kind, Status: in.Status} |
| + if err = ValidateEventInput(&event); err != nil { |
| + return nil, err |
| + } |
| + if in.AllDay && in.TZ != "" { |
| + return nil, access.Fail("invalid", "An all-day event uses dates without a time zone.") |
| + } |
| + if !in.AllDay && event.TZ == "Local" { |
| + return nil, access.Fail("invalid", "Supply an explicit IANA time zone, not the server local zone.") |
| + } |
| + if !in.AllDay && (!agentUnambiguous(event.StartLocal, event.TZ) || !agentUnambiguous(event.EndLocal, event.TZ)) { |
| + return nil, access.Fail("invalid", "Choose unambiguous local times outside a DST gap or fold.") |
| + } |
| + coordinate, _ := json.Marshal([]string{principal.Subject, principal.Client, in.Team, uid.String()}) |
| + key, err := a.store.seal.Fingerprint("agent.event.coordinate.v1", string(coordinate)) |
| + if err != nil { |
| + return nil, err |
| + } |
| + // Fingerprint the supplied fields, not normalized fields: changed retry input |
| + // is a conflict even when the UI normalizer would make the same event. |
| + in.ClientID = uid.String() |
| + payload, _ := json.Marshal(in) |
| + fingerprint, err := a.store.seal.Fingerprint("agent.event.content.v1", string(payload)) |
| + if err != nil { |
| + return nil, err |
| + } |
| + var eventID int64 |
| + err = a.store.g.WithContext(ctx).Transaction(func(tx *gorm.DB) error { |
| + // This first write reserves the SQLite writer before permissions and receipt |
| + // are read; the effect, reminder and receipt commit atomically. |
| + if err := tx.Exec("INSERT INTO calendar_agent_events(coordinate,content) VALUES(?,?) ON CONFLICT(coordinate) DO NOTHING", key, fingerprint).Error; err != nil { |
| + return err |
| + } |
| + current := NewStore(tx, a.store.seal, a.logger) |
| + cal, err := current.Calendar(ctx, person.ID, in.CalendarID) |
| + if err != nil { |
| + return err |
| + } |
| + if cal.ArchivedAt != nil { |
| + return ErrNotFound |
| + } |
| + if !CanWrite(cal.Role) { |
| + return ErrReadOnly |
| + } |
| + var saved string |
| + var id sql.NullInt64 |
| + if err = tx.Raw("SELECT content,event_id FROM calendar_agent_events WHERE coordinate=?", key).Row().Scan(&saved, &id); err != nil { |
| + return err |
| + } |
| + if saved != fingerprint { |
| + return access.Fail("conflict", "This client_id was already used with different event fields.") |
| + } |
| + if id.Valid { |
| + if _, err = current.Event(ctx, person.ID, id.Int64); err != nil { |
| + return err |
| + } |
| + eventID = id.Int64 |
| + return nil |
| + } |
| + created, err := current.CreateEvent(ctx, person.ID, event) |
| + if err != nil { |
| + return err |
| + } |
| + if err = current.EnsureDefaultReminder(ctx, person, created); err != nil { |
| + return err |
| + } |
| + if err = tx.Exec("UPDATE calendar_agent_events SET event_id=? WHERE coordinate=?", created.ID, key).Error; err != nil { |
| + return err |
| + } |
| + eventID = created.ID |
| + return nil |
| + }) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return map[string]any{"id": eventID, "url": a.cfg.Origin + "/events/" + strconv.FormatInt(eventID, 10), "invitations_sent": false}, nil |
| +} |
| + |
| +// A machine caller must never silently acquire the store's default choice for |
| +// a repeated or nonexistent local time. Adjacent zone offsets expose both |
| +// candidates, including non-hour transitions. |
| +func agentUnambiguous(local, zone string) bool { |
| + if zone == "Local" { |
| + return false |
| + } |
| + index, err := ToUTC(local, zone, false) |
| + if err != nil { |
| + return false |
| + } |
| + loc, err := Zone(zone) |
| + if err != nil { |
| + return false |
| + } |
| + actual := time.Unix(index, 0).In(loc) |
| + if actual.Format(LayoutLocal) != local { |
| + return false |
| + } |
| + naive, err := time.Parse(LayoutLocal, local) |
| + if err != nil { |
| + return false |
| + } |
| + from, to := actual.ZoneBounds() |
| + for _, boundary := range []time.Time{from.Add(-time.Second), to} { |
| + if boundary.IsZero() || boundary.Year() < 1 { |
| + continue |
| + } |
| + _, offset := boundary.In(loc).Zone() |
| + candidate := time.Unix(naive.Unix()-int64(offset), 0).In(loc) |
| + if candidate.Unix() != index && candidate.Format(LayoutLocal) == local { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
diff --git a/internal/calendar/agent_migrations/migrations/0001_event_receipts.sql b/internal/calendar/agent_migrations/migrations/0001_event_receipts.sql| new file mode 100644 |
| index 0000000..63aee5f |
| --- /dev/null |
| +++ b/internal/calendar/agent_migrations/migrations/0001_event_receipts.sql |
| @@ -0,0 +1,5 @@ |
| +CREATE TABLE calendar_agent_events ( |
| + coordinate TEXT PRIMARY KEY, |
| + content TEXT NOT NULL, |
| + event_id INTEGER |
| +); |
diff --git a/internal/calendar/agent_operations.go b/internal/calendar/agent_operations.go| new file mode 100644 |
| index 0000000..33a875b |
| --- /dev/null |
| +++ b/internal/calendar/agent_operations.go |
| @@ -0,0 +1,52 @@ |
| +package calendar |
| + |
| +import ( |
| + access "amadan.net/oficina/agent-access.git" |
| + "encoding/json" |
| +) |
| + |
| +func agentObject(properties map[string]any, required ...string) json.RawMessage { |
| + raw, _ := json.Marshal(map[string]any{"type": "object", "properties": properties, "required": required, "additionalProperties": false}) |
| + return raw |
| +} |
| +func agentString(max int) map[string]any { return map[string]any{"type": "string", "maxLength": max} } |
| +func agentID() map[string]any { return map[string]any{"type": "integer", "minimum": 1} } |
| +func agentInput(properties map[string]any, required ...string) json.RawMessage { |
| + properties["team"] = map[string]any{"type": "string", "minLength": 1, "maxLength": 64} |
| + return agentObject(properties, append([]string{"team"}, required...)...) |
| +} |
| + |
| +var agentEventSchema = agentObject(map[string]any{ |
| + "id": agentID(), "calendar_id": agentID(), "title": agentString(MaxTitleLen), "location": agentString(MaxLocationLen), "notes": agentString(MaxNotesLen), |
| + "all_day": map[string]any{"type": "boolean"}, "start_local": agentString(16), "end_local": agentString(16), "tz": agentString(128), |
| + "start_utc": map[string]any{"type": "integer"}, "end_utc": map[string]any{"type": "integer"}, "sequence": map[string]any{"type": "integer"}, |
| + "kind": agentString(32), "status": agentString(32), "url": agentString(2048), |
| +}, "id", "calendar_id", "title", "location", "notes", "all_day", "start_local", "end_local", "tz", "start_utc", "end_utc", "sequence", "kind", "status", "url") |
| + |
| +func (a *App) agentOperations(team string) []access.Operation { |
| + return []access.Operation{ |
| + {Name: "calendar_list", Description: "List calendars currently visible to the linked person, with their roles. Choose a calendar_id explicitly before creating an event.", Scope: "calendar:read", ReadOnly: true, Idempotent: true, |
| + Input: agentInput(map[string]any{}), Output: agentObject(map[string]any{"calendars": map[string]any{"type": "array", "items": agentObject(map[string]any{"id": agentID(), "name": agentString(2048), "kind": agentString(32), "role": agentString(32)}, "id", "name", "kind", "role")}}, "calendars"), Invoke: a.agentGuard(team, "calendar:read", a.agentCalendars)}, |
| + {Name: "calendar_get_event", Description: "Read an event through the person's current calendar grant. Returns its time zone and canonical app URL.", Scope: "calendar:read", ReadOnly: true, Idempotent: true, |
| + Input: agentInput(map[string]any{"id": agentID()}, "id"), Output: agentEventSchema, Invoke: a.agentGuard(team, "calendar:read", a.agentGetEvent)}, |
| + {Name: "calendar_free_busy", Description: "Return complete busy spans across calendars the person can currently see. Supply RFC3339 start/end with offsets, at most 31 days. All-day events use the person's calendar time zone. Availability is advisory; creating an event does not reserve an otherwise free slot.", Scope: "calendar:read", ReadOnly: true, Idempotent: true, |
| + Input: agentInput(map[string]any{"start": agentString(35), "end": agentString(35)}, "start", "end"), Output: agentObject(map[string]any{"tz": agentString(128), "busy": map[string]any{"type": "array", "items": agentObject(map[string]any{"start": agentString(35), "end": agentString(35)}, "start", "end")}}, "tz", "busy"), Invoke: a.agentGuard(team, "calendar:read", a.agentBusy)}, |
| + {Name: "calendar_create_event", Description: "Create a single event on an explicitly selected writable calendar, with the person's default reminder. Local times are YYYY-MM-DDTHH:MM with an IANA tz; all-day events use dates and an exclusive end. Ambiguous/nonexistent DST times are refused. Reuse client_id only to retry identical fields. This operation sends no attendee invitations.", Scope: "calendar:write", Idempotent: true, |
| + Input: agentInput(map[string]any{"calendar_id": agentID(), "client_id": map[string]any{"type": "string", "minLength": 36, "maxLength": 36}, "title": agentString(MaxTitleLen), "location": agentString(MaxLocationLen), "notes": agentString(MaxNotesLen), "all_day": map[string]any{"type": "boolean"}, "start_local": agentString(16), "end_local": agentString(16), "tz": agentString(128), "kind": map[string]any{"enum": []string{KindMeeting, KindCommitment, KindNote}}, "status": map[string]any{"enum": []string{StatusConfirmed, StatusTentative}}}, "calendar_id", "client_id", "title", "start_local", "end_local"), |
| + Output: agentObject(map[string]any{"id": agentID(), "url": agentString(2048), "invitations_sent": map[string]any{"const": false}}, "id", "url", "invitations_sent"), Invoke: a.agentGuard(team, "calendar:write", a.agentCreateEvent)}, |
| + } |
| +} |
| + |
| +func AgentContracts() ([]access.Operation, error) { |
| + a := &App{} |
| + ops := a.agentOperations("contract") |
| + scopes := []string{} |
| + for _, op := range ops { |
| + scopes = append(scopes, op.Scope) |
| + } |
| + registry, err := access.NewRegistry(ops...) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return registry.List(access.Principal{Subject: "contract", Teams: []string{"contract"}, Scopes: scopes}), nil |
| +} |
diff --git a/internal/calendar/agent_read.go b/internal/calendar/agent_read.go| new file mode 100644 |
| index 0000000..2031ba4 |
| --- /dev/null |
| +++ b/internal/calendar/agent_read.go |
| @@ -0,0 +1,69 @@ |
| +package calendar |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "strconv" |
| + "time" |
| + |
| + access "amadan.net/oficina/agent-access.git" |
| +) |
| + |
| +func (a *App) agentCalendars(ctx context.Context, _ access.Principal, p Person, _ json.RawMessage) (any, error) { |
| + cals, err := a.store.Calendars(ctx, p.ID) |
| + if err != nil { |
| + return nil, err |
| + } |
| + out := []map[string]any{} |
| + for _, c := range cals { |
| + out = append(out, map[string]any{"id": c.ID, "name": c.Name, "kind": c.Kind, "role": c.Role}) |
| + } |
| + return map[string]any{"calendars": out}, nil |
| +} |
| +func (a *App) agentGetEvent(ctx context.Context, _ access.Principal, p Person, raw json.RawMessage) (any, error) { |
| + var in struct { |
| + ID int64 `json:"id"` |
| + } |
| + if json.Unmarshal(raw, &in) != nil { |
| + return nil, access.Fail("invalid", "Invalid event ID.") |
| + } |
| + e, err := a.store.Event(ctx, p.ID, in.ID) |
| + if err != nil { |
| + return nil, err |
| + } |
| + c, err := a.store.Calendar(ctx, p.ID, e.CalendarID) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if c.ArchivedAt != nil { |
| + return nil, ErrNotFound |
| + } |
| + return map[string]any{"id": e.ID, "calendar_id": e.CalendarID, "title": e.Title, "location": e.Location, "notes": e.Notes, "all_day": e.AllDay, "start_local": e.StartLocal, "end_local": e.EndLocal, "tz": e.TZ, "start_utc": e.StartUTC, "end_utc": e.EndUTC, "sequence": e.Sequence, "kind": e.Kind, "status": e.Status, "url": a.cfg.Origin + "/events/" + strconv.FormatInt(e.ID, 10)}, nil |
| +} |
| +func (a *App) agentBusy(ctx context.Context, _ access.Principal, p Person, raw json.RawMessage) (any, error) { |
| + var in struct{ Start, End string } |
| + if json.Unmarshal(raw, &in) != nil { |
| + return nil, access.Fail("invalid", "Invalid time range.") |
| + } |
| + start, e1 := time.Parse(time.RFC3339, in.Start) |
| + end, e2 := time.Parse(time.RFC3339, in.End) |
| + if e1 != nil || e2 != nil || !start.Before(end) || end.Sub(start) > 31*24*time.Hour { |
| + return nil, access.Fail("invalid", "Supply a positive RFC3339 time range of at most 31 days, with explicit offsets.") |
| + } |
| + spans, err := a.store.BusyFor(ctx, p, start.Unix(), end.Unix(), nil) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if len(spans) > 10000 { |
| + return nil, access.Fail("too_large", "Use a smaller time range.") |
| + } |
| + out := []map[string]string{} |
| + for _, span := range spans { |
| + from, to := max(span.StartUTC, start.Unix()), min(span.EndUTC, end.Unix()) |
| + if from >= to { |
| + continue |
| + } |
| + out = append(out, map[string]string{"start": time.Unix(from, 0).UTC().Format(time.RFC3339), "end": time.Unix(to, 0).UTC().Format(time.RFC3339)}) |
| + } |
| + return map[string]any{"tz": p.Zone, "busy": out}, nil |
| +} |
diff --git a/internal/calendar/app.go b/internal/calendar/app.go| index 0a5d5a1..090147f 100644 |
| --- a/internal/calendar/app.go |
| +++ b/internal/calendar/app.go |
| @@ -30,6 +30,7 @@ import ( |
| // development mail recorder both hang off this struct, and every later |
| // test depends on them. |
| type App struct { |
| + agent http.Handler |
| native *nativeauth.Auth |
| home *homeConnection |
| cfg Config |
| @@ -73,6 +74,9 @@ func New(cfg Config) (*App, error) { |
| return nil, fmt.Errorf("calendar: Home configuration: %w", err) |
| } |
| + if err := validateAgentConfig(cfg, homeSettings != nil); err != nil { |
| + return nil, err |
| + } |
| instanceKey, err := resolveInstanceKey(cfg) |
| if err != nil { |
| return nil, err |
| @@ -202,6 +206,11 @@ func New(cfg Config) (*App, error) { |
| d.Close() |
| return nil, err |
| } |
| + if err := a.wireAgent(); err != nil { |
| + signinMail.close() |
| + d.Close() |
| + return nil, err |
| + } |
| a.scheduled = newScheduledWork(store.nextDueAt, cfg.Env == "development", func(err error) { |
| logger.Error("calendar: scheduled work registration failed", "stage", "schedule.register", "err", scrubErr(err)) |
| }) |
diff --git a/internal/calendar/config.go b/internal/calendar/config.go| index 76333cf..9027ef1 100644 |
| --- a/internal/calendar/config.go |
| +++ b/internal/calendar/config.go |
| @@ -22,7 +22,8 @@ const DefaultOrigin = "http://localhost:8080" |
| // the family's shape: a misconfigured instance refuses to start, never |
| // quietly does the wrong thing. |
| type Config struct { |
| - Home *connect.Credentials |
| + Home *connect.Credentials |
| + AgentIssuer, AgentTeam string |
| // DBPath is the SQLite file this instance owns. The platform hands |
| // it in as activation argv; a developer passes -db. |
| DBPath string |
diff --git a/internal/calendar/credits/notices.json b/internal/calendar/credits/notices.json| index 683e00f..b237262 100644 |
| --- a/internal/calendar/credits/notices.json |
| +++ b/internal/calendar/credits/notices.json |
| @@ -107,6 +107,17 @@ |
| } |
| ] |
| }, |
| + { |
| + "Name": "github.com/google/jsonschema-go", |
| + "Version": "v0.4.3", |
| + "SourceURL": "https://pkg.go.dev/github.com/google/jsonschema-go@v0.4.3", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "MIT License\n\nCopyright (c) 2025 JSON Schema Go Project Authors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" |
| + } |
| + ] |
| + }, |
| { |
| "Name": "github.com/google/uuid", |
| "Version": "v1.6.0", |
| @@ -146,6 +157,17 @@ |
| "SourceURL": "https://pkg.go.dev/github.com/keymaildev/signin@v0.1.1", |
| "Notices": [] |
| }, |
| + { |
| + "Name": "github.com/modelcontextprotocol/go-sdk", |
| + "Version": "v1.7.0", |
| + "SourceURL": "https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk@v1.7.0", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 (\"Apache-2.0\"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0.\n\nContributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License.\n\nNo rights beyond those granted by the applicable original license are conveyed for such contributions.\n\n---\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright\n owner or by an individual or Legal Entity authorized to submit on behalf\n of the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n---\n\nMIT License\n\nCopyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n---\n\nCreative Commons Attribution 4.0 International (CC-BY-4.0)\n\nDocumentation in this project (excluding specifications) is licensed under\nCC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for\nthe full license text.\n" |
| + } |
| + ] |
| + }, |
| { |
| "Name": "github.com/remyoudompheng/bigfft", |
| "Version": "v0.0.0-20230129092748-24d4a6f8daec", |
| @@ -157,6 +179,50 @@ |
| } |
| ] |
| }, |
| + { |
| + "Name": "github.com/santhosh-tekuri/jsonschema/v6", |
| + "Version": "v6.0.3", |
| + "SourceURL": "https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6@v6.0.3", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability." |
| + } |
| + ] |
| + }, |
| + { |
| + "Name": "github.com/segmentio/asm", |
| + "Version": "v1.1.3", |
| + "SourceURL": "https://pkg.go.dev/github.com/segmentio/asm@v1.1.3", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "MIT License\n\nCopyright (c) 2021 Segment\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" |
| + } |
| + ] |
| + }, |
| + { |
| + "Name": "github.com/segmentio/encoding", |
| + "Version": "v0.5.4", |
| + "SourceURL": "https://pkg.go.dev/github.com/segmentio/encoding@v0.5.4", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "MIT License\n\nCopyright (c) 2019 Segment.io, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" |
| + } |
| + ] |
| + }, |
| + { |
| + "Name": "github.com/yosida95/uritemplate/v3", |
| + "Version": "v3.0.2", |
| + "SourceURL": "https://pkg.go.dev/github.com/yosida95/uritemplate/v3@v3.0.2", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "Copyright (C) 2016, Kohei YOSHIDA \u003chttps://yosida95.com/\u003e. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n * Neither the name of the copyright holder nor the names of its\n contributors may be used to endorse or promote products derived from\n this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" |
| + } |
| + ] |
| + }, |
| { |
| "Name": "golang.org/x/crypto", |
| "Version": "v0.55.0", |
| @@ -168,6 +234,28 @@ |
| } |
| ] |
| }, |
| + { |
| + "Name": "golang.org/x/oauth2", |
| + "Version": "v0.35.0", |
| + "SourceURL": "https://pkg.go.dev/golang.org/x/oauth2@v0.35.0", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "Copyright 2009 The Go Authors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google LLC nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" |
| + } |
| + ] |
| + }, |
| + { |
| + "Name": "golang.org/x/sync", |
| + "Version": "v0.22.0", |
| + "SourceURL": "https://pkg.go.dev/golang.org/x/sync@v0.22.0", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "Copyright 2009 The Go Authors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google LLC nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" |
| + } |
| + ] |
| + }, |
| { |
| "Name": "golang.org/x/sys", |
| "Version": "v0.47.0", |
| @@ -190,6 +278,17 @@ |
| } |
| ] |
| }, |
| + { |
| + "Name": "golang.org/x/time", |
| + "Version": "v0.15.0", |
| + "SourceURL": "https://pkg.go.dev/golang.org/x/time@v0.15.0", |
| + "Notices": [ |
| + { |
| + "Name": "LICENSE", |
| + "Text": "Copyright 2009 The Go Authors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google LLC nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" |
| + } |
| + ] |
| + }, |
| { |
| "Name": "gorm.io/gorm", |
| "Version": "v1.31.2", |
diff --git a/internal/calendar/credits_inventory_test.go b/internal/calendar/credits_inventory_test.go| index 851c02b..55f0137 100644 |
| --- a/internal/calendar/credits_inventory_test.go |
| +++ b/internal/calendar/credits_inventory_test.go |
| @@ -36,7 +36,8 @@ func TestCreditsMatchProductionDependencies(t *testing.T) { |
| if err != nil { |
| t.Fatalf("production dependency graph unavailable: %v\n%s", err, stderr.String()) |
| } |
| - inventory, err := catalog.Collect(bytes.NewReader(raw), map[string]bool{"amadan.net/oficina/estilo.git": true, "amadan.net/oficina/home/handoff": true, "amadan.net/oficina/home/connect": true, "amadan.net/rastrillo/native/server": true}) |
| + inventory, err := catalog.Collect(bytes.NewReader(raw), map[string]bool{"amadan.net/oficina/agent-access.git": true, |
| + "amadan.net/oficina/estilo.git": true, "amadan.net/oficina/home/handoff": true, "amadan.net/oficina/home/connect": true, "amadan.net/rastrillo/native/server": true}) |
| if err != nil { |
| t.Fatal(err) |
| } |
diff --git a/internal/calendar/routes.go b/internal/calendar/routes.go| index 2ad2dd1..3e982fa 100644 |
| --- a/internal/calendar/routes.go |
| +++ b/internal/calendar/routes.go |
| @@ -183,6 +183,10 @@ func (a *App) routes(h *handlers, authPlugin *rauth.Auth, list allowlist, origin |
| mux.Handle("GET "+sky.Prefix, sky.Handler()) |
| mux.HandleFunc("GET /static/credits.css", serveCreditsCSS) |
| a.mountTick(mux, h) |
| + if a.agent != nil { |
| + mux.Handle("/api/v1/operations", a.scheduled.middleware(a.agent)) |
| + mux.Handle("/api/v1/operations/", a.scheduled.middleware(a.agent)) |
| + } |
| mux.Handle("/", a.scheduled.middleware(r)) |
| return mux |
| } |
diff --git a/internal/calendar/store_slots.go b/internal/calendar/store_slots.go| index d2904cc..03d8d59 100644 |
| --- a/internal/calendar/store_slots.go |
| +++ b/internal/calendar/store_slots.go |
| @@ -45,7 +45,7 @@ func (s *Store) busyOn(tx *gorm.DB, host Person, from, to int64, skip map[int64] |
| out = append(out, Busy{StartUTC: e.OccStartUTC, EndUTC: e.OccEndUTC}) |
| continue |
| } |
| - spans, err := allDayBusy(e, host.Zone, hostLoc) |
| + spans, err := allDayBusy(e, host.Zone, hostLoc, from-86400, to+86400) |
| if err != nil { |
| return nil, err |
| } |
| @@ -64,7 +64,7 @@ func (s *Store) busyOn(tx *gorm.DB, host Person, from, to int64, skip map[int64] |
| // second before its exclusive end, and each date is then re-read as |
| // the host's day: a 9 September commitment blocks all of 9 September |
| // in Tokyo, not the UTC day that starts nine hours into it. |
| -func allDayBusy(e EventView, hostZone string, hostLoc *time.Location) ([]Busy, error) { |
| +func allDayBusy(e EventView, hostZone string, hostLoc *time.Location, from, to int64) ([]Busy, error) { |
| evLoc, err := Zone(e.TZ) |
| if err != nil { |
| // An imported zone this build cannot resolve: fall back to |
| @@ -75,19 +75,38 @@ func allDayBusy(e EventView, hostZone string, hostLoc *time.Location) ([]Busy, e |
| } |
| first := time.Unix(e.OccStartUTC, 0).In(evLoc) |
| last := time.Unix(e.OccEndUTC-1, 0).In(evLoc) |
| - firstDate := time.Date(first.Year(), first.Month(), first.Day(), 0, 0, 0, 0, evLoc) |
| - lastDate := time.Date(last.Year(), last.Month(), last.Day(), 0, 0, 0, 0, evLoc) |
| + firstDate := time.Date(first.Year(), first.Month(), first.Day(), 0, 0, 0, 0, time.UTC) |
| + lastDate := time.Date(last.Year(), last.Month(), last.Day(), 0, 0, 0, 0, time.UTC) |
| + // Bound materialization before iterating: an imported all-day event can |
| + // span millennia while a caller asks for one day. Compare civil dates in |
| + // UTC date markers, using the host dates touched by the requested window. |
| + // Advancing in a local zone can repeat a date when that zone skips a day. |
| + lower, upper := time.Unix(from, 0).In(hostLoc), time.Unix(to-1, 0).In(hostLoc) |
| + lowDate := time.Date(lower.Year(), lower.Month(), lower.Day(), 0, 0, 0, 0, time.UTC) |
| + highDate := time.Date(upper.Year(), upper.Month(), upper.Day(), 0, 0, 0, 0, time.UTC) |
| + if firstDate.Before(lowDate) { |
| + firstDate = lowDate |
| + } |
| + if lastDate.After(highDate) { |
| + lastDate = highDate |
| + } |
| var out []Busy |
| for d := firstDate; !d.After(lastDate); d = d.AddDate(0, 0, 1) { |
| // The DATE, rebuilt in the host's zone before DayBounds sees |
| // it. Handing DayBounds the event-zone midnight would let it |
| // land on the previous date for a host west of the event. |
| day := time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, hostLoc) |
| + if day.Year() != d.Year() || day.Month() != d.Month() || day.Day() != d.Day() { |
| + return nil, ErrIncompleteExpansion |
| + } |
| start, end, err := DayBounds(day, hostZone) |
| if err != nil { |
| return nil, err |
| } |
| + if end <= start { |
| + return nil, ErrIncompleteExpansion |
| + } |
| out = append(out, Busy{StartUTC: start, EndUTC: end}) |
| } |
| return out, nil |