Skip to content

core: add a public module-authoring entry with the path, write and generated-region helpers #1397

Closed

Description

@schlessera

Part of #1345.

Context

Decision (maintainer, 2026-10-09): module authors get a supported @schlessera/brain/module entry, @experimental until 1.0, and first-party modules must use it instead of @schlessera/brain/internal. Recorded on #537.

First-party modules import core's internal entry 19 times. Most-used names: safeResolve (13), writeFileSafely (4), WriteRefusedError, splitFrontmatterBlock, rewriteGeneratedRegion, inertGeneratedText, and the scratch helpers (writeScratchFile, scratchName, SCRATCH_DIR, assertScratchWritable, isInScratch, pruneScratch, isWriteRefusal, resolveWritable). #534 placed them in /internal (docs/decisions/public-export-boundary.md, internal entry list). Any module that writes a document needs them, so a third-party module needs them too.

Blocked by #1355 (the atomic writer settles writeFileSafely before it becomes public API)
Blocked by #1396 (removes the module frontmatter copies first, so both changes do not edit the same import blocks)

Scope

  • Add ./module to core's exports with the helpers above and their signature-reachable types, annotated @experimental.
  • Migrate module-finance, module-images, module-jobs, module-travel and module-video to it.
  • Update docs/modules.md, the integration contract's package-entry section and api-report/core.txt.

Out of scope

Acceptance criteria

  • No module-* package imports @schlessera/brain/internal.
  • A third-party-style fixture module writes a document using only public entries, through the real loader.
  • API report and dist-types checks pass with the new entry.

Verification

bun run test packages/core packages/module-finance packages/module-images packages/module-jobs packages/module-travel packages/module-video
bun run typecheck

Contract impact

Additive public entry: CONTRACT: commit, contract doc updated in the same commit, changeset.

Activity

  1. added
    type: feat
    area: core
    area: modules
    priority: p2
    agent-ready
    blocked
    contract
    on Oct 9, 2026
  2. removed
    blocked
    on Oct 10, 2026
  3. schlessera commented on Oct 10, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #1396 merged in #1453, and the other listed blocker is closed too. Env-core and parseFrontmatter now live in @schlessera/brain-common (./internal/env, ./internal/frontmatter), so the per-package copies are gone from the import blocks this issue touches.

  4. self-assigned this
    on Oct 10, 2026
  5. schlessera commented on Oct 10, 2026

    @schlessera
    OwnerAuthor

    Claimed (token wi-1397-a7). Branch: feat/1397-module-entry.

  6. added this to the 0.41.0 milestone on Oct 10, 2026
  7. added 5 commits that reference this issue on Oct 10, 2026
    70e64a5
    27e9e03
    707300e
    ef458e8
    59d9ef8
  8. schlessera commented on Oct 10, 2026

    @schlessera
    OwnerAuthor

    Delivered in #1466, squash a4120ed2 on main (parent 62cf4d6c; the tree matches the tested PR head 6550e838, and all 15 CI/contract checks passed on that head's merge with this base).

    • @schlessera/brain/module is live, @experimental. It covers the ruled helpers plus everything the modules still took from /internal: buildTaxonomy, getMarkdownFiles, runRegistry, ValidationIssue, and completion-provider resolution (resolveCompletionProvider, geminiCompletions, GEMINI_FLASH_MODEL).
    • CommandContext gains an optional completions. module-video uses it instead of getContext().
    • No module-* file imports /internal any more, in source or tests. tests/module-public-imports.test.ts holds this until ci: extension packages may import only public entry points #1400's lint gate lands.
    • A third-party-style fixture module writes a document through the real loader using only public entries (packages/core/tests/module-entry.test.ts). The PR records the failing-first and mutation receipts.

    For the #537 inventory: the extra names beyond the 2026-10-09 ruling are listed in the PR's "Anything left open". #1434 and #537 are unblocked.

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

Metadata

Metadata

Assignees

Labels

agent-readyarea: corearea: modulescontractpriority: p2type: feat

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions