Skip to content

Add posture-expansion templates and pre-bind expansion stage with derived-graph provenance#12

Open
danielbdyer wants to merge 1 commit into
mainfrom
codex/add-canonical-template-artifact-format
Open

Add posture-expansion templates and pre-bind expansion stage with derived-graph provenance#12
danielbdyer wants to merge 1 commit into
mainfrom
codex/add-canonical-template-artifact-format

Conversation

@danielbdyer
Copy link
Copy Markdown
Owner

Motivation

  • Provide a canonical, reviewable way to express scenario expansion rules (target screen, baseline posture, override partitions, include/exclude, and expansion limits) so derived test variants can be generated deterministically from approved artifacts.
  • Keep generated variants disposable and provenance-rich so derivations remain auditable and graphable without making expanded scenarios a new canonical truth.
  • Surface common validation failure modes (missing posture partition, unknown element, non-input action) earlier in the pipeline to improve correctness and diagnostics.
  • Make expansion an explicit, pre-bind stage so the binding and downstream graph/type generation stages operate over a stable, deterministic set of derived variants.

Description

  • Introduced a canonical template artifact format under scenarios/templates/ (example: policy-search.posture-expansion.yaml) that encodes id, scenarioAdoIds, and rules with screen, baseline, overrides, include/exclude, and maxExpansions.
  • Added domain types for templates and expanded outputs (ScenarioTemplateArtifact, ExpandedScenarioSet, ExpandedScenarioVariant, PostureExpansionRule) and extended GraphNodeKind/GraphEdgeKind to include template and derived-from-template kinds.
  • Implemented lib/domain/posture-expansion.ts containing expandScenarioPostures which consumes Scenario, ScreenElements, and ScreenPostures and emits deterministic expanded variants with stable ordering (by element id) and stable variant ids (fingerprinted via sha256(stableStringify(...))).
  • Added lib/application/expand.ts to run expansion as a pre-bind stage, validate templates via validateScenarioTemplateArtifact and validateTemplateExpansionContext, and persist derived expansions under .tesseract/bound/expanded/*.expanded.json (derived space; not canonical).
  • Wired expansion into orchestration by calling expandScenarioTemplates in the compile workflow (lib/application/compile.ts) prior to binding, and exposed the expanded result in compile outputs.
  • Extended validation in lib/domain/validation.ts to parse/validate template artifacts and to produce semantic diagnostics for expansion context issues (missing posture partitions, unknown elements, non-input actions).
  • Extended derived-graph construction and ids (lib/domain/derived-graph.ts, lib/domain/ids.ts, lib/application/graph.ts) to include template nodes and scenario-variant nodes and to emit derived-from-template edges so provenance from template -> generated variant is represented in the graph; template and expanded scenarios are included in graph input fingerprints for deterministic caching.
  • Added law-style tests and integration checks: deterministic expansion unit test (tests/domain.spec.ts) and refresh-level deterministic expanded-output test (tests/compiler.spec.ts).

Testing

  • Built the project with npm run build (TypeScript compilation) and then ran the test suites:
    • node ./node_modules/@playwright/test/cli.js test tests/domain.spec.ts tests/compiler.spec.ts
  • Result: all tests passed (17 passed).

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant