@su-sws/synthetic-web-team 0.2.8 → 0.2.9

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/README.md CHANGED
@@ -24,7 +24,7 @@ Early. The plan is complete and reviewed; the implementation is partway through.
24
24
  | `next-ssr` recipe | Written, extends `astro-static`. Renamed from `next-netlify` on 2026-09-03. Not yet executed end to end |
25
25
  | Hosting profiles | **New.** `standards/hosting/`: a capability contract plus GitHub Pages, Netlify, and Vercel |
26
26
  | Shared skills | **12 of 12 done**, including `sws-github` (provisions a repo and Pages deploy through `gh`), `sws-preflight` (is this machine equipped?) and `sws-code-review` |
27
- | Role skills | **8 of 8 built, 11 of 11 stubs.** 31 skills total, all validated |
27
+ | Role skills | **19 of 19 built.** The 11 former stubs became full roles on 2026-12-03. 31 skills total, all validated |
28
28
  | Documentation site | **Working.** [`site/`](site/), built by our own recipe, scores 100/100 with zero failures |
29
29
  | `sws` CLI | **Working.** `preflight` reports whether the machine has the tools to build at all. `doctor` and `check` run 13 check modules against 68 criteria. `sws a11y` runs axe and an interactive-state audit — hover and focus measured with a real mouse and a real Tab key — and `sws perf` measures a byte budget, all in real Chromium. `--format brief` prints the report as one line of JSON for an agent working in a loop, `--no-history` leaves the score history alone, and `prior-art find` searches the catalog of existing SWS work. Those three are newer than the published 0.2.7 and reach npm with the next release |
30
30
  | Report delivery | **Working.** PR comment and a persistent "Site health" issue, both updated in place. Score trend, sparkline, HTML artifact, README badge |
@@ -312,7 +312,7 @@ node packages/cli/bin/sws.mjs doctor --standards standards
312
312
  | Path | What it does |
313
313
  |---|---|
314
314
  | [`AGENTS.md`](AGENTS.md) | The behavioral contract: the block between the `sws-agent-contract` markers, at most 150 lines, read by every tool. The rest of the file is about this repository and does not ship |
315
- | [`skills/`](skills/) | The team: 31 skills, each one `SKILL.md` with two frontmatter keys. 8 built roles, 11 honest stubs, 12 shared |
315
+ | [`skills/`](skills/) | The team: 31 skills, each one `SKILL.md` with two frontmatter keys. 19 roles, 12 shared |
316
316
  | [`standards/policy/`](standards/policy/) | Stanford requirements: MinSec, MinWeb, accessibility, privacy, brand, identity, procurement, escalation. Each file carries a `reviewed:` date |
317
317
  | [`standards/patterns/`](standards/patterns/) | How SWS actually builds: Decanter, components, content, IA, forms, discoverability, plus conventions derived from reading 11 production repos |
318
318
  | [`standards/stack/`](standards/stack/) | `reference-versions.yml`, a dated baseline. Advisory — nothing installs from it. Plus `performance-budget.yml`, the byte budget `sws perf` enforces |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@su-sws/synthetic-web-team",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Stanford Web Services standards and agent team: policy, patterns, recipes, fragments, prior art, 31 skills, the two-part install wizard, and the advisory compliance CLI.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -1,65 +1,123 @@
1
1
  ---
2
2
  name: role-api-architect
3
- description: API design and integration for Stanford systems. Use when designing an API, consuming a Stanford data source, or integrating with MaIS Registry, Workgroup, or other university APIs. NOT YET IMPLEMENTED as a full role, but the Stanford integration facts are here.
3
+ description: Data integration and API design for Stanford sites. Use when a site consumes a Stanford data source (events, news, profiles, MaIS Registry, Workgroup API), when designing a build-time fetch or scheduled snapshot, when shaping a small endpoint a site exposes, or when someone asks how to get university data onto a page.
4
4
  ---
5
5
 
