Skip to content

docs(bb-agent, hosting, core, blocks): move self-contained README sections into topic files; fix stale statements - #1496

Closed
xyos wants to merge 4 commits into
aws:mainfrom
xyos:docs/readme-size
Closed

xyos wants to merge 4 commits into
aws:mainfrom
xyos:docs/readme-size

Conversation

@xyos

@xyos xyos commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The largest block READMEs are each about 75–140 KB: core 140 KB, hosting 90 KB, bb-agent 85 KB, bb-auth 78 KB, and the @aws-blocks/blocks guide 49 KB. A reader who opens one pays for all of it, even though parts of it serve a narrower audience. Three sections are self-contained material of that kind:

  • bb-agent's Model Configuration spends 14 KB on preset tables, guardrails, health checks, API keys, Bedrock account access and Mantle. package.json already lists a MODELS.md in files, but the file does not exist.
  • hosting's "Bring your own front door" is a 12 KB guide for people writing a door with defineFrontDoor, not for apps that pick a built-in door.
  • the guide's "Migrating an app from aws-blocks/scripts" spends 9.4 KB on apps scaffolded by create-blocks-app 0.1.0 to 0.4.0. Current templates no longer generate those wrappers.

While measuring them, four statements turned out to contradict the code, and one code sample did not compile:

  • core's "Production (frontend hosted separately)" says every allowedOrigins entry is a regex, that an invalid regex falls back to a literal match, and that https://app.example.com also matches https://appXexample.com. The section above it and cors.ts say otherwise.
  • core's Pipeline pointer names no link target.
  • bb-agent recommends the deprecated useChat for subscribe-before-send ordering.
  • bb-agent's InvalidModelConfig row omits two cases that throw it.
  • bb-agent's three useChat samples forward sub with return channel.subscribe(sub), which fails tsc --strict. sub is ChatChunkHandler | ChatSubscribeOptions, and neither RealtimeChannel.subscribe overload accepts the union.

Issue #, if available:

Changes

One commit per README; each has its own changeset (patch).

  • blocks (guide): the migration bullets move verbatim into a new root-level MIGRATING-FROM-SCRIPTS.md, added to files. The README keeps the heading (the create-blocks-app README deep-links it), the two cdk-blocks migrate commands and a pointer to the file. It also keeps, verbatim, what a user needs to run migrate safely: when it refuses to run and --force/--dry-run, that a customized wrapper is never deleted, when deploy/destroy are kept, what happens when a wrapper cannot be deleted, the exit codes, and the two scripts that behave differently afterwards. 49,079 → 42,249 bytes.

  • bb-agent: the seven Model Configuration subsections move verbatim into MODELS.md. Their headings go up one level, and one link back to the README's Local Development is retargeted. The README keeps the model option table and the deployed/local/fallback examples. It also keeps, verbatim, the facts needed before deploying: the global-profile data-residency caveat; the one-time Anthropic and AWS Marketplace steps, the AccessDeniedException delay, opt-in Regions, and global vs regional profiles; that a health check doesn't prove invoke access; and Mantle's local and deployed permissions, apiKey precedence and Chat Completions-only model support. The useChat React example repeated the createChat one. It now links to that example and keeps the guarded useChat(...) construction and the facts that differ for useChat: the react-hooks lint false positive, the resume adapter, the { id, name, reason } interrupt shape and the Next.js note. The two stale statements are fixed; the InvalidModelConfig row keeps main's sessionScope: 'shared' sentence. The three useChat samples' subscribe adapter now narrows first (typeof sub === 'function' ? channel.subscribe(sub) : channel.subscribe(sub)), with no cast, and still forwards sub unchanged. 84,604 → 74,315 bytes.

  • hosting: "Bring your own front door" moves verbatim into CUSTOM-FRONT-DOOR.md, added to files. The README keeps the heading, a summary of what the file covers, a link from the front-door table, and what AWS Blocks checks and enforces for such a door:

    • an http:// url with an API fails a production synth (PlainHttpFrontDoorError) and warns in a sandbox, unless the door sets allowPlainHttp: true;
    • the wiring check's synth errors and warnings (ServeStaticAsset, ProxySameOriginApi, FrontDoorRuleUnwired, FrontDoorBehaviorLimit, MissingFrontDoorUrlError, and wiringCheck: false);
    • that features such as waf are not checked;
    • the 10 KB CloudFront Function limit;
    • serverResponse: 'buffered';
    • the 403 on request bodies through a Function URL with origin access control.

    90,027 → 81,116 bytes. Look hardest here: feat(hosting): let a front door route at the app (routing: 'app') #1245 adds a subsection inside this section, so this commit is self-contained and can be dropped if you'd rather wait for feat(hosting): let a front door route at the app (routing: 'app') #1245.

  • core: the production CORS subsection now says that a plain origin is matched exactly and that an invalid entry fails synth. It links to the allowedOrigins rules above it. Its example and regex table are unchanged, and the table's patterns are still valid. The Pipeline pointer links to the pipeline README. 140,634 → 140,381 bytes.

