canopycms 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,9 +5,9 @@ packages release together, at one version.
5
5
 
6
6
  ## This build
7
7
 
8
- Version `0.8.2`, built from [`74c7565`](https://github.com/safeinsights/canopycms/tree/74c756559271d91a988cf1ce2d250720062efd59).
8
+ Version `0.8.3`, built from [`e5dcfc6`](https://github.com/safeinsights/canopycms/tree/e5dcfc6cc5de00a6e5f215986f460645110fd71c).
9
9
 
10
- Its entries are [0.8.2](#082), under **Released**.
10
+ Its entries are [0.8.3](#083), under **Released**.
11
11
 
12
12
  If you upgraded from a build on another branch, compare the `<!-- changeset: … -->` slugs in your previous build's `CHANGELOG.md` (`npm pack canopycms@<old>` fetches it) with this one's: entries whose slug your old file lacks are new to you.
13
13
 
@@ -24,7 +24,7 @@ Each entry has up to three parts:
24
24
  `node_modules/canopycms/CHANGELOG.md`, assembled for that build: its **This build** section lists
25
25
  what is new since the previous int on the same branch, or on a stable release links its entries, and its links point at the commit the build
26
26
  came from. The copy in the repository holds released history and the entries from before changesets;
27
- every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/.changeset/README.md) until a stable release
27
+ every entry written since is a file in [`.changeset/`](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/.changeset/README.md) until a stable release
28
28
  moves it here.
29
29
 
30
30
  **Find your starting point.** From a stable pin, start at the first version under **Released**
@@ -62,6 +62,24 @@ entries under **Released**.
62
62
 
63
63
  ## Released
64
64
 
65
+ ### 0.8.3
66
+
67
+ #### Dev pages load for non-admin users under `defaultBranchAccess: 'deny'`
68
+
69
+ <!-- changeset: dev-active-branch-readable-under-deny -->
70
+
71
+ _First in 0.8.3._
72
+
73
+ **What changed.** In `dev` mode with `defaultBaseBranch` set, a page rendered on a git branch other than the base failed with `Forbidden: branch access denied (no_acl)` for any user outside `admins` and `reviewers`, because CanopyCMS provisions that branch's workspace itself and so nobody counted as its creator. The active branch the dev server provisions now passes branch access the way the base branch does: readable and, subject to path permissions, editable, but not submittable by a user who has no other grant. Prod and branches people create are unchanged.
74
+
75
+ #### `canopycms sync` reaches the workspace the dev server reads for a branch with a slash
76
+
77
+ <!-- changeset: sync-resolves-branch-like-dev-server -->
78
+
79
+ _First in 0.8.3._
80
+
81
+ **What changed.** `sync` resolves a branch name the way the dev server does. On a branch such as `fix/header`, `push` used to report success but write to a nested `.canopy-dev/content-branches/fix/header` that nothing reads, so the dev site never changed; it now writes to `fix-header`, the workspace the dev server serves, and `pull`, `both` and `abort` read from it. `--branch` also takes an editor branch's short name or its workspace directory name. `sync` refuses a workspace that belongs to a different branch, and a directory under `content-branches/` that is not its own git repository. Short names honour `branchNamespace` from `canopycms.config.ts`; if the config cannot be used, `sync` warns and uses the defaults.
82
+
65
83
  ### 0.8.2
66
84
 
67
85
  #### The editor says when a pull request is stuck, and what to do
@@ -316,7 +334,7 @@ _First in 0.7.0._
316
334
 
317
335
  **What changed.** The pull request a submit opens now lists the branch's unresolved editor comment threads: where each one is, the first line of its first comment (80 characters at most) and a link to it in the editor. Once every thread is resolved, it says so. The list is updated whenever a comment is added, replied to or resolved, as well as on submit. Comment excerpts are visible to everyone who can read the pull request, which on a public repository means everyone. Open threads do not block the merge or keep the pull request in draft. A pull request opened before this release shows no list until its branch is next submitted.
318
336
 
319
- **To adopt.** Nothing, if your deploy replaces the worker along with the CMS, as `cdk deploy` of the canopycms-cdk stack does with the default `workerCode`. A worker on an earlier release fails each update of the list and marks the branch's sync failed until a later task succeeds, so a pipeline that leaves the worker behind must roll it no later than the CMS: see [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#rolling-the-worker-from-ci).
337
+ **To adopt.** Nothing, if your deploy replaces the worker along with the CMS, as `cdk deploy` of the canopycms-cdk stack does with the default `workerCode`. A worker on an earlier release fails each update of the list and marks the branch's sync failed until a later task succeeds, so a pipeline that leaves the worker behind must roll it no later than the CMS: see [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#rolling-the-worker-from-ci).
320
338
 
321
339
  #### Pull request bodies link back to the editor
322
340
 
@@ -326,7 +344,7 @@ _First in 0.7.0._
326
344
 
327
345
  **What changed.** The pull request a submit opens links to the branch in the editor, and each changed entry to that entry. A notice tells reviewers that comments on the pull request do not reach the editor, so the author will not see them. The links use the editor's URL from the submit, accepted only when its host is the one the request was addressed to (`X-Forwarded-Host`, else `Host`), which holds behind `canopycms-cdk`'s CloudFront distribution as it stands.
328
346
 
329
- **To adopt.** Nothing, unless a proxy in front of the CMS sets neither header to the editor's public host: then set `editorUrl` in your Canopy config to the editor page's URL, e.g. `editorUrl: 'https://cms.example.org/edit'`. See [the config reference](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#definecanopyconfig-options).
347
+ **To adopt.** Nothing, unless a proxy in front of the CMS sets neither header to the editor's public host: then set `editorUrl` in your Canopy config to the editor page's URL, e.g. `editorUrl: 'https://cms.example.org/edit'`. See [the config reference](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#definecanopyconfig-options).
330
348
 
331
349
  #### CloudFront origin read timeout accepted up to 120 s; the editor waits 135 s
332
350
 
@@ -412,7 +430,7 @@ _First in 0.6.0._
412
430
 
413
431
  **What changed.** `CanopyCmsService` takes `clerkOrganizationsAsGroups` (default `true`, unchanged), which the worker honours; in a deployment it, not the plugin's `useOrganizationsAsGroups`, decides the groups. When Clerk refuses the organization list with a 403 (Organizations disabled), the refresh now writes users with no groups and logs a warning, instead of failing whole; any other failure still keeps the last snapshot. Memberships are fetched instance-wide rather than per user. The scaffolds write `false` explicitly: `useOrganizationsAsGroups` in `canopycms init`'s `canopy.ts`, and `clerkOrganizationsAsGroups` in `canopycms init-deploy aws`'s CDK stack.
414
432
 
415
- **To adopt.** On a Clerk instance without Organizations, set `clerkOrganizationsAsGroups: false` on `CanopyCmsService` and `useOrganizationsAsGroups: false` in `createClerkAuthPlugin`. See [Deploying to AWS](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md).
433
+ **To adopt.** On a Clerk instance without Organizations, set `clerkOrganizationsAsGroups: false` on `CanopyCmsService` and `useOrganizationsAsGroups: false` in `createClerkAuthPlugin`. See [Deploying to AWS](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md).
416
434
 
417
435
  ### 0.5.0
418
436
 
@@ -424,7 +442,7 @@ _First in 0.5.0._
424
442
 
425
443
  **What changed.** A `type: 'reference', list: true` field now edits as rows in stored order, like an `object` list: drag a row or use its "…" menu to move or remove it, open a row to swap its entry in place, and pick from Add under the rows to append. Neither control offers an entry the list already holds. Any `list: true` field, and any `block` field, takes `maxItems`. The editor stops adding at the cap and says why, a save over it is refused, and a production build fails on an entry over it, naming the entry, field, count and cap. Adding `maxItems` to a list that already holds more therefore fails the build until an editor removes the extra items. `maxItems` on a field that holds no items is refused when the entry schema registry is created.
426
444
 
427
- **To adopt.** Set `maxItems: 3` on the list field in its entry schema. See [Field Types](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#field-types).
445
+ **To adopt.** Set `maxItems: 3` on the list field in its entry schema. See [Field Types](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#field-types).
428
446
 
429
447
  #### SEO field location moves into config; reference pickers mark hidden entries and take a sort order — **breaking: `createNextCanopyContext({ seo })` and `AIContentConfig.seo` are removed**
430
448
 
@@ -434,7 +452,7 @@ _First in 0.5.0._
434
452
 
435
453
  **What changed.** `defineCanopyConfig` takes `seo: { group?, fields? }`, the one place every surface reads an entry's `noindex` flag: the sitemap and `entryToMetadata` that `createNextCanopyContext` returns, AI content and the editor's reference picker. A per-call `seo`/`group`/`fields` still overrides it. The free `generateContentSitemap` takes `seo` as an argument and refuses to run without it when the config sets one; `createNextCanopyContext` and the AI content config refuse a leftover `seo`. A reference picker now badges an entry hidden from search as "Hidden from search", and picking one adds a note naming the setting on that entry's form, since a page listing only indexed entries won't show it. A reference field takes `optionSort`: `'label'` (the default), `'collection'`, or `{ field, direction }`. Point `field` at an ISO date, since strings compare as text.
436
454
 
437
- **To adopt.** Move `seo` from `createNextCanopyContext({ seo })` and from `defineAIContentConfig({ seo })` into `defineCanopyConfig({ seo })`. See [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#sitemap-and-seo-metadata) and [How References Work in the Editor](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#how-references-work-in-the-editor).
455
+ **To adopt.** Move `seo` from `createNextCanopyContext({ seo })` and from `defineAIContentConfig({ seo })` into `defineCanopyConfig({ seo })`. See [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#sitemap-and-seo-metadata) and [How References Work in the Editor](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#how-references-work-in-the-editor).
438
456
 
439
457
  **Now deletable.** A shared `seo` constant passed separately to the Next context and the AI content config.
440
458
 
@@ -462,7 +480,7 @@ resolved without it.
462
480
  **To adopt.** Where a reference renders its target's prose, set `includeBody: true` on that
463
481
  reference field. Code that reads the body from a link-only reference's resolved type now sees
464
482
  `string | undefined`; either set `includeBody: true` or handle the missing value. See
465
- [Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#resolving-references-in-a-listing).
483
+ [Resolving References in a Listing](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#resolving-references-in-a-listing).
466
484
 
467
485
  ### 0.3.3
468
486
 
@@ -879,7 +897,7 @@ URL.
879
897
  2. For a branch preview: wrap views with `withCanopyPreview` in a `'use client'` module, add
880
898
  `app/preview/[[...path]]/page.server.tsx`, set `editor.previewPrefix: '/preview'`, and serve that
881
899
  route with `frame-ancestors 'self'`, not `X-Frame-Options: DENY` (see
882
- [Live Preview](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#live-preview)).
900
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#live-preview)).
883
901
  3. A test reading view content from the route's server HTML must load the page in a browser.
884
902
  Server output rendered during a preview request carries the signed-in asset prefix; keep it out
885
903
  of cross-request caches (`unstable_cache`, module memos).
@@ -894,7 +912,7 @@ kept site styles ahead of Mantine's in the preview.
894
912
  server components. A string path marks the form's spelling (`'a.0.b'` marks `a[0].b`), and an empty
895
913
  path marks nothing. The editor counts and logs marks naming no field. `createEntrySchemaRegistry`
896
914
  refuses a field name that is empty, all digits or contains `.`, `[` or `]`. See
897
- [Live Preview](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#live-preview).
915
+ [Live Preview](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#live-preview).
898
916
 
899
917
  **To adopt.** Fix each path that stops compiling; the error lists valid ones. Rewrite computed paths
900
918
  as literal segments, or type that component's prop as plain `FieldProps`. Pass `fieldProps` as
@@ -976,7 +994,7 @@ or a failed render) renders as its plain text, with no URL; any other form of th
976
994
  fields are nested or renamed, pass the AI config's `seo` the same object you pass
977
995
  `createNextCanopyContext({ seo })`, so the sitemap and AI content read the flag from the same
978
996
  place. A field that links to a hidden section by plain URL needs a field transform; the README
979
- shows [the recipe](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#ai-content-configuration).
997
+ shows [the recipe](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#ai-content-configuration).
980
998
 
981
999
  **Now deletable.** An `exclude.where` that re-read the `noindex` flag by hand.
982
1000
 
@@ -998,7 +1016,7 @@ A `markdown` field with `renderAs: 'mdx'` is checked as MDX, and `mdxAllow` narr
998
1016
  field or site-wide. New: field options `renderAs`, `mdxAllow`; config key `mdxAllow`; type
999
1017
  `MdxAllowlist`. (int.110) A component prop allowance can be `'string'` (or
1000
1018
  `{ type: 'string', maxLength }`): a quoted value only, never bare or `{…}`. See
1001
- [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#mdx-content-cannot-run-code).
1019
+ [MDX content cannot run code](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#mdx-content-cannot-run-code).
1002
1020
 
1003
1021
  **To adopt.** Set `renderAs: 'mdx'` on each `markdown` field your site compiles as MDX, and
1004
1022
  `mdxAllow` to what your renderer takes. Set `executable: true` only on a field whose editors you
@@ -1135,7 +1153,7 @@ a format check.
1135
1153
 
1136
1154
  - (int.93) Submit commits gain an `Edited-by: Name (id)` trailer; PR bodies gain a section that
1137
1155
  re-submits replace, keeping human text. Options: `gitEditedByTrailers`, `gitCoAuthoredByTrailers`
1138
- ([reference](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#definecanopyconfig-options)).
1156
+ ([reference](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#definecanopyconfig-options)).
1139
1157
  - (int.110) Submit-commit trailers name every user who saved since the last submit commit, and
1140
1158
  the PR-body section every user who edited the branch, not only the submitter; settings commits
1141
1159
  (permissions, groups) carry the acting user's trailer.
@@ -1159,7 +1177,7 @@ saves only push the branch, and no failing PR task lands in System health.
1159
1177
  that entry type goes unavailable: the editor says so, and its entries answer 503 with
1160
1178
  `code: 'SCHEMA_UNAVAILABLE'`. Builds, static deploys and `generate-ai-content` still fail. The
1161
1179
  worker holds the base branch for up to 30 minutes while that lasts; see
1162
- [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
1180
+ [New schemas wait for the editor deploy](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#new-schemas-wait-for-the-editor-deploy).
1163
1181
  Public types gain optional `unavailable` on `EntryTypeConfig` and `FlatSchemaItem`, optional
1164
1182
  `ApiResponse.code`, and a required `SchemaResolutionResult.issues`.
1165
1183
 
@@ -1197,7 +1215,7 @@ hang until the drain heartbeat lets termination continue. Its in-flight task is
1197
1215
  new stack needs no steps.
1198
1216
 
1199
1217
  **What changed.** (int.109) Detailed in
1200
- [The worker instance](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
1218
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#the-worker-instance): IMDSv2 with a hop limit of 1; the
1201
1219
  bundle is one file whose sha256 user data checks, readable as that one object; a file-system policy
1202
1220
  refusing clients without TLS or IAM, replacing the worker's
1203
1221
  `AmazonElasticFileSystemClientReadWriteAccess`; an encrypted gp3 root volume; a boot-time upgrade to
@@ -1251,10 +1269,10 @@ failure and exits non-zero on `selfStopped`, with a code outside `RestartPrevent
1251
1269
  with its hash, as `worker/dist/index.js` and `index.js.sha256`. The default, `'asset'`, is
1252
1270
  unchanged.
1253
1271
  - `CanopyCmsService` alarms when the worker logs no git sync for 30 minutes. See
1254
- [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#worker-down-alarm).
1272
+ [Worker-down alarm](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#worker-down-alarm).
1255
1273
 
1256
1274
  **To adopt.** Optional. For parameter-only change sets, see
1257
- [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
1275
+ [Rolling the worker from CI](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#rolling-the-worker-from-ci). For the alarm, pass
1258
1276
  `alarmTopic`.
1259
1277
 
1260
1278
  **Now deletable.** A manual `cdk deploy` after each canopycms bump whose only purpose is moving the
@@ -1265,7 +1283,7 @@ worker, and a hand-built alarm on the worker log group.
1265
1283
  **What changed.** (int.112) The boot's `dnf upgrade` could be OOM-killed on every retry. A 1 GiB
1266
1284
  swap file now goes on first; an upgrade that still fails starts the worker unpatched and notifies
1267
1285
  `alarmTopic` if set; a retried step names itself when it gives up. See
1268
- [The worker instance](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#the-worker-instance).
1286
+ [The worker instance](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#the-worker-instance).
1269
1287
 
1270
1288
  **To adopt.** Deploy, which replaces the worker instance. The bundle needs none of this, so it is
1271
1289
  not Template first and the worker contract stays at 1.
@@ -1331,7 +1349,7 @@ and operations may reuse GitHub fetches under 30 seconds old.
1331
1349
 
1332
1350
  **To adopt.** Nothing. Seeding `remote.git` stages a copy of the repository beside the gateway's
1333
1351
  mirror, so the root volume needs room for two
1334
- ([details](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#the-worker-instance)).
1352
+ ([details](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#the-worker-instance)).
1335
1353
 
1336
1354
  #### The worker follows a rebased or deleted GitHub branch
1337
1355
 
@@ -1353,7 +1371,7 @@ changes the template too (the fallback bundle's key and hash), so only the contr
1353
1371
  bundle-only roll is safe.
1354
1372
 
1355
1373
  **To adopt.** Parameter mode: gate bundle-only rolls on the contract
1356
- ([recipe](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
1374
+ ([recipe](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#rolling-the-worker-from-ci)). The gate refuses a stack without the
1357
1375
  `WorkerContract` output, so `cdk deploy` the template once, which adds it. A hand-installed unit
1358
1376
  copies its `Environment=CANOPYCMS_WORKER_CONTRACT=` line from `worker/canopy-worker.service`.
1359
1377
 
@@ -1370,8 +1388,8 @@ units from the bundle's contract: 2 gets the split, an older bundle the single u
1370
1388
  template, then roll the bundle; on an older template it stops with `template too old for this
1371
1389
  bundle`. Inspect EFS only through `sudo /opt/canopy-worker/canopy-inspect <command>`, never from a root shell. A hand install
1372
1390
  takes `worker/`'s three units and `gateway.env.example`
1373
- ([steps](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
1374
- [checklist](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#first-deploy-checklist).
1391
+ ([steps](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#installing-the-units-by-hand)). After the first deploy, run the
1392
+ [checklist](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#first-deploy-checklist).
1375
1393
 
1376
1394
  #### `canopycms-cdk`: `CanopyCmsService.attachTo`, and editor response headers — **behaviour change if you frame the CMS**
1377
1395
 
@@ -1382,7 +1400,7 @@ response headers policy. `CanopyCmsDistribution` sends the same headers: `frame-
1382
1400
  `X-Frame-Options: SAMEORIGIN`, `nosniff`, HSTS and `X-Robots-Tag: noindex`. Unless your app sends
1383
1401
  its own framing headers, no other origin can frame the editor or any page the CMS domain serves. Every such page is
1384
1402
  marked `noindex`. The editor's default preview is same-origin and unaffected. See
1385
- [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
1403
+ [Serving the editor from a distribution you already own](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#serving-the-editor-from-a-distribution-you-already-own).
1386
1404
 
1387
1405
  **To adopt.** If you wired the Function URL into your own distribution by hand, delete those
1388
1406
  behaviors and call `attachTo`, passing your CMS build's `assetPrefix` as `editorAssetPrefix` and a
@@ -1558,7 +1576,7 @@ one the exclusions leave out. A throw or any other return is logged and treated
1558
1576
  **To adopt.** If your site's routes, sitemap or bylines decide that some entries have no page,
1559
1577
  apply the same rule here, for example `referenceLink: (target, { body }) =>
1560
1578
  !body?.trim() ? false : undefined` in `defineAIContentConfig` from `canopycms/ai`. See
1561
- [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#ai-content-configuration).
1579
+ [AI Content Configuration](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#ai-content-configuration).
1562
1580
 
1563
1581
  **Now deletable.** A `fieldTransforms` entry that re-renders a reference field only to drop or
1564
1582
  change its link.
@@ -1633,7 +1651,7 @@ _First in int.115._
1633
1651
  entry the base branch also changed, the "updated on the base branch" notice and the branch's
1634
1652
  conflict count now stay until the branch merges, so a reviewer still sees which entries replaced a
1635
1653
  base change. They used to clear on the next sync, about five minutes later. README's new [Drafts
1636
- and Unpublishing](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#drafts-and-unpublishing) section covers long-lived branches and
1654
+ and Unpublishing](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#drafts-and-unpublishing) section covers long-lived branches and
1637
1655
  unpublishing.
1638
1656
 
1639
1657
  #### The editor calls the content drawer "All content"
@@ -1945,7 +1963,7 @@ editor carries an unsaved draft of a stamped entry onto its stamped version.
1945
1963
  The flag is refused off a top-level `datetime`, on `list: true`, and with `required: true`.
1946
1964
 
1947
1965
  **To adopt.** Add `stampOnPublish: true` to the date field your site sorts or labels by, such as
1948
- `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#stamping-a-publication-date).
1966
+ `{ name: 'publishedAt', type: 'datetime', stampOnPublish: true }`. See [Stamping a publication date](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#stamping-a-publication-date).
1949
1967
 
1950
1968
  **Now deletable.** A build step or hook that writes a missing publication date into new entries.
1951
1969
 
@@ -1992,7 +2010,7 @@ preview/form divider is now keyboard-resizable within the same 15–85% the spli
1992
2010
  stored at, and `react-split-pane` is no longer a dependency.
1993
2011
  `EditorPanes`, `EditorPanesProps`, the `PaneLayout` type and the `SPLIT_PERCENT_*` and `DEFAULT_*_SPLIT_PERCENT` constants are
1994
2012
  no longer exported from `canopycms/client`. See
1995
- [Your root layout](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#editor-customization).
2013
+ [Your root layout](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#editor-customization).
1996
2014
 
1997
2015
  **To adopt.** Nothing, unless you import `EditorPanes` or those constants: render `CanopyEditor`
1998
2016
  instead, which lays out its own panes. Hiding your site chrome on the editor route is now
@@ -2103,7 +2121,7 @@ never ended. `canopycms-auth-clerk` skips it while the editor is mounted, and ex
2103
2121
  **To adopt.** Nothing for the editor, if your edit page uses `useClerkAuthConfig()` or
2104
2122
  `ClerkSignIn`. If your CMS build renders `<SignIn>`, `UserButton` or `OrganizationSwitcher` on your
2105
2123
  own pages, mount the hook as in
2106
- [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
2124
+ [Clerk components on your own pages](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/packages/canopycms-auth-clerk/README.md#clerk-components-on-your-own-pages).
2107
2125
  Your own Server Actions in the CMS build still 403 behind OAC.
2108
2126
 
2109
2127
  **Now deletable.** Any local patch of `window.__internal_onBeforeSetActive` (or 6.x's
@@ -2144,12 +2162,12 @@ fast naming the ARN, the field and the keys present, never a value.
2144
2162
  **To adopt.** Nothing, unless one of those secrets holds a JSON document: then set the matching
2145
2163
  prop. The scaffolded stack fills them from the repository _variables_
2146
2164
  `CANOPY_GITHUB_TOKEN_SECRET_JSON_FIELD` and `CLERK_SECRET_KEY_SECRET_JSON_FIELD`
2147
- ([why the prefix](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
2165
+ ([why the prefix](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#repository-secrets-and-variables)); a stack scaffolded earlier
2148
2166
  adds the props to `infrastructure/bin/app.ts` and `infrastructure/lib/cms-stack.ts` and the two `env`
2149
2167
  lines to `.github/workflows/deploy-cms.yml`, or re-runs the generator and diffs. `cdk synth` refuses a `…JsonField` prop without its `…SecretArn`, and an ARN carrying the ECS `:KEY::` suffix
2150
2168
  (also in `secretsArns`). Don't use CDK's `secretValueFromJson`: it resolves the plaintext into the deployed
2151
2169
  resource's configuration, readable by anyone who can describe it. Only `CLERK_SECRET_KEY` goes through Secrets Manager; `CLERK_JWT_KEY` and the publishable
2152
- key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#security-model)).
2170
+ key are public material ([Security Model](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#security-model)).
2153
2171
 
2154
2172
  **Now deletable.** A wrapper that fetches the secret, parses it and re-exports one field into the
2155
2173
  worker's environment, such as a `jq` step in user data or a wrapper entrypoint around
@@ -2161,7 +2179,7 @@ worker's environment, such as a `jq` step in user data or a wrapper entrypoint a
2161
2179
  `githubToken` is not deprecated and stays the documented default; `canopycms` neither depends on
2162
2180
  nor imports `@octokit/auth-app`. Register one App per site, not one shared across repositories:
2163
2181
  anyone holding an App's key can mint a token for any of its installations
2164
- ([why](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
2182
+ ([why](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/ARCHITECTURE.md#why-one-github-app-per-site-not-one-shared-across-an-organisation)).
2165
2183
 
2166
2184
  **To adopt with `canopycms-cdk`** (existing stacks need no edit). `CanopyCmsServiceProps` takes
2167
2185
  `githubAppId`, `githubAppInstallationId`, `githubAppPrivateKeySecretArn` and
@@ -2174,7 +2192,7 @@ anyone holding an App's key can mint a token for any of its installations
2174
2192
  `verify` checks an existing installation's permissions: run it, since an App missing a
2175
2193
  permission only shows up later, as `sync-failed`. `create` needs an interactive terminal and
2176
2194
  never edits an existing JSON secret (create one and point the JSON-field prop at it)
2177
- ([details](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
2195
+ ([details](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#register-it-with-canopycms-init-github-app)).
2178
2196
  2. Set the three props and **remove `githubTokenSecretArn`** (with its JSON field). A partial set
2179
2197
  of the three is refused at synth, and so is an App alongside a token.
2180
2198
  3. In the generated workflow, store them as `CANOPY_GITHUB_APP_ID`,
@@ -2185,7 +2203,7 @@ anyone holding an App's key can mint a token for any of its installations
2185
2203
 
2186
2204
  The private key is ARN-only; passing the key itself is refused at synth. Its ARN joins the worker's
2187
2205
  IAM policy automatically, so you need not add it to `secretsArns`. See
2188
- [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#authenticating-as-a-github-app).
2206
+ [Authenticating as a GitHub App](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#authenticating-as-a-github-app).
2189
2207
 
2190
2208
  ```bash
2191
2209
  canopycms init-github-app create -- \
@@ -2233,7 +2251,7 @@ downloads the `.pem` from the App's settings page.
2233
2251
 
2234
2252
  **What changed.** The worker re-reads a Secrets Manager secret (the GitHub token or the Clerk secret
2235
2253
  key) when the operation using it fails. Timings, costs and the store-before-revoke order are in
2236
- [Rotating a secret](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#rotating-a-secret).
2254
+ [Rotating a secret](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#rotating-a-secret).
2237
2255
 
2238
2256
  **To adopt.** Nothing for credentials from `*_SECRET_ARN`, which is every scaffolded deployment. A
2239
2257
  GitHub App private key is still read only at boot: store the new key, replace the instance, and
@@ -2287,12 +2305,12 @@ also check the bucket policy for its grant.
2287
2305
  5. `withCanopy()` adds sharp's libvips to Next's file tracing (not for a static export) and, on
2288
2306
  Next 16 and later, sets `turbopack: {}` when your config has neither `turbopack` nor your own
2289
2307
  `webpack` and it can read your Next version. A webpack build still fails its image transforms
2290
- ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#dual-build-support)).
2308
+ ([Dual Build Support](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#dual-build-support)).
2291
2309
 
2292
2310
  **Breaking:** a stack setting `platform` on `fromImageAsset` without `architecture` gets an arm64
2293
2311
  function while `platform` still decides the image, so `Platform.LINUX_AMD64` builds an image the
2294
2312
  function cannot run. A stack setting neither moves to arm64 with a matching image, built under QEMU
2295
- on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#where-the-image-is-built)).
2313
+ on an x86 host ([Where the image is built](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#where-the-image-is-built)).
2296
2314
 
2297
2315
  **To adopt.**
2298
2316
 
@@ -2321,7 +2339,7 @@ reason; `platform` on `fromImageAsset`; and, with `withCanopy()`, a hand-written
2321
2339
 
2322
2340
  **What changed.** `media.uploadUrl` (s3 adapter; an absolute http(s) URL or a site-relative path)
2323
2341
  replaces the `url` that `beginUpload()` returns, leaving the presign's `fields` untouched, so
2324
- uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#media-configuration) for the
2342
+ uploads can be same-origin. See [Media Configuration](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#media-configuration) for the
2325
2343
  CloudFront behavior it expects.
2326
2344
 
2327
2345
  **To adopt.** Optional. Set it from an environment variable: a site-relative value works only where
@@ -2346,7 +2364,7 @@ needs `lazyPublicTransforms: true`) let you pass a deterministically named role,
2346
2364
  bucket's stack computes `arn:aws:iam::<account>:role/<name>` from literals instead of a
2347
2365
  `Fn::GetStackOutput` reference only the CDK CLI resolves. The constructs re-attach
2348
2366
  `AWSLambdaBasicExecutionRole` (and the VPC policy) that `lambda.Function` drops from a role you
2349
- pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#cross-account-asset-bucket).
2367
+ pass. See [Cross-account asset bucket](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#cross-account-asset-bucket).
2350
2368
 
2351
2369
  **To adopt.** Optional:
2352
2370
 
@@ -2456,7 +2474,7 @@ public JWKS PEM, used only to verify signatures.
2456
2474
  to variables (Settings → Secrets and variables → Actions → Variables); `bin/app.ts` refuses the
2457
2475
  deploy at synth while it is unset. Check that `bin/app.ts` passes `CLERK_SECRET_KEY` as
2458
2476
  `clerkSecretKeySecretArn` (read by the worker), never in the Lambda's `environment`, unless you keep
2459
- `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/docs/deploying-to-aws.md#security-model)).
2477
+ `clerkMiddleware` ([Security Model](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/docs/deploying-to-aws.md#security-model)).
2460
2478
 
2461
2479
  #### `readByUrlPath` answers only where `listEntries` publishes — **breaking (routing)**
2462
2480
 
@@ -2555,7 +2573,7 @@ basePath: process.env.NEXT_PUBLIC_BASE_PATH,
2555
2573
  Then pass `baseUrl` to `assetUrl` only if Next serves `/assets` (local adapter, `next dev`, S3 with
2556
2574
  no distribution): `assetUrl(image, { width: 960, baseUrl: BASE_PATH })`. Assets on CloudFront via
2557
2575
  `AssetSupport` stay at the distribution root; pass no `baseUrl` (mount table under "Where `/assets`
2558
- is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#media-configuration)). Two traps:
2576
+ is mounted" in [Media Configuration](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#media-configuration)). Two traps:
2559
2577
 
2560
2578
  - Don't pass a deployment `basePath` to `contentStaticParams({ basePath })`; that option filters by
2561
2579
  a nested route prefix and emits zero params, building green.
@@ -2714,7 +2732,7 @@ Under `exactOptionalPropertyTypes: true`, omit keys instead of assigning `undefi
2714
2732
  `withTrailingSlash` and `isAbsoluteUrl` from `canopycms/server`; `defineSeoFieldGroup()` from
2715
2733
  `canopycms`; `generateContentSitemap` and `entryToMetadata` from `canopycms-next`, bound on
2716
2734
  `createNextCanopyContext`'s result. See
2717
- [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2735
+ [Sitemap and SEO Metadata](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#sitemap-and-seo-metadata). Every routable entry type is in
2718
2736
  the sitemap unless `exclude`d or `noindex`; one `noindex` predicate drives both robots metadata and
2719
2737
  sitemap exclusion. `trailingSlash` is never inferred. `lastModified` defaults to `updatedAt`, a
2720
2738
  filesystem mtime. An empty SEO field counts as unset. `siteUrl` must be absolute, colliding URLs are
@@ -2771,7 +2789,7 @@ underscore-prefixed files are skipped.
2771
2789
 
2772
2790
  **What changed.** New scaffolds write `defaultBranchAccess: 'deny'` and
2773
2791
  `defaultPathAccess: { read: 'allow' }`
2774
- ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#public-read-on-server-deployments)).
2792
+ ([Public read on server deployments](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#public-read-on-server-deployments)).
2775
2793
 
2776
2794
  **To adopt.** An older scaffold's `defaultBranchAccess: 'allow'` is wider than recommended;
2777
2795
  consider `'deny'`. If you deleted `defaultPathAccess: { read: 'allow' }`, anonymous visitors get no content until you
@@ -2824,7 +2842,7 @@ re-checked an entry's type (a `switch` on `meta.entryType` can merge them into o
2824
2842
  **What changed.** `BlockComponentRegistry<Blocks>` (types only, from `canopycms`; `BlockValueOf<Blocks, 'hero'>`
2825
2843
  gives one template's value type) requires exactly
2826
2844
  one component per block template name when written as an object literal. See
2827
- [Block Component Registries](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#block-component-registries) and
2845
+ [Block Component Registries](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#block-component-registries) and
2828
2846
  `apps/example1/app/components/PostView.tsx`.
2829
2847
 
2830
2848
  ```ts
@@ -2846,7 +2864,7 @@ templates against the schema.
2846
2864
 
2847
2865
  **What changed.** Spreading a `const` field array into several schemas, and nesting
2848
2866
  `defineInlineFieldGroup()` inside a block template, are documented
2849
- ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2867
+ ([Reusable Field Fragments](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#reusable-field-fragments)); `defineFieldFragment()` is an
2850
2868
  identity helper for them.
2851
2869
 
2852
2870
  ```ts
@@ -2865,7 +2883,7 @@ field by composing from the same `const` field object.
2865
2883
  A block template holding a `reference` field is a shared block; `read()`/`readByUrlPath()` resolve
2866
2884
  it, and listings do with
2867
2885
  [`resolveReferences`](#listings-resolve-references-and-a-resolved-reference-carries-urlpath-and-optionally-its-body-16--breaking-type-level)
2868
- (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#shared--referenced-blocks).
2886
+ (0.0.64). See [Shared / Referenced Blocks](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#shared--referenced-blocks).
2869
2887
 
2870
2888
  **Now deletable.** A second `read()` in page code to unwrap a shared block's reference.
2871
2889
 
@@ -2887,7 +2905,7 @@ Not retro-documented, apart from these:
2887
2905
 
2888
2906
  #### The registry is keyed by entry-type name (0.0.42)
2889
2907
 
2890
- **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/74c756559271d91a988cf1ce2d250720062efd59/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2908
+ **What changed.** `createEntrySchemaRegistry` keys are the entry-type names that `.collection.json` files name in `entry.schema`, and `EntryTypesFromRegistry` derives the typed entry-type map from them. Schema-variable keys (`{ postSchema }`) still work but derive nothing; [README's registry convention](https://github.com/safeinsights/canopycms/blob/e5dcfc6cc5de00a6e5f215986f460645110fd71c/README.md#convention-why-key-the-registry-by-entry-type-name) says when to keep them.
2891
2909
 
2892
2910
  **To adopt.**
2893
2911
 
@@ -5,6 +5,7 @@
5
5
  import { loadOrCreateBranchContext } from '../branch-workspace.js';
6
6
  import { readsFromCheckout } from '../build-mode.js';
7
7
  import { GitManager } from '../git-manager.js';
8
+ import { AI_USER_ID } from '../system-users.js';
8
9
  import { baseBranchOf } from '../utils/base-branch.js';
9
10
  import { detectHeadBranch } from '../utils/git.js';
10
11
  /**
@@ -36,7 +37,7 @@ export async function resolveBranchRoot(config) {
36
37
  config: resolved,
37
38
  branchName: activeBranch,
38
39
  mode: config.mode,
39
- createdBy: 'canopycms-ai',
40
+ createdBy: AI_USER_ID,
40
41
  remoteUrl: config.defaultRemoteUrl,
41
42
  });
42
43
  return context.branchRoot;
@@ -25,6 +25,12 @@ interface BranchAccessOptions {
25
25
  * private.
26
26
  */
27
27
  isProtectedBranch?: boolean;
28
+ /**
29
+ * Whether this is dev's auto-provisioned active branch ({@link isDevActiveBranch}). It passes
30
+ * this layer where the base branch does, so it reads (and in dev saves) like the base;
31
+ * {@link canPerformWorkflowAction} never passes it, so no workflow rights follow.
32
+ */
33
+ isDevActiveBranch?: boolean;
28
34
  }
29
35
  /**
30
36
  * Check if user has access to a branch with explicit default behavior.
@@ -35,17 +41,17 @@ interface BranchAccessOptions {
35
41
  * 3. An explicit user/group ACL -- an allowlist omitting the creator still
36
42
  * denies them, so an admin can lock down a branch someone else created
37
43
  * 4. With no ACL: the branch creator, then `defaultAccess`, and only where that
38
- * would deny, the protected base branch grant
39
- * (see {@link BranchAccessOptions.isProtectedBranch})
44
+ * would deny, the base branch or dev active branch grant ({@link BranchAccessOptions})
40
45
  * @internal Exported for tests.
41
46
  */
42
47
  export declare function checkBranchAccessWithDefault(context: BranchContext, user: CanopyUser, defaultAccess?: DefaultBranchAccess, options?: BranchAccessOptions): BranchAccessResult;
43
48
  /**
44
49
  * Bind a default access level. `config` is needed only to resolve the
45
50
  * protected-base-branch question, which routes through `getBranchProtection`,
46
- * its single source of truth, rather than repeating the comparison here.
51
+ * its single source of truth, rather than repeating the comparison here, and
52
+ * the dev-active-branch question ({@link isDevActiveBranch}).
47
53
  */
48
- export declare function createCheckBranchAccess(defaultAccess?: DefaultBranchAccess, config?: Pick<CanopyConfig, 'mode' | 'defaultBaseBranch'>): (context: BranchContext, user: CanopyUser) => BranchAccessResult;
54
+ export declare function createCheckBranchAccess(defaultAccess?: DefaultBranchAccess, config?: Pick<CanopyConfig, 'mode' | 'defaultBaseBranch' | 'defaultActiveBranch'>): (context: BranchContext, user: CanopyUser) => BranchAccessResult;
49
55
  /** Options tightening {@link canPerformWorkflowAction} beyond the default hybrid model. */
50
56
  export interface WorkflowActionOptions {
51
57
  /**
@@ -1,6 +1,22 @@
1
1
  import { isAdmin, isLockedOutOfBranch, isReviewer } from './helpers.js';
2
2
  import { getBranchProtection } from './protected-branch.js';
3
- import { SYSTEM_USER_ID } from '../system-users.js';
3
+ import { isSystemUserId, SYSTEM_USER_ID } from '../system-users.js';
4
+ import { sanitizeBranchName } from '../paths/branch-name.js';
5
+ import { baseBranchOf } from '../utils/base-branch.js';
6
+ /**
7
+ * Whether `context` is the active branch a dev server provisioned for itself: owned by a CanopyCMS
8
+ * system user, so nobody is its creator, and named like the active branch now, which follows git
9
+ * HEAD unless configured and is not the base when HEAD has left a configured `defaultBaseBranch`.
10
+ * A person's branch never is.
11
+ * `mode` is the adopter's configured operating mode; a prod deployment's is 'prod', so prod
12
+ * returns before the name comparison and never consults its possibly unresolved base branch.
13
+ */
14
+ function isDevActiveBranch(config, context) {
15
+ if (config.mode !== 'dev' || !isSystemUserId(context.branch.createdBy))
16
+ return false;
17
+ const active = config.defaultActiveBranch ?? baseBranchOf(config);
18
+ return sanitizeBranchName(context.branch.name) === sanitizeBranchName(active);
19
+ }
4
20
  /**
5
21
  * Check if user has access to a branch with explicit default behavior.
6
22
  *
@@ -10,8 +26,7 @@ import { SYSTEM_USER_ID } from '../system-users.js';
10
26
  * 3. An explicit user/group ACL -- an allowlist omitting the creator still
11
27
  * denies them, so an admin can lock down a branch someone else created
12
28
  * 4. With no ACL: the branch creator, then `defaultAccess`, and only where that
13
- * would deny, the protected base branch grant
14
- * (see {@link BranchAccessOptions.isProtectedBranch})
29
+ * would deny, the base branch or dev active branch grant ({@link BranchAccessOptions})
15
30
  * @internal Exported for tests.
16
31
  */
17
32
  export function checkBranchAccessWithDefault(context, user, defaultAccess = 'deny', options) {
@@ -43,6 +58,9 @@ export function checkBranchAccessWithDefault(context, user, defaultAccess = 'den
43
58
  if (options?.isProtectedBranch) {
44
59
  return { allowed: true, reason: 'base_branch' };
45
60
  }
61
+ if (options?.isDevActiveBranch) {
62
+ return { allowed: true, reason: 'dev_active_branch' };
63
+ }
46
64
  return { allowed: false, reason: 'no_acl' };
47
65
  }
48
66
  const userAllowed = hasUserConstraint && access.allowedUsers?.includes(user.userId);
@@ -53,13 +71,15 @@ export function checkBranchAccessWithDefault(context, user, defaultAccess = 'den
53
71
  /**
54
72
  * Bind a default access level. `config` is needed only to resolve the
55
73
  * protected-base-branch question, which routes through `getBranchProtection`,
56
- * its single source of truth, rather than repeating the comparison here.
74
+ * its single source of truth, rather than repeating the comparison here, and
75
+ * the dev-active-branch question ({@link isDevActiveBranch}).
57
76
  */
58
77
  export function createCheckBranchAccess(defaultAccess = 'deny', config) {
59
78
  return (context, user) => checkBranchAccessWithDefault(context, user, defaultAccess, {
60
79
  isProtectedBranch: config
61
80
  ? getBranchProtection(config, context.branch.name, context.branch.baseBranch).isProtected
62
81
  : false,
82
+ isDevActiveBranch: config ? isDevActiveBranch(config, context) : false,
63
83
  });
64
84
  }
65
85
  /**
@@ -7,7 +7,7 @@ export type PermissionPath = string & {
7
7
  };
8
8
  export interface BranchAccessResult {
9
9
  allowed: boolean;
10
- reason: 'privileged' | 'base_branch' | 'creator' | 'allowed_by_acl' | 'denied_by_acl' | 'no_acl';
10
+ reason: 'privileged' | 'base_branch' | 'dev_active_branch' | 'creator' | 'allowed_by_acl' | 'denied_by_acl' | 'no_acl';
11
11
  }
12
12
  export interface PathPermissionResult {
13
13
  allowed: boolean;