6
- # API architecture
7
-
8
- **Status: stub. Full role lands in v2.** v1 sites consume data at build time and
9
- expose no APIs.
10
-
11
- ## Stanford APIs, which is the part worth knowing now
12
-
13
- **MaIS Registry APIs** cover Account, CourseClass, Person, Privilege and
14
- Authority, Student, and Workgroup. Two things surprise people:
15
-
16
- - **Authentication is x509 mutual TLS**, not an API key and not OAuth. You submit
17
- a CSR to the MaIS Certificate Manager and the resulting certificate is added as
18
- a workgroup admin for access.
19
- - **Access requires data-owner approval** plus an intake ticket. This has a lead
20
- time measured in weeks, not hours, so it belongs in discovery rather than in
21
- the build.
22
-
23
- **Workgroup API 2.0** is JSON, at `workgroupsvc.stanford.edu/workgroups/2.0/`
24
- with a UAT equivalent. This is how Stanford authorisation actually works: you ask
25
- whether someone is in a workgroup rather than maintaining your own list. There is
26
- also an AWS API Gateway variant.
27
-
28
- Person data from these APIs is almost certainly **Moderate or High risk**, which
29
- changes the compliance tier of anything that stores it. Consuming an API is not a
30
- neutral technical decision.
31
-
32
- ## Prefer build-time consumption
33
-
34
- On a static Stanford site, fetch at build and commit nothing sensitive. This
35
- avoids credentials in the browser, avoids a runtime dependency on a university
36
- service being up, and keeps the compliance tier low.
37
-
38
- The pattern that works: build-time fetch, webhook or scheduled rebuild for
39
- freshness. `adapt-directory` shows a more involved version, turning an OpenAPI
40
- spec into TypeScript types and enum options via a codegen pipeline, plus a mock
41
- server for local development when the upstream API is unavailable. That mock
42
- server pattern is worth stealing.
43
-
44
- ## If you are designing an API rather than consuming one
45
-
46
- That is squarely v2 and probably not a website project. Two notes for now:
47
-
48
- - Stanford has an established authorisation primitive in workgroups. Do not invent
49
- a parallel permission model.
50
- - Secrets belong in HashiCorp Vault, which is the SWS norm, not in environment
51
- files.
52
-
53
- For general API design judgment, the `engineering:architecture` and
54
- `engineering:system-design` skills cover ADRs and service boundaries without
55
- Stanford specifics.
56
-
57
- ## What to do now
58
-
59
- Name the mutual-TLS requirement and the approval lead time early, because both
60
- routinely surprise people and both can delay a launch. Propose build-time
61
- consumption. Route data access requests through the proper intake per
62
- `standards/policy/escalation.md`, noting those routes still need confirming.
63
-
64
- Do not store person data because it was easy to fetch. Ask what the site actually
65
- needs to display.
6
+ # API architecture and data integration
7
+
8
+ On a Stanford unit site this role is mostly about **consuming** university data
9
+ safely, not designing APIs. The house shape is build-time consumption, and the hard
10
+ parts are permissions, approvals, and data risk rather than HTTP.
11
+
12
+ ## Default shape: fetch at build, never from the browser
13
+
14
+ The connector shape in `standards/connectors/README.md` is the starting point for
15
+ any external data:
16
+
17
+ 1. **Fetch at build time or on a schedule**, never from the visitor's browser. No
18
+ key reaches the browser, a source outage does not break a page, and the content
19
+ is in the built HTML where `sws a11y` can see it.
20
+ 2. **Snapshot into the repo.** A scheduled Actions job writes a data file and commits
21
+ it to `main`, which deploys. Every content change goes through the checks.
22
+ Fetching at build without committing is the alternative: fewer commits, no git
23
+ history of the content.
24
+ 3. **Credentials live in Actions secrets**, never in the repo or the build output.
25
+ 4. **Link back to the source.** The source stays authoritative.
26
+ 5. **Permission belongs to the system owner.** Being able to reach an API is not the
27
+ same as being allowed to depend on it.
28
+
29
+ Whether a snapshot counts as "content from the repo" is an open call for SWS
30
+ (`standards/scope.md`). Say that if it matters to the decision.
31
+
32
+ ## Before you integrate: five questions
33
+
34
+ Ask these in discovery. Each one can delay a launch by weeks if it surfaces late.
35
+
36
+ 1. **What does the page actually need to show?** Fetch that, not the whole record.
37
+ 2. **Who owns the source, and have they agreed?** If the owner is unknown, use the
38
+ general UIT contact and say so.
39
+ 3. **What risk class is the data?** Person data is almost certainly Moderate or High
40
+ risk, which changes the tier of anything that stores it.
41
+ 4. **What authentication does the source require, and how long does access take?**
42
+ 5. **What happens when the source is down or changes shape?** The build should fail
43
+ loudly or keep the last good snapshot, never publish an empty page.
44
+
45
+ ## Stanford sources
46
+
47
+ | Source | What is known | Status |
48
+ |---|---|---|
49
+ | **Events**, events.stanford.edu (Localist) | Public API confirmed reachable | Connector stub |
50
+ | **News**, news.stanford.edu | API not yet located | Connector stub |
51
+ | **Profiles**, cap.stanford.edu (CAP) | Access not yet confirmed | Connector stub |
52
+ | **MaIS Registry APIs** | Account, CourseClass, Person, Privilege and Authority, Student, Workgroup | See below |
53
+ | **Workgroup API 2.0** | JSON, at `workgroupsvc.stanford.edu/workgroups/2.0/`, with a UAT equivalent and an AWS API Gateway variant | See below |
54
+
55
+ None of the connectors is a tested integration. Read the connector file, use what is
56
+ known, and **do not invent endpoints, fields, or credentials.**
57
+
58
+ ### MaIS Registry and Workgroup, which surprise people
59
+
60
+ - **Authentication is x509 mutual TLS**, not an API key and not OAuth. You submit a
61
+ CSR to the MaIS Certificate Manager and the certificate is added as a workgroup
62
+ admin for access.
63
+ - **Access requires data-owner approval** plus an intake ticket, with a lead time in
64
+ weeks. It belongs in discovery, not the build.
65
+ - **Workgroups are Stanford's authorisation primitive.** You ask whether someone is
66
+ in a workgroup instead of keeping your own list.
67
+
68
+ Say the mutual-TLS requirement and the approval lead time early. Both routinely
69
+ delay launches.
70
+
71
+ ## Designing the integration
72
+
73
+ - **Type the boundary.** Validate the fetched payload against a schema at build
74
+ time, so a changed upstream fails the build instead of rendering `undefined`.
75
+ `adapt-directory` turns an OpenAPI spec into TypeScript types via codegen, which is
76
+ worth borrowing when a spec exists.
77
+ - **Mock the source for local work.** `adapt-directory` also runs a mock server for
78
+ when the upstream is unavailable. That pattern is worth stealing.
79
+ - **Keep the last good snapshot.** If a scheduled pull fails, do not commit an empty
80
+ file. Leave the previous one and surface the failure.
81
+ - **Normalise once.** Map the source's fields to the site's content model in one
82
+ place, so the templates never see the upstream shape.
83
+ - **Store less.** Do not keep person data because it was easy to fetch. Ask what the
84
+ site needs to display.
85
+
86
+ ## If the site exposes an endpoint
87
+
88
+ Small endpoints on `astro-ssr` or `next-ssr` (a search route, a form handler) are in
89
+ scope and owned by `role-backend-developer`. Design notes:
90
+
91
+ - One job per endpoint, a stable URL, and errors as structured JSON with a useful
92
+ message.
93
+ - No authentication you invented. Stanford has workgroups and SSO; see
94
+ `role-identity-engineer`.
95
+ - No personal data in query strings, which end up in logs and referrers.
96
+
97
+ A standalone API with its own consumers is a different project from a website and
98
+ outside this package. The `engineering:architecture` and `engineering:system-design`
99
+ skills cover general design without Stanford specifics.
100
+
101
+ ## When reviewing an integration
102
+
103
+ - Is the data fetched at build or on a schedule, and nowhere in the browser?
104
+ - Has the source owner agreed, and is that recorded?
105
+ - What risk class is the data, and did the tier move?
106
+ - Are credentials in Actions secrets or Vault, and absent from the build?
107
+ - Does a broken or changed source fail visibly without publishing an empty page?
108
+ - Does each item link back to its canonical source?
109
+
110
+ ## Artifacts
111
+
112
+ | Artifact | Path |
113
+ |---|---|
114
+ | Data snapshots | `src/data/` |
115
+ | Fetch scripts | `scripts/`, so CI can call them |
116
+ | Scheduled workflow | `.github/workflows/` |
117
+ | Source, owner, and data class | `.sws/manifest.yml` under `divergences:` |
118
+
119
+ ## Escalation
120
+
121
+ Data access requests route through the source's intake. For a Data Risk Assessment
122
+ or an unknown owner, route per `standards/policy/escalation.md`; those routes still
123
+ need confirming, so use the general contact and say that is what you are doing.
@@ -1,69 +1,156 @@
1
1
  ---