Across the four READMEs: −26,283 bytes. The three new topic files add 33,411 bytes, so the total shipped docs grow slightly. What changes is how much a reader of each README has to get through. Every moved line is present verbatim in its new file, and every new file ships in its package and, through gen-block-docs.mjs, in @aws-blocks/blocks/docs/.

The bb-auth commit of the earlier head is dropped: it said that on AWS the password-reset marker is read with an eventually consistent GetItem. Since #1453, KVStore.get() is strongly consistent by default (ConsistentRead unless consistentRead: false, bb-kv-store/src/index.aws.ts), and Sessions.isRevoked reads the marker with no options, so the README's "from the next request on … on AWS" is true as it stands. This PR no longer touches the bb-auth README.

Related PRs

Merged since the previous head, now in its base (main dabb3f22f):

Open:

Validation

Head 261b7f752, rebased on main dabb3f22f (after #1596), Node 22.23.1. The rebase from dfc4a306b was clean: none of the six new main commits touches a file this PR changes, and the moved sections still match main line for line. The local checks below ran on earlier heads with the same docs tree. The pre-push checks below ran one main commit earlier (ddae81525) and before the useChat adapter fix. The main commit in between changes only native/swift/Demo/typescript-demo/package.json, and the fix changes only three lines of packages/bb-agent/README.md and its changeset.

Before pushing:

  • npm ci: pass; no lockfile churn.
  • npm run build: every workspace builds. Locally, the last step (admin-ui's next build) stops with Next.js 16.4.2's upgrade notice for a known Next.js security advisory, which Next shows only outside CI; re-running npm run build -w @aws-blocks/admin-ui passes.
  • npm run lint:deps: pass (664 files).
  • npm run check:api: all API reports up to date.
  • npm run sync-docs:check: catalog up to date.
  • packages/blocks npm test: 566 tests, 555 pass, 3 skipped, 8 fail. That includes readme-links and docs-pointers (pass) and conditional-exports (pass). The 8 failures are all in "signals sent to the CLI while a child runs". 7 log EMFILE: too many open files, watch …/dist/cli/runners/dev-server.js, because this machine had no inotify instance left. The eighth ("records how its dev server runner ended") fails an assertion with no EMFILE line; its cause is unconfirmed. CI runs these tests on its own runners. This PR adds no tests.

After pushing, on this head (local):

  • npm test: 13,680 tests, 13,641 pass, 25 fail, 10 skipped, 4 cancelled.
    • 4 failures are the create-blocks-app auth-oidc template tests from CI shard 3 (fix(create-blocks-app): align auth-oidc template with template checks #1596).
    • 12 are core's dev-server lifecycle and pidfile tests (4 more were cancelled with them). Each logs EMFILE: too many open files, watch: this machine had no inotify instance left, and a bare fs.watch('.') throws EMFILE here.
    • 8 are cdk-blocks dev signal tests. 7 log the same EMFILE. The eighth ("records how its dev server runner ended") fails an assertion with no EMFILE line; its cause is unconfirmed.
    • 1 is hosting's watchHostingValues() ("watcher did not regenerate with the new config key"). It logs no EMFILE, and the secret typegen falls back to polling when fs.watch fails, so its cause is unconfirmed.
    • None of these tests read the docs. CI's Local Unit Tests shards 1 and 2 pass on this head.
  • npm run test:e2e:local: 539 tests, 0 pass, 10 fail, 524 cancelled, 5 skipped. The comprehensive app's dev server exits with code 1 right after "Generating client code", before it is ready. The log shows no other error, so the cause is unconfirmed. CI's Local E2E job passes on this head.

CI on this head: all green, 24 pass, 21 skipped, 0 fail (gh pr checks --watch exit 0). Local Unit Tests (shard 3) passes now that the merge commit includes #1596.

Also checked on this head:

  • The moved sections were diffed again against current main. MIGRATING-FROM-SCRIPTS.md and CUSTOM-FRONT-DOOR.md carry main's current section text byte for byte under a one-line intro. Every line of the seven bb-agent subsections is in MODELS.md, except the retargeted Local Development link.

  • Every relative link and #anchor in the four READMEs, the bb-auth README and the three topic files resolves. Outside MODELS.md, nothing links to the headings that moved.

  • The packages/blocks build writes docs/MIGRATING-FROM-SCRIPTS.md, docs/bb-agent/MODELS.md and docs/hosting/CUSTOM-FRONT-DOOR.md, byte-identical to the sources. npm pack --dry-run lists each topic file in its own package.

  • The CORS statements were checked against the built packages/core/dist/cors.js:

    • the four table patterns pass validateCorsOriginEntry;
    • a plain https://app.example.com is matched exactly and case-insensitively, and doesn't match https://appXexample.com;
    • a regex with an unescaped . is rejected;
    • a top-level | alternation stays anchored.
  • The new hosting bullet was checked in hosting_construct.ts: a custom door whose URL is http://, with an API, throws PlainHttpFrontDoorError outside a sandbox, warns with @aws-blocks/hosting:PlainHttpAllowedInProduction under allowPlainHttp: true, and warns with @aws-blocks/hosting:PlainHttpFrontDoor in a sandbox.

  • The useChat samples were type-checked with tsc --strict against the built @aws-blocks/bb-agent/client and the Agent types. api was typed from the backend methods. The React snippet, the End-to-End frontend and the deprecated-hook sample all pass. The React snippet fails when api is removed. The End-to-End sample fails with the old adapter line (TS2769). An earlier version of this description claimed the React snippet type-checked; that check was too loose, and this one replaces it.

  • The README edits after the first pre-push run touch only packages/bb-agent/README.md (the adapter lines) and its changeset. Those three lines are inside code fences, so no link or anchor check reads them. The docs suites passed on this head in the three-way combined check and in CI.

Checklist

  • PR description included
  • Tests are changed or added (docs only; existing guards cover the links and the shipped docs)
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@changeset-bot

changeset-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 261b7f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@aws-blocks/bb-agent Patch
@aws-blocks/blocks Patch
@aws-blocks/core Patch
@aws-blocks/hosting Patch
@aws-blocks/create-blocks-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@xyos
xyos force-pushed the docs/readme-size branch 3 times, most recently from e845b25 to 1df6207 Compare November 13, 2026 20:26
@xyos
xyos marked this pull request as ready for review November 13, 2026 20:37
@xyos
xyos requested a review from a team as a code owner November 13, 2026 20:37
@xyos xyos changed the title docs(bb-agent, hosting, core, bb-auth, blocks): move self-contained README sections into topic files; fix stale statements docs(bb-agent, hosting, core, blocks): move self-contained README sections into topic files; fix stale statements Nov 17, 2026
xyos added 4 commits November 17, 2026 20:36
The guide README spends 9.4 KB on migrating apps scaffolded by
create-blocks-app 0.1.0 to 0.4.0 from aws-blocks/scripts wrappers, which
current templates no longer generate. The section's bullets move verbatim
into a root-level MIGRATING-FROM-SCRIPTS.md, added to files so it ships in
the package and in docs/. The README keeps the heading (deep-linked from the
create-blocks-app README), the two migrate commands, when migrate refuses
to run, what it never deletes, what happens when a wrapper cannot be
deleted, its exit codes, the two scripts that behave differently
afterwards, and a pointer.

Validation: packages/blocks build; readme-links and docs-pointers tests 2/2;
the bundled docs/ copy is byte-identical to the source.
The README's Model Configuration section spent 14 KB on preset tables,
guardrails, health checks, API keys, Bedrock account access and Mantle.
Those subsections move verbatim into MODELS.md, which package.json files
already listed but which did not exist. The README keeps the model option
table and examples, links each moved section, and keeps the facts a reader
needs before deploying: the global-profile data-residency caveat, the
one-time Anthropic and Marketplace steps, that a health check does not
prove invoke access, and Mantle's local and deployed permissions, apiKey
precedence and Chat Completions-only model support.

The useChat React example repeated the createChat one; it now links to it
and keeps the useChat-only facts (lint false positive, the resume adapter,
the { id, name, reason } interrupt shape, Next.js). Two stale statements
are fixed: the README recommended the deprecated useChat for
subscribe-before-send ordering (index.hooks.ts marks it deprecated in
favour of createChat), and the InvalidModelConfig row omitted trustable
with interrupt (agent.ts) and guardrail on a non-bedrock provider
(model-factory.ts).

The useChat samples' subscribe adapter, `return channel.subscribe(sub)`,
did not compile under strict: sub is ChatChunkHandler |
ChatSubscribeOptions, and neither RealtimeChannel.subscribe overload takes
the union. All three samples now narrow with typeof sub === 'function'
and still forward sub unchanged.

Validation: every README/MODELS.md link and anchor resolves; every line
of the moved subsections is present verbatim in MODELS.md, except the
one retargeted Local Development link. The React useChat snippet, the
End-to-End frontend and the deprecated-hook sample type-check with tsc
--strict against the built @aws-blocks/bb-agent client and the Agent
types (api typed from the backend methods); the React snippet fails when
api is removed, and the End-to-End sample fails with the old adapter line.
…R.md

The 12 KB guide to writing a door with defineFrontDoor is for door authors,
not for apps that pick a built-in door, and nothing in the repository links
into it. It moves verbatim into a root-level CUSTOM-FRONT-DOOR.md, added to
files so it ships in the package and in the umbrella's docs/. The README
keeps the heading, a summary of what the file covers, a link from the
front-door table, and what AWS Blocks checks and enforces for such a door:
an http:// url with an API fails a production synth
(PlainHttpFrontDoorError) unless the door sets allowPlainHttp: true, the
wiring check's synth errors and warnings (ServeStaticAsset,
ProxySameOriginApi, FrontDoorRuleUnwired, FrontDoorBehaviorLimit,
MissingFrontDoorUrlError), that features such as waf are not checked, the
10 KB CloudFront Function limit, serverResponse: 'buffered', and the 403 on
request bodies through a Function URL with origin access control.

Validation: every moved line is present verbatim; npm pack --dry-run lists
CUSTOM-FRONT-DOOR.md.
The "Production (frontend hosted separately)" CORS section contradicted the
"allowedOrigins entries" section above it and the code. It said every entry
is a regex, that an invalid regex falls back to a literal match, and that
https://app.example.com also matches https://appXexample.com. In cors.ts a
plain origin is matched exactly and case-insensitively (isLiteralOrigin),
an invalid entry fails synth (validateCorsOriginEntry) and is dropped and
logged at runtime (parseCorsPatterns). The section now states that and
links to the rules; its example and regex table are unchanged and still
valid. The Pipeline section's pointer, which named no target, now links to
the pipeline README.

Validation: against the built dist/cors.js, the four table entries pass
validateCorsOriginEntry, a plain https://app.example.com does not match
https://appXexample.com, an unescaped-dot regex is rejected, and a
top-level | alternation stays anchored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant