# Package Distribution Plan

## Purpose

The Operational Topology Framework is already source-extracted inside this
repository. The next step is to define how it should be distributed as a
package without collapsing the application and the framework into the same
public surface.

This document captures the package boundary, export intent, and release policy
so future implementation work can proceed intentionally.

## Current State

- Framework source entry points live under `src/framework/`
- Labs and presets are separated at the source and package levels
- The application uses the same public boundaries exercised by consumers
- Compiled package output and declaration files are generated by the package
  build
- Stable and beta releases are published on npm through GitHub Actions

## Distribution Goal

The package should expose reusable topology primitives, controllers, and
template layers while keeping application-specific pages and demo content out of
the public package surface.

## Public Entry Points

Recommended package exports:

- `.` - core topology primitives and composition helpers
- `./browser` - DOM integration, navigation controllers, dataset transitions,
  and developer hooks
- `./animations` - reusable animation presets and shared motion helpers
- `./labs` - compatibility alias for animation labs, fixtures, and experimental motion helpers
- `./presets` - reusable production templates and page families
- `./astro/TopologyBackground` - reusable topology background shell
- `./astro/TopologyGrid` - reusable SVG grid renderer
- `./astro/TopologyScene` - reusable interactive Astro scene component
- `./astro/TopologyLayout` - optional document and theme layout starter
- `./astro/ThemeSwitcher` - reusable theme and appearance controls

## Package Boundary

The public package should include:

- axial geometry and grid utilities
- topology and world models
- camera math and viewport helpers
- connector contracts and routing helpers
- signal engine and signal policy contracts
- repository normalization and render-prep utilities
- browser controllers
- reusable animation helpers
- labs compatibility helpers
- reusable presets

The public package should not include:

- application routes
- application content collections
- repository-specific page profiles
- demo-only composition experiments that are not reusable

## Versioning Policy

Recommended release model:

- Start at `0.x` while the API is still being exercised by local application use
- Use semantic versioning for package releases
- Treat `0.y` increments as potentially breaking unless explicitly stabilized
- Reserve `1.0.0` for the first stable public package boundary

## Release Channel Plan

Suggested channels:

1. `canary`
   - Local and CI validation only
   - Fast iteration while the package boundary is still settling
2. `beta`
   - Optional prerelease for an external consumer fixture
   - Used to validate export maps and type declarations
3. `stable`
   - Published only after the package boundary is exercised outside this repo

## Build Output

The package build produces:

- ESM JavaScript
- TypeScript declaration files
- export-map aware entry points
- a consumer-friendly package manifest

## Semantic Release Policy

Recommended release automation:

- Conventional commits for release categorization
- Release notes generated from commit history
- Automated version bumps for feature, fix, and breaking-change classes
- Prerelease tags for canary or beta builds

## Required Follow-Up Work

The next distribution task is validation from a separate consumer fixture:

- install the published package in a clean project
- import the core and browser entry points
- render a topology with nodes and relationships
- run camera, minimap, selection, signal, and dataset transition behavior
- document the supported consumer setup

Existing consumer fixtures in the repository:

- `examples/consumer-demo` - browser-first demo that installs the published package and exercises browseable topology behavior
- `examples/standalone-consumer-demo` - self-contained Docker demo that copies cleanly to another machine and installs the package at image build time

Astro application layouts remain application-owned. The reusable scene layer is exposed through the `./astro/TopologyBackground`, `./astro/TopologyGrid`, and `./astro/TopologyScene` entrypoints.

## Practical Recommendation

The current sequence is:

1. Maintain the source extraction and public entry points.
2. Validate the published package with a separate consumer fixture.
3. Publish beta releases for external testing.
4. Promote compatible changes to stable.


## Publishing Workflow Draft

The repository is set up to publish manually through GitHub Actions once an npm
account and token are available.

### Release channels

- `beta` publishes prerelease versions such as `0.2.1-beta.0`
- `latest` publishes stable versions such as `0.2.1`
- both channels can coexist because they use different version strings and npm
  dist-tags

### Required secret

- `NPM_TOKEN` - npm automation token with publish permission

### Workflow entry point

- `.github/workflows/publish-package.yml`

### Manual publish flow

1. Open the workflow in GitHub Actions.
2. Choose `beta` or `latest`.
3. Provide the version number to publish.
4. Run the workflow against the intended ref, usually `main`.
5. The current release line is `0.2.1` for both channels, with `beta` using prerelease suffixes when needed.

### Release rule

- beta and stable should never try to publish the same version number
- beta gets a prerelease suffix and the `beta` dist-tag
- stable gets the plain semver version and the `latest` dist-tag
