Skip to content

feat(patchy): start tier 1 patches with Preact - #423

Merged
allisonmahmood merged 3 commits into
mainfrom
tier2/392-preact-scaffold
Oct 1, 2026
Merged

allisonmahmood merged 3 commits into
mainfrom
tier2/392-preact-scaffold

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

New tier 1 patches need a ready-to-use Preact page and clear guidance on which SDK code can run in the browser.

Switch the starter to patchy/preact, enforce page imports in dev and publish, and generate release-bound skills and capability announcements. Existing vanilla repos remain supported, and refresh leaves authored source alone.

Stacked on tier2/391-neon-object-storage. This PR contains only the #392 implementation above that branch and follows spec #384.

Verification

  • Typecheck and lint passed.
  • Packed CLI end-to-end acceptance passed, including fresh installation, Preact interactions and vanilla publishing. Real browser saves and refresh JSON were exercised.
  • All 10 import-refusal scenarios passed; standards and spec review findings were resolved.
  • The full offline suite ran once: 94/96 test files passed initially. Fixed two dev-server fixtures, then both affected files and all three tests passed. The Postgres timeout passed unchanged in isolation. No second full-suite run.

Implemented with OpenAI GPT-6 Astra (openai-codex/gpt-6-astra) in the omp harness.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:xl Over 1,000 changed lines; review in multiple passes labels Sep 28, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed 0bf0be7 against origin/tier2/391-neon-object-storage at 013c945, using #392 and #384 §12–13. Two merge blockers.

Standards

No merge-blocking method or YAGNI findings.

Spec

  1. [P1, intent] Keep existing vanilla repos buildable. pageImports.ts:134–140

    feat(patchy): the Preact scaffold on tier 1, the page-graph import check and the patchy-preact skill #392 requires: “A vanilla repo keeps working on the framework-free core client.” The previous scaffold's Vite config uses viteSingleFile() without build.modulePreload: false. Vite therefore injects vite/modulepreload-polyfill, which this hook rejects as a company dependency. A page containing only document.body.textContent = "vanilla" fails with import_refused, naming package vite and importer index.html. Both the one-shot build and build-watch fail, blocking publish and dev for unchanged vanilla repos after refresh.

    Keep Vite-generated imports outside the company-import restriction. Cover the previous scaffold's config unchanged; the new vanilla acceptance scenario replaces the page source but retains the new config's modulePreload: false, hiding this regression.

  2. [P2, intent] Check transitive CSS imports before they are inlined. pageImports.ts:80–98

    feat(patchy): the Preact scaffold on tier 1, the page-graph import check and the patchy-preact skill #392 requires: “bare imports resolve only to the page entry points. Anything else is import_refused”. The CSS check inspects the directly transformed stylesheet, but Vite's CSS pipeline resolves nested @import statements separately. Reproduction: main.ts imports ./style.css; that imports ./nested.css; nested.css imports lodash/style.css from an installed package. Both build and build-watch succeed without a refusal and emit the package's CSS into index.html. I observed its marker in the output: body{--off-sdk-marker:423;color:red}.

    Validate imports in every reachable stylesheet before CSS inlining, with the refusal pointing to the stylesheet that imports the package. This is a gap in the promised build contract, not a security-boundary claim.

Verification used isolated temporary repos and the real runToolchain Vite build/build-watch paths. No full-suite run or repository edits.

Summary: Standards 0, no blocker; Spec 2, worst is P1 because unchanged vanilla repos can no longer dev or publish.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Opus review

Reviewed origin/tier2/391-neon-object-storage...HEAD against #392 and spec #384 §12, §13 and §19, and the SDK decision (r302). Findings are ranked most severe first.

1. Correctness: every existing tier 1 repo is now import_refused in dev and publish

packages/patchy/src/pageImports.ts:134-136. Vite 8 prepends import "vite/modulepreload-polyfill" to the HTML entry of any page with a module script unless build.modulePreload is false (vite/dist/node/chunks/node.js:31311). resolveId then sees a bare import with index.html as the importer, and check refuses it at line 70.

The tier 1 vite.config.ts scaffold that this PR replaces never set modulePreload: false, and refresh never touches vite.config.ts. So every tier 1 repo created before this change fails dev and publish with:

Package "vite" (import "vite/modulepreload-polyfill") in index.html is not a page entry point. ... anything else, write or copy into your patch as your company's own code.

The same thing happens when a tier 0 repo moves to tier 1, or when a builder drops that line from their own config. The message sends the agent after a dependency it never imported. This breaks the issue's "a vanilla repo still publishes".

I reproduced it with the worktree's Vite 8.3.0, vite-plugin-singlefile and pageImports, building an index.html + src/main.ts page. With the old config the build refuses as above. With build: { modulePreload: false } it builds.

The vanilla case in scripts/packed-cli-e2e.mjs:3708 and the cli tests both start from the new scaffold's vite.config.ts, so neither catches this.

Fix: treat Vite's own injected id (vite/modulepreload-polyfill) as toolchain, not page code, and exempt it in check. Then add a test that publishes a page with the old vite.config.ts.

2. Correctness: the "What the SDK gives you" rendering has no test, and existing skill coverage was deleted

packages/sdk/src/SdkApi.test.ts:634. The PR deleted the loop that checked each served skill against its canonical file and checked name: / description: frontmatter. It did this for every skill, not only patchy-loop, so the new patchy-preact skill's frontmatter is now unchecked.

Nothing replaces it. Generation.ts:375 fills the section with contents.replace("<!-- sdk-capabilities -->", ...). If the marker is edited or dropped, the replace silently does nothing. patchy-loop would then ship without the catalogue while every import_refused message points agents at it (pageImports.ts:46).

This section is a core deliverable of #392 (r302 point 16). Keep the canonical comparison, with the marker substituted for patchy-loop, and assert the rendered loop skill contains ## What the SDK gives you and all four groups.

3. Correctness: refresh now hard-fails against an instance whose release predates capability metadata

packages/patchy/src/Project.ts:594-598. The capability decode runs in the invoking CLI (the pre-refresh pin), not in the installed child. If a repo pinned to this release or later refreshes against an instance on an earlier release, generation returns an index.json without capabilities. Refresh then fails with "Generation returned no SDK capability metadata" and rolls back.

Before this PR that refresh worked. Now the repo cannot move back without a hand edit. That is a one-way door (CLAUDE.md, "Reverse states") and it is easy to hit while switching between stacked-branch dev instances.

Fix: treat missing capabilities as [], the same way the previous index already is at line ~541, and announce nothing.


Checked and fine:

  • The scaffold matches the issue: tsconfig and oxc JSX settings, modulePreload, no router or state library, and refresh leaves src/ alone.
  • The import check covers aliased, dynamic, re-export, CSS, path-into-node_modules and server/ imports, and resets per watch build.
  • The lint bans react, react-dom and direct preact.
  • patchy-preact is seeded on tiers 1 and 2, and tier 0 is unchanged.
  • The capabilities catalogue lands in index.json, refresh --json returns addedCapabilities, and ADR-0004, the README, product.md, the Publishing glossary and the global skill are updated.
  • The skills-lock.json hash matches sha256sum skills/patchy/SKILL.md.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review

PR 423 is the #392 slice of spec #384: a tier 1 Preact starter, a page-graph import_refused in dev and publish, the patchy-preact skill, and a release catalogue rendered into patchy-loop. The scaffold, the shared Vite check, the glossary, ADR-0004, and the packed end-to-end run are the right size for that ticket. Standards and spec are separate below, then the method and YAGNI notes.

Standards

Hard. packages/sdk/skills/patchy-loop/SKILL.md step 2 tells every repo to read ../patchy-preact/SKILL.md and to import the client from src/App.tsx. packages/sdk/src/Generation.ts adds patchy-preact only for tiers 1 and 2, which docs/SKILL_DISTRIBUTION.md also states. Tier 0 init creates neither that skill nor src/App.tsx. The loop file is one template. Generation only replaces the <!-- sdk-capabilities --> marker, so a tier 0 agent is sent to a missing skill.

Hard. That same distribution doc says AGENTS.md points agents at the generated skills. The starter AGENTS.md in packages/patchy/src/initProject.ts names loop, tables, files, postgres, and shared tables, and skips patchy-preact. ADR-0004 says refresh does not rewrite AGENTS.md, so init is the only chance to name it. packages/patchy/README.md under Agent skill still describes the core project skills as loop, tables, and files.

No Effect service violation. pageImports and sdkCapabilities stay modules, which is the right call for one consumer and a pure table. Project.refresh still takes its dependencies from the environment, and new failures use the existing LocalError.

Judgement calls:

  • owned in packages/patchy/src/pageImports.ts is true for any file outside the SDK directories, including third-party modules. The name reads as "company file".
  • ESLint, typescript-eslint, and eslint-plugin-react-hooks are version literals in starterFiles. ADR-0004 keeps the other scaffold ranges in toolchain.json so one record feeds init and the toolchain check. These three sit outside that record.
  • The tier 1 App.tsx sample reads notes in an effect and renders an empty list plus an error line. patchy-preact tells the agent to show a loading state and to drop a stale response. The sample does neither.
  • Tier 0 still ships the old notes page as src/main.ts while tier 1 repeats that flow in App.tsx. Tier 0 index.html never loads the module. Two starters is fine. A shared notes component would be a third copy.

patchy/csv on the allow list looks spare. ADR-0004 reserves it for the helper ticket and says it is not shipped, so that smell is suppressed.

Spec

The in-scope text is issue #392 plus the #384 clauses that ticket owns: §12's page graph, §13's tier 1 tree, and the §19 skill and glossary lines. Later tickets stay later. This diff does not add init --tier 2, a server-graph check, a workerd pin, members, a CSV implementation, shared stores, or tier 2 publish.

Present and matching:

  • Tier 1 gets index.html with an empty root, src/main.tsx, src/App.tsx, jsx: react-jsx, jsxImportSource: "patchy/preact", isolatedModules, verbatimModuleSyntax, Vite oxc.jsx.importSource: "patchy/preact", and build.modulePreload: false. No router, CSS framework, state library, test runner, or @preact/preset-vite. Tier 0 HTML stays the static page.
  • Dev and publish refuse an off-entry page import with local import_refused, exit 1. The message names the package, the importer, the allowed entries, and the company-code rule, and it points at "What the SDK gives you". package.json is not the checked file.
  • patchy-preact is seeded on tiers 1 and 2. It says Preact with compat semantics, names synchronous transitions and the missing scheduler, says never import react, and does not point at upstream Preact docs.
  • Generation fills patchy-loop with Core, Primitives, Integrations, and Helpers, and the loop skill tells the agent to talk through edge cases with the person before building.
  • refresh announces added capabilities, with where each runs and its limits, in the text output and in --json addedCapabilities.
  • docs/product.md (SDK paragraph and Building a patch), the Publishing glossary (Patchy SDK, Core, Helper, Company code), ADR-0004, the global skill, and skills-lock.json are updated.
  • The exact Preact 10.29.8, @preact/signals 2.11.2, and signals-core pins were already on the base. This PR sets jsxImportSource to patchy/preact and does not re-bundle them.

Wrong. #392 asks for eslint-plugin-react-hooks with additionalHooks for useQuery. The starter sets that option on react-hooks/rules-of-hooks:

"react-hooks/rules-of-hooks": ["error", { additionalHooks: "^useQuery$" }],

In eslint-plugin-react-hooks 7.1.1, rules-of-hooks lists additionalHooks in its schema and create() never reads rule options. It reads settings["react-hooks"].additionalEffectHooks, and only to decide that a call is an effect. useQuery is already a hook because the name starts with use, which is why the packed probe still fails a conditional call. Putting the same option on exhaustive-deps would mis-read useQuery(handler, args). That rule treats the first argument as a callback and the next as a dependency list. The comment in the starter already says useQuery is not that shape. Delete the dead option.

Wrong. ADR-0004, added in this PR, says a bare package import fails with import_refused even when aliased to a local file. Vite's resolvePlugins installs resolve.alias before user enforce: "pre" plugins, so pageImports resolveId sees the rewritten path. The TypeScript walk still refuses import, export … from, and import(), which is why cli.test.ts stays green for an aliased import "lodash". The walk does not classify require("…"), import.defer("…"), or import x = require("…"). With an alias to a local file, those forms build. import.defer is a real import under the tier 1 verbatimModuleSyntax setting, so typecheck does not catch it. Dev and publish share this plugin.

