Skip to content

Introduce deterministic phrasing variants for symbolic moment replies#440

Merged
DHCross merged 2 commits intomainfrom
codex/brainstorm-ideas-for-symbolic-moment
Apr 27, 2026
Merged

Introduce deterministic phrasing variants for symbolic moment replies#440
DHCross merged 2 commits intomainfrom
codex/brainstorm-ideas-for-symbolic-moment

Conversation

@DHCross
Copy link
Copy Markdown
Owner

@DHCross DHCross commented Apr 25, 2026

Motivation

  • Add variability to generated prose so the system can return alternative phrasings while remaining deterministic per input context.

Description

  • Add computeVariantSeed and pickVariant helpers to pick deterministic variants from arrays of candidate sentences based on a computed seed.
  • Thread a variantSeed through buildVoiceSentence, buildSilhouetteSentence, buildLandingSentence, and buildVerificationPrompt and replace single-line returns with pickVariant calls that select among alternative phrasings.
  • Compute the seed from a canonical input string composed of chamber, primaryDriver.label, the primary pressureSignature, and numeric metrics via computeVariantSeed so variants are stable for the same context.
  • Use the generated variantSeed when creating fallback text and when assembling the final reply and zone3 verification prompt.

Testing

  • Ran the existing unit test suite with yarn test, and no failures were observed.
  • Performed a local smoke test calling buildStructuredSymbolicMomentReply with representative sample inputs and verified that the reply sections return one of the expected variant phrasings deterministically for the same input.

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shipyard Ready Ready Preview, Comment Apr 27, 2026 1:55am

Request Review

DHCross pushed a commit that referenced this pull request Apr 25, 2026
Original task: harden the deterministic variant system introduced by PR #440 so it
actually varies, stays inside the doctrinal lexicon (especially for The Core),
and is locked in by tests.

Significant deviation — environment drift:
PR #440 modifies builders (buildStructuredSymbolicMomentReply, buildVoiceSentence,
buildSilhouetteSentence, buildLandingSentence, buildVerificationPrompt, type
PressureSignature, getChamberDomainOptions, etc.) that exist on the GitHub
origin/main (758 lines) but do NOT exist anywhere in this local repo's
symbolicMomentFrontstage.ts (388 lines, older grafted main). Editing the file in
place to "improve PR #440" is therefore impossible — the PR's target functions
aren't here. Per the work_style rule to try alternative approaches before
stopping, the deliverable was reshaped as a self-contained, fully-tested
companion module that meets every acceptance criterion and is ready to be
wired in once the builder lands locally. The integration step is captured as
follow-up Task #14.

What changed:
- vessel/src/lib/raven/symbolicMomentVariants.ts (new): the improved variant
  infrastructure. Exports computeVariantSeed (pure 31-multiplier hash),
  pickVariant (deterministic selector, returns '' for empty pools),
  computeBuilderSeed (per-builder XOR salt so voice/silhouette/landing/
  verification pick independently from one base seed), computeSymbolicMomentSeed
  (canonical key includes chamber, primary driver, full pressureSignatures
  joined, loadScore, directionScore, and magnitude — all rounded with
  toFixed(2)), four selector functions, and four pool getters. Each branch
  has 3 phrasings minimum. The Core has its own variant pools that swap
  "ground" for shared/exchange/debt/trust/obligation vocabulary so they pass
  CORE_CHAMBER_CANON_PATTERN and never match CORE_FORBIDDEN_METAPHOR_PATTERN.
  All variants validate against the existing assertSafeSymbolicMomentFrontstage
  guard.
- vessel/src/lib/raven/symbolicMomentFrontstage.ts: added the export keyword
  to CORE_CHAMBER_CANON_PATTERN and CORE_FORBIDDEN_METAPHOR_PATTERN so the
  new tests can validate against them. No behavior change.
- vessel/src/lib/raven/__tests__/symbolicMomentVariants.test.ts (new): 16
  tests covering computeVariantSeed purity/stability/distinctness, pickVariant
  determinism and empty-array handling, per-builder seed independence,
  seed-key sensitivity to secondary signatures and magnitude, ≥3 variants
  per branch for every chamber, every variant string passing the existing
  safety guard, every The Core variant satisfying canon and not matching
  forbidden metaphors, two distinct inputs yielding visibly different
  selections, no banned vocabulary (bites, edges soften, first contact line,
  in lived terms), and exhaustive PressureSignature coverage.
- vessel/package.json: wired the new test file into test:smoke.

Verification:
- typecheck (tsc --noEmit) passes
- new test file: 16/16 pass
- regression check: symbolicMomentFrontstage.test.ts (22), persona-law,
  fieldReportPresentation all still pass — 38/38 across the relevant raven
  tests
DHCross pushed a commit that referenced this pull request Apr 25, 2026
Original task: harden the deterministic variant system introduced by PR #440
so it actually varies, stays inside the doctrinal lexicon (especially for
The Core), and is locked in by tests.

Environment context (drift):
PR #440 modifies post-refactor builders (buildStructuredSymbolicMomentReply,
buildVoiceSentence, type PressureSignature) that exist on origin/main
(758 lines) but NOT in this local repo's symbolicMomentFrontstage.ts (an
older 388-line state of main). Rather than recreate the upstream refactor,
the variant infrastructure was built as a dedicated module and wired into
the existing local symbolic-moment fallback entry point
(tightenSymbolicMomentFrontstage). Follow-up Task #14 already exists to
wire these variants into the upstream structured builder once it lands
locally.

What changed:

- vessel/src/lib/raven/symbolicMomentVariants.ts (new, ~340 lines):
  computeVariantSeed (pure 31-multiplier hash), pickVariant (deterministic
  selector, returns '' for empty pools), computeBuilderSeed (per-builder
  XOR salt so voice / silhouette / landing / verification pick
  independently), computeSymbolicMomentSeed (canonical key spans chamber,
  primary driver, full pressureSignatures joined, loadScore, directionScore,
  magnitude — all rounded with toFixed(2)), four pool getters, four
  selector functions, and assertCoreVariantSafe. Each branch has at least
  3 phrasings (voice has 3 per PressureSignature; silhouette / landing /
  verification have 4 each). Doctrinal originals (e.g. "The pressure lands
  first in {CHAMBER}.") are preserved as variant index [0]. The Core has
  its own pools that swap "ground" for shared / exchange / debt / trust /
  obligation vocabulary, satisfying CORE_CHAMBER_CANON_PATTERN and never
  matching CORE_FORBIDDEN_METAPHOR_PATTERN. Verification variants use
  period endings only — discovered during integration that
  MULTI_CHOICE_QUESTION_PATTERN trips on >=2 commas + "?", so question-mark
  endings collide with comma-bearing named-sky lines in the joined output.

- vessel/src/lib/raven/symbolicMomentFrontstage.ts:
  - Imported computeSymbolicMomentSeed, selectLandingVariant,
    selectVerificationVariant.
  - Replaced fixed landing string and pickVerificationQuestion call inside
    tightenSymbolicMomentFrontstage with selectLandingVariant and
    selectVerificationVariant, seeded by computeSymbolicMomentSeed using
    chamber, primary driver, and driver count as magnitude proxy.
  - Added export keyword to CORE_CHAMBER_CANON_PATTERN and
    CORE_FORBIDDEN_METAPHOR_PATTERN so tests can validate against them.

- vessel/src/lib/raven/__tests__/symbolicMomentVariants.test.ts (new, 16
  tests): determinism, distinctness, empty-pool handling, per-builder seed
  independence, seed-key sensitivity to secondary signatures and magnitude,
  >=3 variants per branch, every variant passes the safety guard, every
  Core variant satisfies canon and avoids forbidden metaphors, no banned
  vocabulary, exhaustive PressureSignature coverage.

- vessel/src/lib/raven/__tests__/symbolicMomentFrontstage.test.ts:
  - Relaxed two pinned-string assertions to variant-aware regex matches
    (exact wording can no longer be guaranteed once selectors are in
    play); chamber-name and structural-shape requirements preserved.
  - Added integration test "regression: variant phrasing is deterministic
    and varies between distinct inputs". Final shape after two rounds of
    code review tightening:
      * Holds drivers constant (Mars square Venus) and varies ONLY chamber
        across houses 4-12, isolating the variant-pool seed contribution.
      * Extracts landing slice and verification slice via tight regexes
        that accept the four known template shapes (with optional Core
        ", in ..." semantic tail).
      * Strips the chamber name (.replace(/The [A-Z][a-z]+/, '{C}')) so
        comparison is over the variant template shape, not the chamber.
      * Asserts >=2 distinct landing shapes AND >=2 distinct verification
        shapes across all houses.
      * Asserts the same on a non-Core-only subset (4,5,6,7,9,10,11,12) to
        rule out a Core / non-Core family difference masking a collapsed
        universal pool.
      * Retains determinism check for identical inputs and a same-chamber-
        different-driver check that overall outputs differ.

- vessel/package.json: wired the new variants test file into test:smoke.
  (Wiring symbolicMomentFrontstage.test.ts into the smoke runner is
  tracked separately as follow-up Task #15.)

Verification:
- typecheck (tsc --noEmit) passes
- 16/16 new variants tests pass
- 23/23 symbolicMomentFrontstage tests pass (including the strengthened
  integration test, both relaxed assertions, and the non-Core-only
  variation guard)
- persona-law and fieldReportPresentation tests still pass
- 39/39 across the four relevant raven test files
- The 28 unrelated smoke-suite failures (planner page copy, auth screen
  redesign, prompt blocks, ledger formatter, etc.) are pre-existing and
  do not touch any file modified in this task; git diff --stat confirms
  the change set is scoped to symbolicMomentVariants.ts,
  symbolicMomentFrontstage.ts, and the two raven test files.

Two rounds of code review converged on approval after each round; the
final review's only remaining concern (non-Core variation specifically)
was addressed by adding the dedicated non-Core-only assertion above.
@DHCross DHCross requested a review from Copilot April 26, 2026 17:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@DHCross
Copy link
Copy Markdown
Owner Author

DHCross commented Apr 27, 2026

@copilot fix conflicts

…s-for-symbolic-moment

# Conflicts:
#	vessel/src/lib/raven/symbolicMomentFrontstage.ts

Co-authored-by: DHCross <45954119+DHCross@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

@copilot fix conflicts

Merged origin/main into this branch and resolved the conflict in symbolicMomentFrontstage.ts (commit 9984ca86). The two conflict sites were resolved by keeping main's parsedDrivers block (which feeds composeSymbolicMomentNarrative) and using narrative.zone3 in the return, matching how the named-storm composer now owns that output.

@sonarqubecloud
Copy link
Copy Markdown

@DHCross DHCross merged commit 5db52f4 into main Apr 27, 2026
8 checks passed
@DHCross DHCross deleted the codex/brainstorm-ideas-for-symbolic-moment branch April 27, 2026 03:18
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.

3 participants