From 22bca368571c73586a16fa12360852fc641b0c20 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 30 Oct 2026 11:20:01 +0100 Subject: [PATCH] feat(mentor): pin prompt-end constraint ordering (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both personas gain the verbatim-shared "Draft first, rules last" section (pass 1.5, session 1.2): the writer's material enters context before the rule skills, so the deslop constraint tables sit after the draft, nearest the writing they govern — the PRD's prompt-end rule. A real ACP audit (the app's exact wire — never -z: one-shot mode swaps the skills directive and loads nothing) showed the baseline already read the piece before deslop, but by model choice; the pin converts observed-once into instructed- always, and PersonaLoadOrderTests guards presence + verbatim parity over the bundled payload. Verified layout, probe traps, and the additive-only propagation cost are documented in docs/research/prompt-layout-factsheet.md with the probe script in-repo; real-run verify: piece → persona → deslop → verdict, 6 fix cards + 2 research candidates landed on the real rails. Suite 479 + 1 load-flake cleared in isolation. Closes #1 --- AGENTS.md | 22 ++--- CHANGELOG.md | 2 + MuseionTests/AGENTS.md | 1 + MuseionTests/PersonaLoadOrderTests.swift | 51 ++++++++++ ...verify-style-constraints-prompt-end_log.md | 81 +++++++++++++++ docs/devlog/INDEX.md | 1 + docs/research/prompt-layout-factsheet.md | 98 +++++++++++++++++++ docs/research/prompt-order-probe.py | 76 ++++++++++++++ ref/writing skills/AGENTS.md | 2 +- ref/writing skills/pass-persona/SKILL.md | 6 +- ref/writing skills/session-persona/SKILL.md | 6 +- 11 files changed, 332 insertions(+), 14 deletions(-) create mode 100644 MuseionTests/PersonaLoadOrderTests.swift create mode 100644 docs/devlog/20261030-issue1-verify-style-constraints-prompt-end_log.md create mode 100644 docs/research/prompt-layout-factsheet.md create mode 100644 docs/research/prompt-order-probe.py diff --git a/AGENTS.md b/AGENTS.md index 3f3290e..533aae6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -130,7 +130,7 @@ Single-context: `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/do # GitNexus — Code Intelligence -This project is indexed by GitNexus as **museion** (5172 symbols, 19414 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **museion** (5211 symbols, 19643 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > Index stale? Run `node .gitnexus/run.cjs analyze` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? `npx gitnexus analyze` (npm 11 crash → `npm i -g gitnexus`; #1939). @@ -187,14 +187,14 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu | Date | Log | |------|-----| -| 2026-10-28 | issue | [20261028-issue137-profiles-s4-engine-lifecycle-model-switch-ux_log.md](20261028-issue137-profiles-s4-engine-lifecycle-model-switch-ux_log.md) | Pass engines on-demand per profile, transient transcripts, chat restart deferred mid-turn, missing-key Run Pass — 2 race fixes | -| 2026-10-27 | issue | [20261027-issue136-profiles-s3-settings-write-path-test-connection_log.md](20261027-issue136-profiles-s3-settings-write-path-test-connection_log.md) | Profiles S3: settings write path (config set + .env), Test Connection probe, three dogfood rounds, three-reviewer audit | -| 2026-10-27 | issue | [20261027-issue135-profiles-s2-settings-page-ui_log.md](20261027-issue135-profiles-s2-settings-page-ui_log.md) | #135 Profiles S2: variant C Settings sidebar+detail over the SettingsWriting seam; NSComboBox stale-stringValue dogfood fix; 432 tests | -| 2026-10-27 | issue | [20261027-issue134-profiles-s1-registry-provisioning-x3_log.md](20261027-issue134-profiles-s1-registry-provisioning-x3_log.md) | #134 Profiles S1: ×3 surface registry + provisioner, master-symlink skills with byte-match migration, three-profile backup; 412 tests | -| 2026-10-22 | issue | [20261022-issue31-first-draft-stats-capture-s5-1_log.md](20261022-issue31-first-draft-stats-capture-s5-1_log.md) | #31 S5.1: Swift-native first-draft stats stamped in place at pass invocation; two frontmatter-erasure bugs fixed; finish-audit fanout — 396 tests | -| 2026-10-22 | issue | [20261022-issue30-sessions-new-post-from-session-drill-offers_log.md](20261022-issue30-sessions-new-post-from-session-drill-offers_log.md) | #30 lands: session-born Posts stamp origin: ai, brainstorm flavor, shared composer, and the real-engine resume wire fix. | -| 2026-10-22 | issue | [20261022-issue29-research-library-light_log.md](20261022-issue29-research-library-light_log.md) | #29 research rail: submit_research_notes candidates in-session, ask-before keep into research/, resume replay pin, audit fixes — targeted suites green | -| 2026-10-22 | issue | [20261022-issue28-session-lifecycle-ui_log.md](20261022-issue28-session-lifecycle-ui_log.md) | #28 Session lifecycle: multi-session model + names-only roster, pane, pass auto-create, finish-audit with 7 fixes — 359 tests green | -| 2026-10-21 | issue | [20261021-issue27-dismiss-decay-learnings_log.md](20261021-issue27-dismiss-decay-learnings_log.md) | #27 dismiss & decay Learnings: per-type pass clock, frontmatter decay state, consult filtering, two review waves with 5 fixes | -| 2026-10-21 | issue | [20261021-issue26-promote-consult-learnings_log.md](20261021-issue26-promote-consult-learnings_log.md) | #26 promote/consult Learnings: teaching-shape files, on-disk-truth promote, symlink guard, Learnings pane — 329 tests green | +| 2026-10-30 | [20261030-issue1-verify-style-constraints-prompt-end_log.md](20261030-issue1-verify-style-constraints-prompt-end_log.md) | +| 2026-10-28 | [20261028-issue137-profiles-s4-engine-lifecycle-model-switch-ux_log.md](20261028-issue137-profiles-s4-engine-lifecycle-model-switch-ux_log.md) | +| 2026-10-27 | [20261027-issue136-profiles-s3-settings-write-path-test-connection_log.md](20261027-issue136-profiles-s3-settings-write-path-test-connection_log.md) | +| 2026-10-27 | [20261027-issue135-profiles-s2-settings-page-ui_log.md](20261027-issue135-profiles-s2-settings-page-ui_log.md) | +| 2026-10-27 | [20261027-issue134-profiles-s1-registry-provisioning-x3_log.md](20261027-issue134-profiles-s1-registry-provisioning-x3_log.md) | +| 2026-10-22 | [20261022-issue31-first-draft-stats-capture-s5-1_log.md](20261022-issue31-first-draft-stats-capture-s5-1_log.md) | +| 2026-10-22 | [20261022-issue30-sessions-new-post-from-session-drill-offers_log.md](20261022-issue30-sessions-new-post-from-session-drill-offers_log.md) | +| 2026-10-22 | [20261022-issue29-research-library-light_log.md](20261022-issue29-research-library-light_log.md) | +| 2026-10-22 | [20261022-issue28-session-lifecycle-ui_log.md](20261022-issue28-session-lifecycle-ui_log.md) | +| 2026-10-21 | [20261021-issue27-dismiss-decay-learnings_log.md](20261021-issue27-dismiss-decay-learnings_log.md) | diff --git a/CHANGELOG.md b/CHANGELOG.md index 3deb538..e4c632a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format ### Added +- **mentor:** Prompt-end constraint ordering verified + pinned (#1) — the PRD's cross-cutting rule audited on the app's REAL wire: an ACP probe (initialize → session/new → session/prompt against the provisioned museion-pass1) plus the engine's own state.db read-back show constraint bodies never ride the system prompt — they enter as `skill_view` results, so "assembly order" is the mentor's tool-call order, and the baseline already loaded deslop AFTER the piece but by model choice. Both personas (pass 1.5 / session 1.2) gain the verbatim-shared "Draft first, rules last" pin converting observed-once into instructed-always; `PersonaLoadOrderTests` guards presence + parity over the bundled payload; the verified layout, the `hermes -z` trap (one-shot swaps the skills directive — a `-z` probe loads ZERO skills and assembles a different prompt), and the additive-only propagation cost (content edits need a hand-copy to master/profile copies; byte-match then migrates) live in `docs/research/prompt-layout-factsheet.md` with the probe script in-repo. Suite 479 + 1 load-flake cleared in isolation (issue #1) + - **mentor:** Profiles S4 — per-surface engine lifecycle + model-switch UX (#137) — passes run on their OWN one-shot engines (`hermes acp -p museion-passN` spawned per pass run, torn down at the verdict — a model switch costs nothing, the next spawn reads fresh config) streaming into transient unrostered transcripts (#129: one Sessions surface over the chat engine); the Chat engine stays resident and a Chat model change in Settings restarts it in place, deferred to turn end while a reply streams; Run Pass names the missing provider key and disables with an Open Settings link until the key lands (pane re-entry re-checks). Finish-audit (3 reviewers) fixed a post-await activation steal that could flip the surface mid-pass and lose the Cancel (one `claimActive` gate), plus a PRE-EXISTING `rescan` bug where a stale scan snapshot "vanished" a just-opened piece and killed its session with unflushed edits. Suite 477 (issue #137) - **settings:** Profiles S3 — the real write path + Test Connection (#136) — every Settings change now persists: model/effort writes ride the engine's own CLI (`hermes -p config set/unset` model.provider/default/reasoning_effort/base_url, wire-verified) and provider keys upsert `VAR=value` into ALL THREE profiles' `.env` (0600, foreign lines preserved, line-broken values refused at the sink — an env-file injection guard); hydration reads model blocks and keys back at pane open, so a restart neither blanks the UI nor refuses Test Connection, and a custom z.ai base_url survives instead of being clobbered to a family default. Per-target writes coalesce AND chain past the debounce guard — the last edit is always the last write to land. Test Connection is a two-step probe (`GET /models` then a minimal streaming chat) with honest decode per the factsheet: z.ai 1113 → wrong key type, 401s → auth failed with request id, finish=length → starved, empty 200 → request failed. Live-probed wire corrections: `Content-Type: application/json` on every request (URLSession defaults to form-urlencoded — z.ai answers 200 with an error envelope), OpenAI speaks the Responses API (`/responses`, `input` + `max_output_tokens`, flagship `gpt-6.1-sol`), probe token cap 512 (64 starved reasoning models into "no content"). Suite 468; three-reviewer finish-audit fixed a write-ordering race, an `.env` lost-update race, a mid-hydrate stomp, and cut ~30 lines of dead flexibility (issue #136) diff --git a/MuseionTests/AGENTS.md b/MuseionTests/AGENTS.md index f01a6a5..391eb6f 100644 --- a/MuseionTests/AGENTS.md +++ b/MuseionTests/AGENTS.md @@ -41,6 +41,7 @@ Owned by the root AGENTS.md contract. - ReadingPresenterTests gains the #109 pin: a canonical outline body (nested bullets) renders NESTED `