In scope, and worth keeping: CSS @import is part of the page graph, and the Postgres skill no longer tells a page to import patchy/config or patchy/client. The generated client re-exports isPatchyError for that reason.

Issue 392

The ticket wants init to hand an agent a tier 1 Preact page, and dev and publish to stop any other page import with the company-code rule, pointed at a catalogue for this release. A new tier 1 repo does that. refresh leaves src/ alone. A vanilla repo still publishes. import "lodash" is import_refused in both commands, and the packed end-to-end run typechecks and publishes the starter.

The loop instructions are the miss against that intent. Step 2 assumes every repo has patchy-preact and src/App.tsx. Tier 0 has neither. The loop says pnpm typecheck and never pnpm lint, so an agent can miss the hooks config entirely. Publish does not run eslint. The import check is the gate the "done when" line names. The lint is a second tool the agent is not pointed at.

refresh --json naming new capabilities is implemented. A second refresh returns []. A repo with no capability ids records the whole catalogue once, which docs/SKILL_DISTRIBUTION.md states on purpose. The test checks runs and limits with expect.any(String), and the import_refused test never asserts the company-code sentence. The message does contain it.

Method

One Vite plugin, used by dev and by publish, is the small way to refuse page imports. The second parse earns its place. Alias rewriting runs before this plugin's resolveId, and the TypeScript walk is what still sees the original specifier on import and import(). Removing the walk would let an aliased import "lodash" through, which the current test forbids. The hole above is the same walk stopping at three node kinds. Extend it. A new parser is not needed. TypeScript is already in the CLI.

The catalogue is hand-written because "where it runs" and the limits are sentences. Generation stamps the same array into the loop skill and index.json. Refresh diffs stable ids. The text matches the release that generated it, and it matches the SDK when someone edits sdkCapabilities.ts.

The part that is heavier than the ticket needs is the package direction. sdkCapabilities.ts has no imports. Generation.ts is what renders it. @patchy/sdk moved patchy from devDependencies to dependencies so it can import patchy/sdk-capabilities. The server depends on @patchy/sdk, so the server now depends on the CLI package. Refresh reads capability ids from the generated index. The table belongs next to Generation.

YAGNI

Keep the starter. One empty root, one JSX import source, modulePreload: false, a short eslint file, no router and no state library. Keep one catalogue and the id diff on refresh. Keep the type-only exception and the server/ refusal.

The Helpers group, the "not in this release" paragraphs, and patchy/csv on the page entries stay. #392 asks for those four groups. #384 §12 lists patchy/csv as a page entry and says the missing helpers are stated as facts. ADR-0004 already says that import is reserved.

The deletion that loses no #392 behavior is the additionalHooks option on rules-of-hooks. The linter's result does not change.

Summary

Standards: 2 hard findings, 4 judgement calls. Worst: the shared loop skill sends tier 0 to patchy-preact and src/App.tsx, which init does not create.

Spec: the #392 slice is in place aside from 2 wrong implementations. Worst: require, import.defer, and import-equals skip import_refused when a Vite alias rewrites the specifier. The additionalHooks option is unused by the plugin version the starter pins.

Reviewed with Grok 4.7 in the Grok harness, eight read-only passes over 013c9455...0bf0be7.

allisonmahmood added a commit that referenced this pull request Sep 28, 2026
Address PR #423 review findings for current scaffold and CLI behavior without legacy release migration support.
@allisonmahmood

allisonmahmood commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner Author

Review fixes are in eaeb854; the integration-test deadline repair is in bf0467c.

Reviewed Astra, Opus and Grok's conversation comments, plus the Reviews tab and inline-comment API. There were no review bodies or inline comments at the time of triage.

Fixed

  • Vite preload injection: distinguish the toolchain's injected helper from authored page imports. This matters for a repo created by today's tier 0 scaffold and changed to tier 1, not just old repos. Direct authored imports remain refused.
  • Nested CSS and aliased module syntax: check reachable stylesheets before inlining, including watch rebuilds, and classify require, import-equals and deferred imports before aliases rewrite their specifiers. Diagnostics name the importing file. Renamed the ambiguous owned predicate.
  • Tier-specific instructions: the loop now distinguishes static tier 0, Preact and vanilla pages. Scaffold agent instructions name the Preact skill conditionally, the README lists it, and the skills tell builders to run the supplied lint script.
  • Catalogue generation and ownership: fail generation if the template marker is missing; exercise the served catalogue and failure response. Moved the catalogue into @patchy/sdk and removed the CLI export/runtime dependency.
  • Hook lint: removed the ignored additionalHooks option. useQuery is recognized by its name; configuring it as an effect would misinterpret its handler and argument object. Valid query calls and invalid conditional hooks remain covered by packed acceptance.
  • Starter async state: show pending reads/saves, ignore the initial read after unmount, and block writes during pending work so the initial read cannot overwrite a later save. The browser acceptance delays a real read response to exercise this state.

