# backward-chaining goal-driven reactive ui

- Status: `experiment`
- Track: [reactive prompt architectures](https://aifoc.us/labs/reactive-prompts/)
- Layer: 2. Post-<a> Hypermedia & Composable UI
- Updated: 1 December 2026
- Live demo: https://reactive-goal-ui.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/reactive-goal-ui

## Inspired by

- [what falling ai model latency means for the web](https://aifoc.us/latency/)
- [the projects behind my ai focus posts](https://aifoc.us/projects/)

## Hypothesis

- **Claim:** Backward-chaining from a target goal schema (`solveGoalFrontier`) renders smaller missing-input forms and invalidates fewer downstream computations on partial edits than forward-push prompt chains.
- **Confirms it:** Supplying upfront natural-language facts eliminates already-known questions from the DOM, and changing `destination` preserves cached `dates` and `budget` artifacts while selectively invalidating `flightEstimate` and `itinerary`.
- **Falsifies or bounds it:** Fact extraction errors create oscillating forms where newly extracted fields keep invalidating user-filled controls.

> **Why this exists:** Forward push graphs re-run entire pipelines whenever an upstream variable changes, while static multi-page forms ask visitors for details they already supplied in an initial prompt. A backward-chaining constraint solver starts from the desired output schema, diffs against already-extracted facts, renders HTML inputs strictly for the minimal missing frontier, and invalidates only transitive dependents when one requirement changes.


## What this lab tests

[Reactive Goal UI](https://reactive-goal-ui.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/reactive-goal-ui)) extracts structured facts via `/api/extract-facts` (or local `LanguageModel`), computes `missingLeaves`, `readyToPull`, and conditional sub-goals dynamically across three constraint schemas (`Book a Trip`, `SEV-1 Incident Postmortem`, `Web Feature Launch Readiness`), applies canonical-fact early cutoff on rephrased inputs, and progressively unlocks ready sections on `/api/pull-goal-node`.

```js
const frontier = solveGoalFrontier("book-trip", extractedFacts, nodeCache, "destination");
// -> missingLeaves: ["pace", "international"] (renders only missing inputs)
// -> invalidated: ["flightEstimate", "itinerary"] (leaves dates, budget, pace cached)
```


## Open questions to iterate on

- How can canonical fact hashing combine browser built-in `LanguageModel` extraction with synchronous rule checks in < 50ms?
- Can goal schemas automatically compile both these missing-input forms and WebMCP tool parameters (like `canonical-multimodal-ui`)?

## Iteration log

- **2026-12-01:** Built 3-pack constraint solver (`Book a Trip`, `SEV-1 Postmortem`, `Launch Readiness`), canonical fact extractor, and progressive unlock endpoints.
- **2026-12-01:** Fixed Tab 2 CSS Grid `minmax(0, 1fr)` horizontal overflow and promoted code blueprints to top of page.
- **2026-12-01:** Reordered the backward-chaining solver ahead of setup docs for 700px embeds, added CSP-safe DOM syntax highlighting and keyboard tab navigation, and routed static assets through the Worker with `no-cache` headers.

## Primitives tested

- `Backward-Chaining Solver`
- `Conditional Sub-Goals`
- `Selective Invalidation`
- `Canonical Fact Diffing`

## Connected labs in other tracks

- [canonical multimodal ui](https://aifoc.us/labs/hypermedia-and-islands/canonical-multimodal-ui/) — Tests schema-driven HTML + WebMCP generation from a single source definition.
- [reactive prompt models rosetta stone](https://aifoc.us/labs/reactive-prompts/reactive-prompt-rosetta/) — Compares forward push DAG strategies against this backward-chaining solver.

---
Canonical: https://aifoc.us/labs/reactive-prompts/reactive-goal-ui/