2
2
  name: role-backend-developer
3
- description: Server-side development for a Stanford site. Use for APIs, server logic, databases, forms that submit somewhere, webhooks, serverless functions, or CMS back ends. NOT YET IMPLEMENTED as a full role, because v1 sites are static by design.
3
+ description: Server-side development for a Stanford site. Use for form handlers, search endpoints, redirects and rewrites, response headers, serverless or edge functions, scheduled data pulls, webhooks, or any question about whether a site needs a back end at all. Covers the server surface the astro-ssr and next-ssr recipes allow; CMS back ends are out of scope.
4
4
  ---
5
5
 
6
6
  # Back-end development
7
7
 
8
- **Status: stub. Full role lands in v2 with the Drupal recipe.** v1 targets static
9
- sites, which have no server-side surface on purpose.
8
+ A Stanford unit site usually has very little back end, and the job is keeping it
9
+ that way on purpose. Every route you add is something to patch under MinSec for as
10
+ long as the site lives, and some routes move the compliance tier.
10
11
 
11
- ## First, ask whether you need a back end
12
+ ## What is in scope
13
+
14
+ `standards/scope.md` puts a server runtime in scope for four things, and content
15
+ still comes from the repo:
16
+
17
+ | Need | Where it lives | Notes |
18
+ |---|---|---|
19
+ | **Response headers** | Host config, not code | The default set is in `standards/hosting/capabilities.yml`. **You do not need a server runtime for headers**: a static build on Netlify or Vercel gets them from host config |
20
+ | **Redirects and rewrites** | Host config first | Same. A runtime only earns its place for redirects that depend on the request |
21
+ | **Search** | A build-time index, or a server route | A build-time index adds no third party. A hosted search service does, and that is a DRA question |
22
+ | **Forms** | A host form feature, a function, or a route handler | A tier question before it is a code question. See below |
12
23
 
13
- On a Stanford unit site the answer is often no, and reaching for one adds a
14
- compliance tier, an attack surface, and something to patch forever.
24
+ Anything else on the server side, such as fetching content from a backend, is a
25
+ CMS by another name and is out of scope (`standards/scope.md`). Out of scope is not
26
+ forbidden: if the unit needs one, say so plainly. Do not build half of one.
27
+
28
+ ## First, ask whether you need a back end
15
29
 
16
30
  Common requirements that do **not** need one:
17
31
 
18
- - **Content that changes often.** Edit it in the repo: a commit to `main` from
19
- the GitHub web UI rebuilds the site, and it stays static. A CMS with a
20
- webhook-triggered rebuild is out of scope for this package right now, not
21
- forbidden (`standards/scope.md`). If the unit needs one, say so rather than
22
- wiring one up.
23
- - **Search.** Algolia DocSearch is hosted and free for public education content.
24
- - **A contact form.** A hosted form service, or a Netlify function, beats standing
25
- up an application.
26
- - **Restricting content to a few people.** See `role-identity-engineer`. Often the
27
- answer is not publishing it rather than authenticating it.
28
-
29
- ## What a back end costs you
30
-
31
- Adding server-side logic that handles personal data or authenticates users moves
32
- the compliance tier from `low` to at least `moderate`: Duo, centralised logging,
33
- secure SDLC with code review and static analysis, annual developer training,
34
- weekly encrypted backups. Payments or regulated data means `high`, plus a Data
35
- Risk Assessment before deployment.
36
-
37
- Say that out loud before writing the first route. It is usually the decisive fact.
38
-
39
- ## Prior art, when v2 arrives
40
-
41
- Two established patterns at SWS, both Decanter 7 era so borrow architecture and
42
- not CSS. **Both are CMS-backed and therefore out of scope for this package right
43
- now** (`standards/scope.md`) — they are recorded here because the record is
44
- useful and because the scope is expected to widen, not because you should wire
45
- one up today:
46
-
47
- - **Decoupled Drupal**: `cardinalsites-nextjs`, `csp-nextjs`, `summer-nextjs` use
48
- `graphql-request` plus `graphql-codegen` against Drupal. `sulgryphon-nextjs`
49
- uses `next-drupal` instead. All four run `--webpack` rather than Turbopack —
50
- a point-in-time decision rather than a forward choice. **Turbopack is the
51
- forward default for new Next.js work.**
52
- - **Storyblok**: the ADAPT and OOD family. `ccc-bulletin` is the current-version
53
- reference at `@storyblok/react` 6.x.
54
-
55
- For serverless, SWS uses Netlify functions, edge functions, and blobs. Secrets come
56
- from HashiCorp Vault via `node-vault` or `netlify-plugin-vault-variables`, never
57
- from `.env` in production.
58
-
59
- `adapt-online-giving` is the most complex server-side surface in the set: Stripe,
60
- `adapt-auth-sdk`, Upstash Redis, TanStack Form, transactional email. It is
61
- high-risk-tier work, so read it for patterns and never cite it as a template for a
62
- unit site.
63
-
64
- ## What to do now
65
-
66
- State that server-side work is outside v1, propose a static-compatible approach if
67
- one exists, and if it genuinely does not, name the tier change and route to UIT
68
- Security. Do not quietly add an API route and hope nobody notices the compliance
69
- implications.
32
+ - **Content that changes often.** A commit to `main` from the GitHub web UI rebuilds
33
+ the site and keeps it static.
34
+ - **Headers and redirects.** Host config, as above.
35
+ - **Search on a small site.** A static index generated at build time.
36
+ - **A contact form.** A `mailto:` link or a link to an existing central form is
37
+ often the cheapest compliant answer. Offer it before building anything.
38
+ - **Restricting content.** See `role-identity-engineer`. Often the answer is not
39
+ publishing it.
40
+
41
+ If nothing on the list needs a server, recommend `astro-static` and stop. The
42
+ recipes say the same: `output: 'static'` with a host adapter still gets headers,
43
+ redirects, and preview URLs.
44
+
45
+ ## Forms, which is where tiers move
46
+
47
+ A form that collects personal information moves the site from `low` to
48
+ `moderate`, with the obligations in `standards/policy/minsec.md`: Duo, centralised
49
+ logging, secure SDLC, annual training, weekly encrypted backups. A third-party form
50
+ endpoint is also a new third-party service, which triggers a Data Risk Assessment
51
+ per `standards/policy/privacy.md`.
52
+
53
+ So before writing a handler:
54
+
55
+ 1. **Ask what each field is for.** Delete the ones nobody can justify.
56
+ 2. **Name the tier change, once, plainly.** Record it in `.sws/manifest.yml` under
57
+ `tier` and `tier_because`.
58
+ 3. **Decide where submissions go.** GitHub Pages has no server, so it needs a
59
+ third-party endpoint. On Netlify, Netlify Forms or a function. On a server
60
+ recipe, a route handler.
61
+ 4. **Put the transparency notice before the form**, per MinPriv.
62
+ 5. **Then** write the handler.
63
+
64
+ The markup, labels, errors, and the opt-in `decanter/forms` import are in
65
+ `standards/patterns/forms.md`. Front-end owns those; you own what happens after
66
+ submit.
67
+
68
+ ### Writing the handler
69
+
70
+ - **Validate on the server.** Client validation is a courtesy, not a control.
71
+ - **Return errors the form can render inline**, field by field, and never discard
72
+ what the user typed.
73
+ - **Rate-limit and add a spam control** proportionate to the form. Do not reach for
74
+ a third-party CAPTCHA without noting it is a third-party service.
75
+ - **Log the event, not the payload.** Personal data in logs is still personal data.
76
+ - **Send nothing to the client it does not need.** A success message, not an echo of
77
+ the record.
78
+ - **Fail closed and visibly.** A handler that swallows an error loses a submission
79
+ silently, and nobody finds out until someone complains.
80
+
81
+ ## Secrets
82
+
83
+ Secrets come from HashiCorp Vault, the SWS norm, never from a committed `.env`.
84
+ `node-vault` is the host-portable option; `netlify-plugin-vault-variables` is the
85
+ Netlify build-plugin route. Scheduled jobs keep credentials in Actions secrets.
86
+
87
+ **Any key in a static build is public.** If a value reaches the browser bundle, treat
88
+ it as published. Committed credentials are the one blocking check in this system;
89
+ if one lands on `main`, **rotate first**, then clean history.
90
+
91
+ ## Scheduled data pulls and webhooks
92
+
93
+ The connector shape in `standards/connectors/README.md` is the house pattern: fetch
94
+ at build time or on a schedule, never from the visitor's browser, snapshot into the
95
+ repo so the content goes through `sws a11y`, and link back to the source. All three
96
+ connectors there are stubs; do not invent endpoints, fields, or credentials.
97
+
98
+ A webhook receiver is a public endpoint. Verify the sender's signature, make the
99
+ handler idempotent, and keep it doing one thing. A CMS publish webhook is deferred
100
+ with the CMS (`standards/scope.md`).
101
+
102
+ ## Recipe specifics worth knowing
103
+
104
+ - **Astro:** `output: 'server'`, not `'hybrid'`, which was removed. Opt pages back
105
+ into prerendering individually. **Do not set headers in middleware**: it does not
106
+ run for prerendered routes, so some pages get headers and some do not.
107
+ - **Next:** a static export forfeits headers, redirects, Proxy, Server Actions, and
108
+ makes Route Handlers `GET`-only. If you want a static export, you want
109
+ `astro-static`.
110
+ - **Changing hosts** means moving secrets, redirects, and headers too, not only the
111
+ adapter.
112
+
113
+ Read the recipe in `standards/recipes/` before improvising; it is more current than
114
+ this file.
115
+
116
+ ## Prior art, for the shape and not the wiring
117
+
118
+ Check `sws prior-art find "<what you are building>"` first. Most SWS server-side
119
+ work is CMS-backed and Decanter 7 era, so borrow architecture, not CSS or CMS
120
+ wiring:
121
+
122
+ - **Serverless at SWS** is Netlify functions, edge functions, and blobs.
123
+ - **Decoupled Drupal** (`cardinalsites-nextjs`, `csp-nextjs`, `summer-nextjs` with
124
+ `graphql-request`; `sulgryphon-nextjs` with `next-drupal`) and **Storyblok**
125
+ (`ccc-bulletin` at `@storyblok/react` 6.x) are a factual record, not a recipe
126
+ here. The four Drupal repos run `--webpack`; **Turbopack is the forward default**.
127
+ - **`adapt-online-giving`** (Stripe, `adapt-auth-sdk`, Upstash Redis, TanStack Form,
128
+ transactional email) is high-tier work. Read it for patterns; never cite it as a
129
+ template for a unit site.
130
+
131
+ ## When reviewing back-end code
132
+
133
+ - Does this route need to exist, or would host config or a build step do?
134
+ - Did the tier change, and is it recorded with a reason?
135
+ - Is input validated server-side, and are errors returned per field?
136
+ - Does anything personal reach logs, the client, or a third party?
137
+ - Are secrets read from Vault or Actions secrets, with nothing in the bundle?
138
+ - Are headers set in host config rather than middleware?
139
+ - Is the new dependency something you are willing to patch within 7 days?
140
+
141
+ ## Artifacts
142
+
143
+ | Artifact | Path |
144
+ |---|---|
145
+ | Server routes | `src/pages/api/` (Astro) or `app/**/route.ts` (Next) |
146
+ | Host config | `netlify.toml`, `vercel.json`, or the adapter config |
147
+ | Tier and reason | `.sws/manifest.yml` |
148
+ | Third parties and divergences | `.sws/manifest.yml` under `divergences:` |
149
+ | Operations runbook | `docs/ops/runbook.md`, shared with `role-devops` |
150
+
151
+ ## Escalation
152
+
153
+ A tier change or a new third-party service routes to UIT Security for the DRA, per
154
+ `standards/policy/escalation.md`. That route is still marked as needing
155
+ confirmation, so use the general contact and say so. Do not recommend or rank form,
156
+ search, or database vendors: state the obligation, name the office, stop.