Kept as is

  • Refresh to pre-metadata releases: no compatibility fallback. Nothing is deployed; a release served by the current code must return capability metadata. Missing target metadata remains a generation-contract failure. No old-repo migration added.
  • Canonical-copy/frontmatter snapshots: not restored. These check copies rather than behavior. Added generated-output and missing-marker failure coverage instead.
  • Lint version ranges: kept as scaffold defaults with one consumer. ESLint packages belong to the builder and are not loaded by dev/publish; adding them to the public release-toolchain schema would add metadata without another consumer.
  • Tier 0's unused vanilla starter module: unchanged to preserve feat(patchy): the Preact scaffold on tier 1, the page-graph import check and the patchy-preact skill #392's tier 0 scope. It is not loaded by the static page; no shared-component abstraction or third starter was added.
  • Reserved CSV and later-tier features: unchanged. The catalogue still states what is unavailable; this PR does not implement CSV or hosted tier 2 execution.

Local verification

  • pnpm typecheck and pnpm lint passed.
  • All 263 tests passed across the CLI, dev lifecycle/server, real Vite page graph and SDK API suites.
  • pnpm test:packed-cli-e2e passed, including delayed real-read UI state, valid/invalid hook lint, fresh init, local/hosted Preact interactions and vanilla publishing.
  • Separate browser smoke on the real local shell: held a real table-read response, observed the loading notice and disabled controls, then saved two visible rows with the button and Enter. No error remained. Stopped the patch/cloud processes and removed the disposable repo and caches.
  • The two integration cases that exceeded CI's five-second default both passed after adopting the existing 30-second integration allowance. All assertions and production timeouts are unchanged.

CI

The first run on eaeb854 passed seven checks, including the full Node 24 suite and Node 22 packed smoke. Node 22's full suite exceeded the five-second test deadline in the harmless-CSS publish and Postgres runtime cases. bf0467c fixes those two test deadlines.

All eight reported checks now pass on bf0467c15e764605daad1eb7bf2425cc73b3aa3e: full offline tests on Node 22 and 24, lint/typecheck/format, packed CLI and Preact smoke, Postgres concurrency, live Clerk, dependency review and PR labels. CI run.

GitHub reports MERGEABLE / CLEAN against tier2/391-neon-object-storage. This target has no separately configured required checks; every reported check is green. Rechecked conversation comments, review bodies and inline comments after the final push; no new findings. No unresolved blockers. The PR remains unmerged.

@github-actions github-actions Bot added the area:integrations Company connections and integration implementations label Sep 28, 2026
@allisonmahmood
allisonmahmood force-pushed the tier2/391-neon-object-storage branch from 013c945 to c240955 Compare October 1, 2026 01:01
Base automatically changed from tier2/391-neon-object-storage to main October 1, 2026 01:14
Implement #392 with tier 1 scaffolding, page-graph import refusals, SDK capability discovery, and release-bound Preact guidance.
Address PR #423 review findings for current scaffold and CLI behavior without legacy release migration support.
Use the existing 30-second integration deadline for the two cases that exceeded Vitest's five-second default on Node 22. Keep all assertions and production timeouts unchanged.
@allisonmahmood
allisonmahmood force-pushed the tier2/392-preact-scaffold branch from bf0467c to 7343267 Compare October 1, 2026 01:14
@allisonmahmood
allisonmahmood merged commit 7793ac2 into main Oct 1, 2026
8 checks passed
@allisonmahmood
allisonmahmood deleted the tier2/392-preact-scaffold branch October 1, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:integrations Company connections and integration implementations area:server Touches the server area size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(patchy): the Preact scaffold on tier 1, the page-graph import check and the patchy-preact skill

1 participant