Skip to content

M2-01: Decide Web runtime and freeze module boundaries #22

Closed

Description

@pillowtalk-Qy
Type: Architecture Decision
Priority: P0 / trust boundary
Initial status: Needs Decision
Owner: App/API + Maintainer
Depends on: current architecture/security docs
Blocks: M2-03, M2-04, M2-09, M2-11, all UI
Writable: decision Issue; accepted 后 ADR/spike files

唯一目标

通过 Node 22 compatibility spike 选择 Web runtime,并冻结模块 ownership 和依赖方向。

比较方案

A. Next.js App Router + Node runtime + single process
B. React/Vite + Fastify
C. Vite/static + minimal Node server

建议 A,但只能由 build/deploy/Moss SDK/ESM spike 支持后接受。

固定模块边界

report-schema      contracts only
decision-engine    pure decision only
moss-adapter       Moss/Monad I/O and raw mapping only
preflight-core     alignment, decision input, report assembly
clear402-profile   optional report consumer only
web/server         orchestration and presentation only

验收

[ ] 三方案 build/deploy/test/SDK 风险比较
[ ] Node 22 + pnpm 11 + ESM + production build spike 通过
[ ] server-only Moss code 不进入 browser bundle
[ ] CLEAR402_ENABLED=false 独立路径明确
[ ] API response owner 明确
[ ] raw evidence 不由 UI 重写
[ ] Local Fork 是 SHOULD,不阻塞 Live + Fixture
[ ] Maintainer Accepted

验证

pnpm install --frozen-lockfile
pnpm build
pnpm typecheck
pnpm check

Codex 指令

做最小 runtime compatibility spike 和 ADR 比较,不搭完整 UI。
输出 bundle/server boundary、production start、Moss import 和部署风险证据。
Maintainer 未接受时不得继续生成 app/package skeleton。

Activity

  1. pillowtalk-Qy commented on Jul 30, 2026

    @pillowtalk-Qy
    ContributorAuthor

    Direction selected: Option A

    Maintainer direction date: 2026-07-30

    Selected runtime direction

    Use Next.js App Router + Node runtime + one deployable Node process as the proposed Web runtime.

    The production baseline is a normal Node server or container. Edge runtime is not the baseline. Core Preflight execution uses explicit Route Handlers; Server Actions do not own the core API.

    Frozen boundary direction

    report-schema      contracts only
    decision-engine    pure decision only
    moss-adapter       Moss/Monad I/O and raw mapping only
    preflight-core     alignment, decision input, report assembly only
    clear402-profile   optional report consumer only
    web/server         orchestration and HTTP/presentation boundary only
    

    Allowed internal dependency direction:

    decision-engine  -> report-schema
    moss-adapter     -> report-schema + pinned Moss/Monad dependencies
    preflight-core   -> report-schema + decision-engine
    clear402-profile -> report-schema
    web/server       -> moss-adapter + preflight-core
    web/client       -> report-schema type/schema boundary only
    

    The browser must not import moss-adapter, preflight-core, pinned Moss packages, RPC configuration, or server environment variables. The canonical report contract is owned by report-schema; preflight-core assembles and validates it; the Web route owns only request validation, HTTP status, and transport; UI code owns presentation only and cannot rewrite raw evidence.

    CLEAR402_ENABLED=false must keep the core report path independent. clear402-profile may consume a completed report only when enabled and cannot alter Core evidence or Decision semantics.

    Acceptance remains pending

    This comment selects the direction but does not mark M2-01 Accepted. Option A must first pass the required Node 22, pnpm 11, ESM, production build/start, server-only bundle, Moss import, disabled-Clear402, clean-start, and deployment compatibility spike.

    The spike may use the documented exact Moss upstream candidate as temporary compatibility evidence while M2-03 remains blocked. That candidate is not the final pinned integration dependency.

    If Moss cannot be imported and executed in the Next.js Node production build, server-only code enters the browser bundle, or the selected Node deployment cannot run the required Moss/RPC path without unsupported workarounds, the recorded fallback is Option B: React/Vite + Fastify, preferably two development processes and one Fastify production process serving the built frontend.

    M2-01 remains status:needs-decision until the spike evidence is linked and the Maintainer posts a separate Accepted or Rejected decision.

  2. pillowtalk-Qy commented on Jul 30, 2026

    @pillowtalk-Qy
    ContributorAuthor

    Node 22 compatibility spike: Option A evidence

    Result: the selected Option A is technically supported: Next.js App Router with Node runtime can import the pinned Moss candidate in server-only routes and run as one Node process.

    Reproducible environment

    • Moss candidate: da9b566f9b607c28633b3790a44ae8d49522b269
    • Node: 22.23.1
    • pnpm: 11.10.0
    • Web dependency versions: Next 16.2.12, React/React DOM 19.2.3

    Evidence

    1. pnpm install and pnpm build completed for Moss plus the temporary Next workspace under Node 22.
    2. next build produced a production App Router build.
    3. A Node-runtime, server-only route imported @themoss/core, @themoss/simulator, @themoss/protocol-kuru, and @themoss/protocol-pancakeswap; production HTTP response reported all four imports as true.
    4. next start served the production build in one Node process.
    5. Static browser output contained no @themoss, moss, or clear402 references; Moss references appeared only in .next/server.
    6. With CLEAR402_ENABLED unset/false, the dedicated route returned 404; no Clear402 module was imported.

    Controlled deployment condition

    Next resolved sharp@0.34.5. Moss pnpm supply-chain policy initially blocked Sharp's install script, so the temporary spike only added allowBuilds.sharp: true after explicit review. A real app must either carry the reviewed, pinned allowlist entry or demonstrate that the chosen Next configuration removes the dependency. Do not bypass the policy.

    Boundary and residual risks

    • This is runtime/ESM/bundle evidence, not an implementation skeleton; the temporary workspace is not committed.
    • The final vendor/submodule and dependency-link strategy remains owned by the later integration work; this spike used Moss workspace links only.
    • Options B and C were not implemented as comparable spikes. The positive conclusion is that A meets its required compatibility proof, not that B/C are impossible.

    Decision request: record Maintainer acceptance of Option A, then freeze the stated module ownership in the architecture ADR before app implementation begins.

  3. pillowtalk-Qy commented on Jul 31, 2026

    @pillowtalk-Qy
    ContributorAuthor

    Maintainer decision: Accepted

    Option A is accepted for the Mini-Demo architecture based on the Node 22 compatibility evidence above.

    The following is now frozen:

    • Next.js App Router using the Node runtime.
    • One deployable Node process for web and server orchestration.
    • Moss imports remain server-only and must not enter browser bundles.
    • CLEAR402_ENABLED=false remains a complete, independently working path.
    • Module ownership and dependency direction remain exactly as listed in this Issue.
    • API/report ownership stays outside the UI; the UI must not rewrite raw evidence.
    • Local Fork remains a SHOULD and does not block Live + Fixture delivery.

    The reviewed sharp build-script allowlist requirement must be handled explicitly in the implementation. Final Moss vendor/submodule linkage remains owned by the later integration work. Options B and C are not technically invalid, but are rejected for this Mini-Demo because Option A has now passed the required compatibility proof with less operational surface.

    This comment constitutes Maintainer acceptance for #22.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions