# Operational Topology Framework

OTF means Operational Topology Framework.

OTF is an experimental framework for exploring connected knowledge as an
operational world.

The project combines Markdown-authored content, a persistent axial hex grid,
relationship-aware navigation, transient signals, camera controls, an Inspector,
responsive interaction patterns, and semantic themes.

Start here:

- [Framework API](docs/FRAMEWORK_API.md) for the package boundaries and core entry points.
- [Creating Your First OTF Presentation](docs/FRAMEWORK_API_HELLO_WORLD_DECK.md) for a step-by-step first deck.
- [OTF Elements Cheat Sheet](docs/OTF_ELEMENTS_CHEATSHEET.md) for a compact element reference.

The grid is the spatial model:

- cells are atomic spatial units
- entities occupy cells
- relationships connect occupied cells
- signals communicate transient activity
- the camera changes observation, not world state
- the Inspector explains the currently focused entity

## Current Status

This repository contains the framework implementation and a demonstration
application. It is an active prototype and a published npm package, but it is
still an experimental public API.

Implemented systems include:

- axial hex-grid primitives and viewport-derived cell generation
- normalized Markdown content through Astro content collections
- persistent operational world and selection state
- configurable straight, shortest-axial, and obstacle-aware relationship routing
- ambient, origin, path, receiving, broadcast, and resolved signal states
- reusable animation presets including the deterministic radialSignal awareness scan
- camera fitting, focus visibility, pan, zoom, persistence, and minimap controls
- synchronized topology and Inspector navigation
- desktop, tablet, and touch-oriented mobile presentation
- eight runtime-switchable semantic themes
- reduced-glow, high-contrast, and color-safe appearance modes
- one canonical SVG renderer for initial output and viewport rebuilds
- a development-only inspection and control API

Further connector work includes bundling, congestion handling, and richer
multi-hop visualization. The framework has scoped core, browser, lab, and
preset entry points, a declarative composition factory, and a reusable dataset
transition contract. The API remains experimental and is published on npm.

## Architecture

```text
Markdown
  -> Astro Content Collections
  -> Knowledge Repository
  -> Operational World Model
  -> Grid Occupancy
  -> Camera and Visible Cells
  -> Prepared Render Frame
  -> SVG Render Layers
  -> Interaction and Navigation
  -> Inspector
```

The core architectural rules are:

1. Axial coordinates remain canonical.
2. World state is independent of viewport size.
3. Renderers consume prepared state and do not define domain meaning.
4. Responsive layouts change observation, not the underlying world.
5. Markdown owns authored knowledge.
6. Semantic tokens own visual expression.

Detailed specifications live in [docs](docs/), including:

- [Architecture](docs/ARCHITECTURE.md)
- [Architecture Atlas](docs/ARCHITECTURE_ATLAS.md)
- [Framework API](docs/FRAMEWORK_API.md)
- [Render Pipeline](docs/RENDER_PIPELINE.md)
- [Developer API](docs/DEVELOPER_API.md)
- [Framework Presets Plan](docs/FRAMEWORK_PRESETS_PLAN.md)
- [Signal Specification](docs/SIGNAL_SPEC.md)
- [Navigation Specification](docs/NAVIGATION_SPEC.md)
- [Camera Specification](docs/CAMERA_SPEC.md)

## Project Structure

```text
src/
├── config/
├── components/
│   ├── theme/
│   ├── topology/
│   └── world-map/
├── content/
├── framework/
├── layouts/
├── pages/
├── styles/
├── theme/
└── topology/
```

Published package entry points:

- `operational-topology` - environment-neutral core contracts
- `operational-topology/browser` - DOM, navigation, dataset transitions, and
  development integration
- `operational-topology/animations` - reusable motion presets and animation helpers
- `operational-topology/labs` - optional animation demonstrations
- `operational-topology/presets` - reusable scene templates for production pages
- `operational-topology/astro/TopologyBackground` - reusable topology background shell
- `operational-topology/astro/TopologyGrid` - reusable SVG grid renderer
- `operational-topology/astro/TopologyScene` - reusable interactive Astro scene component
- `operational-topology/astro/TopologyLayout` - optional document and theme layout starter
- `operational-topology/astro/ThemeSwitcher` - reusable theme and appearance controls

Important implementation modules:

- `src/topology/KnowledgeRepository.ts`
- `src/topology/TopologyModel.ts`
- `src/topology/worldModel.ts`
- `src/topology/SignalEngine.ts`
- `src/topology/SignalPolicy.ts`
- `src/topology/sceneNavigationController.ts`
- `src/topology/renderPipeline.ts`
- `src/topology/TopologyGridRenderer.ts`
- `src/topology/DeveloperAPI.ts`

See [Framework API](docs/FRAMEWORK_API.md) for entry-point boundaries and a
minimal definition example. For a beginner-first walkthrough, see [Creating Your First OTF Presentation](docs/FRAMEWORK_API_HELLO_WORLD_DECK.md) and [OTF Elements Cheat Sheet](docs/OTF_ELEMENTS_CHEATSHEET.md).

## Install

The package is published publicly on npm under the name
`operational-topology`.

Install the stable `0.5.0` release:

```sh
npm install operational-topology
```

Install the beta channel:

```sh
npm install operational-topology@beta
```

The package is published with two release channels:

- `latest` for stable releases
- `beta` for prerelease validation

See [docs/PACKAGE_DISTRIBUTION.md](docs/PACKAGE_DISTRIBUTION.md) for the
release model and publishing workflow.

## Animation Families

OTF keeps animation semantics separate: Signal Animations respond to topology interaction, Presentation Transitions replace or transition topology state, Ambient Animations keep inactive grid space alive, and Navigation Transitions provide a short visual bridge across a host application page or route change.

Navigation Transitions do not perform navigation themselves. The host application controls the route change and requests complementary `out` and `in` phases from OTF.

The 0.4.0 navigation catalog is available from `operational-topology/animations`: `navigation.flow`, `navigation.converge`, `navigation.expand`, `navigation.originArrival`, and `navigation.nodeFlicker`. Each supports the host-controlled `out` / `in` lifecycle where applicable. Navigation transitions do not perform navigation, mutate topology datasets, or know anything about routes.

## Framework Usage

Create a topology from one declarative definition:

```ts
import { createOperationalTopology } from "operational-topology";

const topology = createOperationalTopology({
  grid: {
    radius: 28,
    columns: 12,
    rows: 10,
    originQ: -6,
    originR: -5,
  },
  entities: [
    { id: "root", label: "Root", q: 0, r: 0, variant: "root" },
    { id: "entry", label: "Entry", q: 3, r: 2, variant: "entity" },
  ],
  relationships: [
    { from: "root", to: "entry", kind: "parent" },
  ],
});

const frame = topology.createRenderFrame({
  selectedId: "root",
});
```

The resulting runtime provides the topology model, world model, normalized
knowledge repository, signal policy, relationship context, and prepared render
frames. Invalid grids, duplicate entity IDs, and broken relationships are
rejected before the runtime is created.

Use the entry matching the environment:

```ts
import { axialToPixel } from "operational-topology";
import { createSceneNavigationController } from "operational-topology/browser";
import { getCenterBloomFrame } from "operational-topology/labs";
```

Interactive browser scenes can transition between datasets while preserving one
SVG scene, grid, camera, and minimap:

```ts
import {
  createTopologyDatasetTransition,
} from "operational-topology/browser";

const transition = createTopologyDatasetTransition({
  sceneGrid,
  cells,
  radius: 28,
});

await transition.transition({
  nodes,
  relationships,
});
```

The consuming application supplies the data and updates its Inspector. The
framework handles staging, ordered reveal, cancellation, and layer swapping.
The public API is experimental and follows the package's `0.x` release policy.

The completed repository-level implementation is recorded in
[`docs/RELEASE_BASELINE.md`](docs/RELEASE_BASELINE.md).

## Demonstration Routes

- `/world-map` - primary integration environment
- `/lab` - topology interaction demonstration
- `/animation-lab` - grid, signal, and logo animation experiments
- `/presentation-simulator` - interactive scene slideshow and transition demo
- `/connector-lab` - straight, axial, and obstacle-aware routing experiments
- `/theme-gallery` - semantic theme comparison
- `/experience-map` - example content-driven topology page

These routes are demonstrations of shared framework components rather than
independent rendering implementations.

## Local Development

Requirements:

- Node.js 22.12 or newer
- npm

Install dependencies:

```sh
npm install
```

Start Astro in background mode:

```sh
npm exec astro dev --background
```

Inspect or stop the background server:

```sh
npm exec astro dev status
npm exec astro dev logs
npm exec astro dev stop
```

Create a production build:

```sh
npm run build
```

## Validation

The repository includes focused Node test suites:

```sh
npm run test:camera
npm run test:developer
npm run test:framework
npm run test:render
npm run test:contrast
npm run test:signal
npm run test:theme
```

The current validation surface covers camera geometry, render contracts,
server/client renderer parity, framework entry-point boundaries, composition,
signal semantics, theme token coverage, text contrast, and Developer API
delegation.

## Development API

Development builds expose:

```js
window.otf
```

Examples:

```js
otf.help()
otf.world.entities()
otf.graph.neighbors("entity-id")
otf.camera.state()
otf.debug.layers()
otf.debug.performance()
```

The API is excluded from production builds. See
[docs/DEVELOPER_API.md](docs/DEVELOPER_API.md) for the complete command surface.

## Public Data Policy

Private repository status is not treated as a security boundary.

Documentation and examples should contain only information suitable for public
visibility. Before any public release:

- include only content explicitly cleared for publication
- use fictional or sanitized demonstration records where appropriate
- remove private identifiers, credentials, internal addresses, and unpublished
  operational details
- review generated static output as well as source files

The framework architecture does not require private personal or organizational
data.

## Technology

- [Astro](https://astro.build/)
- TypeScript
- SVG
- CSS semantic tokens
- Markdown and Astro content collections

## Transition Lifecycle

OTF 0.4.0 adds createTransitionLifecycle as a framework-level coordinator for visual ownership across an application navigation boundary. It does not know about routes or perform navigation. The host supplies callbacks for the concrete Navigation and Presentation transitions.

```ts
import { createTransitionLifecycle } from "operational-topology";

const lifecycle = createTransitionLifecycle({
  playNavigation: (phase) => renderNavigationFlow(phase),
  playPresentation: (phase) => renderPresentationHandoff(phase),
  setAmbientEnabled: (enabled) => ambient.setEnabled(enabled),
  setSignalsEnabled: (enabled) => signals.setEnabled(enabled),
  setOccupantsVisible: (visible) => occupants.setVisible(visible),
});

await lifecycle.exit();
await hostNavigate();
await lifecycle.enter();
```

Exit runs signal suppression, ambient yield, Presentation OUT, then Navigation OUT. Entrance keeps occupants hidden, runs Navigation IN, runs Presentation IN, reveals occupants, resumes ambient activity, then enables signals.

The OTF site includes a live lifecycle preview at /transition-lifecycle-lab/. It demonstrates the host-controlled ordering without performing a route change.

For complete host integration guidance, see [Navigation Transition Integration](docs/NAVIGATION_TRANSITIONS_INTEGRATION.md).

The operational-topology/browser entry provides createTopologySceneAnimationAdapter for rendering Navigation transitions into an existing OTF scene without host-side cell or connector DOM manipulation.
