Skip to content

Commit 00ea397

Browse files
committed
push
1 parent d78164f commit 00ea397

46 files changed

Lines changed: 8821 additions & 2691 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs_build/database/ddl/messages.sql

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Target DEV database: gamefoundry_dev
55
-- Scope: executable grouped table DDL for active server API migration.
66
-- Authoritative key values are generated by the server/API layer unless a later DEV-only seed exception explicitly applies.
7-
-- Owned tables: messages_categories, messages_emotion_profiles, messages_records
7+
-- Owned tables: messages_categories, messages_emotion_profiles, messages_records, messages_segments
88
CREATE TABLE IF NOT EXISTS messages_categories (
99
key text PRIMARY KEY,
1010
"name" text NOT NULL UNIQUE,
@@ -45,7 +45,25 @@ CREATE TABLE IF NOT EXISTS messages_records (
4545
"updatedBy" text NOT NULL REFERENCES users(key)
4646
);
4747

48+
CREATE TABLE IF NOT EXISTS messages_segments (
49+
key text PRIMARY KEY,
50+
"messageKey" text NOT NULL REFERENCES messages_records(key),
51+
"emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
52+
"segmentText" text NOT NULL,
53+
"displayOrder" integer NOT NULL,
54+
"active" boolean NOT NULL DEFAULT true,
55+
"createdAt" timestamptz NOT NULL DEFAULT now(),
56+
"updatedAt" timestamptz NOT NULL DEFAULT now(),
57+
"createdBy" text NOT NULL REFERENCES users(key),
58+
"updatedBy" text NOT NULL REFERENCES users(key)
59+
);
60+
4861
CREATE INDEX IF NOT EXISTS idx_messages_records_categorykey ON messages_records ("categoryKey");
4962
CREATE INDEX IF NOT EXISTS idx_messages_records_emotionprofilekey ON messages_records ("emotionProfileKey");
5063
CREATE INDEX IF NOT EXISTS idx_messages_records_createdby ON messages_records ("createdBy");
5164
CREATE INDEX IF NOT EXISTS idx_messages_records_updatedby ON messages_records ("updatedBy");
65+
CREATE INDEX IF NOT EXISTS idx_messages_segments_messagekey ON messages_segments ("messageKey");
66+
CREATE INDEX IF NOT EXISTS idx_messages_segments_emotionprofilekey ON messages_segments ("emotionProfileKey");
67+
CREATE INDEX IF NOT EXISTS idx_messages_segments_order ON messages_segments ("messageKey", "displayOrder");
68+
CREATE INDEX IF NOT EXISTS idx_messages_segments_createdby ON messages_segments ("createdBy");
69+
CREATE INDEX IF NOT EXISTS idx_messages_segments_updatedby ON messages_segments ("updatedBy");

docs_build/database/dml/messages.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- Ownership: docs_build/database/dml/messages.sql
44
-- Runtime setup/seed operations for this group must run through server-side APIs.
55
-- Browser pages must not directly seed authoritative DB records.
6-
-- Owned tables: messages_categories, messages_emotion_profiles, messages_records
6+
-- Owned tables: messages_categories, messages_emotion_profiles, messages_records, messages_segments
77

88
-- DML status: Server-seed-owned.
99
-- Setup is performed through the Messages Local API / server-side SQLite service for this PR.

docs_build/database/seed/messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"Sad",
2525
"Mysterious"
2626
],
27-
"messages_records": []
27+
"messages_records": [],
28+
"messages_segments": []
2829
},
2930
"note": "Seed names are applied by the server-side Messages SQLite service. Browser pages must not seed authoritative records."
3031
}

docs_build/dev/commit_comment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Add Admin health operations dashboard - PR_26169_019-admin-health-operations
1+
Add Messages emotion segments persistence and editor - PR_26171_004
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# PR_26171_004 Messages Emotion Segments Manual Validation Notes
2+
3+
Manual validation was performed through the targeted Playwright run and a direct Local API probe.
4+
5+
PASS - Messages page loads at `/tools/messages/index.html`.
6+
7+
PASS - Existing Messages foundation still loads:
8+
- Categories render.
9+
- Emotion Profiles render.
10+
- Messages table renders.
11+
- Persistence inspector reports Server API / SQLite / messages.
12+
13+
PASS - Segment validation:
14+
- Empty Segment save displays visible validation.
15+
- Segment Text is required.
16+
- Emotion Profile is required.
17+
- Display Order is required.
18+
19+
PASS - Segment create:
20+
- Created segment 1 for `Forest Warning`.
21+
- Selected `Calm`.
22+
- Stored `The forest gets darker beyond this point.`
23+
24+
PASS - Segment add:
25+
- Created segment 2 for `Forest Warning`.
26+
- Selected `Urgent`.
27+
- Stored `We are being attacked by bats.`
28+
29+
PASS - Segment reorder:
30+
- Used `Move Up` on the second segment.
31+
- Segment order updated so the urgent line became display order 1.
32+
33+
PASS - Segment edit:
34+
- Edited segment text to `We are being attacked by bats right now.`
35+
- Saved the segment.
36+
- Reloaded segment content from the Local API.
37+
38+
PASS - Segment disable:
39+
- Used the row action to disable the edited segment.
40+
- Row displayed `Inactive`.
41+
- Local API returned `active: false`.
42+
43+
PASS - Local API persistence:
44+
- Direct API probe created, updated, listed, and fetched a segment.
45+
- Required-field failures returned actionable `400` responses.
46+
47+
PASS - SQLite persistence:
48+
- Restarted the Local API against the same SQLite file.
49+
- Confirmed the segment was still readable with updated text, display order, and inactive status.
50+
51+
PASS - No delete endpoints:
52+
- `DELETE /api/messages/segments/:key` returned `404`.
53+
54+
PASS - Theme V2 rendering:
55+
- Segment editor uses the existing Theme V2 form, table, card, status, and action classes.
56+
- No inline styles, style blocks, inline event handlers, tool-local CSS, or page-local CSS were introduced.
57+
58+
Out-of-scope confirmation:
59+
- No Text To Speech implementation.
60+
- No audio playback.
61+
- No voice selection.
62+
- No AI voices.
63+
- No dialog trees.
64+
- No localization or translation behavior.
65+
- No delete behavior.
66+
67+
Known validation blocker:
68+
- `npm run test:workspace-v2` still fails two out-of-scope workspace assertions after the Local API runtime is available:
69+
- Hardcoded Toolbox count expects `13/42`; current runtime reports `14/43`.
70+
- Alphabetical nav assertion expects `Game Hub` before `Game Journey`; current page renders `Game Journey` before `Game Hub`.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
PR_26171_004-messages-emotion-segments validation report
2+
3+
Branch validation:
4+
PASS
5+
6+
Current branch:
7+
main
8+
9+
Latest main validation:
10+
PASS - `git rev-list --left-right --count main...origin/main` returned `0 0`.
11+
12+
Targeted syntax/static checks:
13+
PASS
14+
15+
Commands:
16+
- node --check src/dev-runtime/messages/messages-sqlite-service.mjs
17+
- node --check toolbox/messages/messages-api-client.js
18+
- node --check toolbox/messages/messages.js
19+
- node --check tests/playwright/tools/MessagesTool.spec.mjs
20+
21+
Theme V2 / HTML restriction validation:
22+
PASS
23+
24+
Evidence:
25+
- `rg -n "<style| style=| on[a-z]+=" toolbox/messages/index.html` returned no matches.
26+
- Inline script guard returned `PASS no inline script tags in toolbox/messages/index.html`.
27+
28+
Local API / SQLite segment contract probe:
29+
PASS
30+
31+
Evidence:
32+
- `POST /api/messages/segments` without Display Order returned `400` with `Display order is required.`
33+
- `POST /api/messages/segments` without Emotion Profile returned `400` with `Emotion profile is required.`
34+
- `POST /api/messages/segments` without Segment Text returned `400` with `Segment text is required.`
35+
- `POST /api/messages/segments` created a segment.
36+
- `POST /api/messages/segments/:key` updated segment text, Display Order, and Active/Inactive status.
37+
- `GET /api/messages/segments` listed the segment.
38+
- `GET /api/messages/segments/:key` returned the segment after Local API restart against the same SQLite file.
39+
40+
Playwright:
41+
PASS
42+
43+
Command:
44+
- `npx playwright test tests/playwright/tools/MessagesTool.spec.mjs --project=playwright --workers=1 --reporter=list`
45+
46+
Result:
47+
- 1 passed.
48+
49+
Playwright behaviors covered:
50+
- Messages page loads.
51+
- Segment required validation displays for Segment Text, Emotion Profile, and Display Order.
52+
- Create Segment works.
53+
- Edit Segment works.
54+
- Reorder Segment works.
55+
- Disable Segment works using Active/Inactive.
56+
- Reload Segments reads from the Local API.
57+
- Local API persistence works.
58+
- SQLite persistence works across Local API restart.
59+
- `DELETE /api/messages/segments/:key` returns `404`.
60+
61+
Requested workspace lane:
62+
FAIL
63+
64+
Command:
65+
- `npm run test:workspace-v2`
66+
67+
Initial result:
68+
- 5 failed.
69+
- Failures included unavailable API requests to `http://127.0.0.1:5501/api/...`.
70+
71+
Rerun with Local API runtime started at `http://127.0.0.1:5501`:
72+
- 3 passed.
73+
- 2 failed.
74+
75+
Remaining failures:
76+
- `RootToolsFutureState.spec.mjs:246` expected `Tool Count: 13/42`; current runtime returned `Tool Count: 14/43`.
77+
- `RootToolsFutureState.spec.mjs:455` expected alphabetical order with `Game Hub` before `Game Journey`; current page rendered `Game Journey` before `Game Hub`.
78+
79+
Failure classification:
80+
- BLOCKER for the requested workspace lane.
81+
- Out of scope for this Messages segment PR.
82+
- Not changed in this PR to preserve one-purpose scope.
83+
84+
Coverage reports:
85+
PASS with advisory WARN entries for server-side files not collected by browser V8 coverage.
86+
87+
Evidence:
88+
- `docs_build/dev/reports/playwright_v8_coverage_report.txt`
89+
- `docs_build/dev/reports/coverage_changed_js_guardrail.txt`
90+
91+
Diff validation:
92+
PASS
93+
94+
Command:
95+
- `git diff --check -- <PR_26171_004 changed files>`
96+
97+
Result:
98+
- No whitespace errors. Git reported CRLF normalization warnings for existing line-ending behavior only.
99+
100+
Skipped validation:
101+
- Full samples validation skipped. This PR does not modify sample JSON, sample runtime, or shared sample framework behavior.
102+
- Full suite skipped. Targeted Messages validation and the requested workspace lane were run.
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# PR_26171_004-messages-emotion-segments
2+
3+
## Summary
4+
5+
Added ordered Message Segments to the existing Messages tool foundation.
6+
7+
This PR adds:
8+
- Server-owned SQLite `messages_segments` persistence under the grouped `messages` ownership area.
9+
- Local API contracts under `/api/messages/segments` for list, get, create, and update.
10+
- Theme V2 segment editor UI for add, edit, reorder, save, reload, and Active/Inactive disable.
11+
- Targeted Playwright coverage for segment validation, UI behavior, Local API persistence, and SQLite restart persistence.
12+
13+
No delete behavior, Text To Speech, audio playback, voice selection, AI voices, dialog trees, or localization behavior was added.
14+
15+
## Branch Validation
16+
17+
PASS - Current branch is `main`.
18+
19+
Evidence:
20+
- `git branch --show-current` -> `main`
21+
- `git rev-list --left-right --count main...origin/main` -> `0 0`
22+
23+
## Requirement Checklist
24+
25+
PASS - Added Message Segments persistence under grouped ownership area `messages`.
26+
27+
Evidence:
28+
- `src/dev-runtime/messages/messages-sqlite-service.mjs` creates `messages_segments`.
29+
- `docs_build/database/ddl/messages.sql` documents `messages_segments`.
30+
- `docs_build/database/dml/messages.sql` and `docs_build/database/seed/messages.json` include `messages_segments`.
31+
32+
PASS - Added Local API contracts for list, get, create, and update message segments.
33+
34+
Evidence:
35+
- `GET /api/messages/segments`
36+
- `GET /api/messages/segments/:key`
37+
- `POST /api/messages/segments`
38+
- `POST /api/messages/segments/:key`
39+
40+
PASS - No delete behavior added.
41+
42+
Evidence:
43+
- No segment delete service method exists.
44+
- Playwright validated `DELETE /api/messages/segments/:key` returns `404`.
45+
46+
PASS - Theme V2 segment editor UI added.
47+
48+
Evidence:
49+
- `toolbox/messages/index.html` includes Message Segments editor controls using existing Theme V2 classes.
50+
- `toolbox/messages/messages.js` wires add, edit, reorder, save, reload, and Active/Inactive status actions externally.
51+
- No page-local CSS, tool-local CSS, inline CSS, inline event handlers, or inline script blocks were added.
52+
53+
PASS - Segment validation implemented.
54+
55+
Evidence:
56+
- UI blocks save when Segment Text is missing.
57+
- UI blocks save when Emotion Profile is missing.
58+
- UI blocks save when Display Order is missing.
59+
- Direct Local API probe validates missing segment text, missing emotion profile, and missing display order return actionable `400` responses.
60+
61+
PASS - Local API persistence works.
62+
63+
Evidence:
64+
- Direct probe created, updated, listed, and fetched a segment through `/api/messages/segments`.
65+
- Playwright created, edited, reordered, disabled, and reloaded segments through the browser UI.
66+
67+
PASS - SQLite persistence works.
68+
69+
Evidence:
70+
- Direct probe restarted the Local API against the same SQLite file and re-read the updated segment.
71+
- Playwright restarted the Local API against the same SQLite file and re-read the disabled segment.
72+
73+
PASS - Browser does not generate authoritative keys.
74+
75+
Evidence:
76+
- Segment create payloads do not include keys.
77+
- `MessagesSqliteService` generates segment keys server-side with ULIDs.
78+
79+
PASS - Out-of-scope features were not implemented.
80+
81+
Evidence:
82+
- No Text To Speech, audio playback, voice selection, AI voices, dialog trees, localization, translation, or delete endpoint behavior was added.
83+
84+
## Validation Lane
85+
86+
Impacted lane:
87+
- Messages Local API + SQLite persistence + Theme V2 Messages UI.
88+
89+
Commands and results:
90+
- `node --check src/dev-runtime/messages/messages-sqlite-service.mjs`: PASS
91+
- `node --check toolbox/messages/messages-api-client.js`: PASS
92+
- `node --check toolbox/messages/messages.js`: PASS
93+
- `node --check tests/playwright/tools/MessagesTool.spec.mjs`: PASS
94+
- `git diff --check -- <PR_26171_004 changed files>`: PASS
95+
- HTML inline style/event scan for `toolbox/messages/index.html`: PASS
96+
- Inline script guard for `toolbox/messages/index.html`: PASS
97+
- Direct Local API / SQLite segment probe: PASS
98+
- `npx playwright test tests/playwright/tools/MessagesTool.spec.mjs --project=playwright --workers=1 --reporter=list`: PASS, 1 passed
99+
100+
Requested legacy lane:
101+
- `npm run test:workspace-v2`: FAIL
102+
- Rerun with Local API runtime at `127.0.0.1:5501`: FAIL, 3 passed and 2 failed.
103+
104+
Workspace lane blocker details:
105+
- `RootToolsFutureState.spec.mjs` expects `Tool Count: 13/42`; current runtime returns `Tool Count: 14/43`.
106+
- `RootToolsFutureState.spec.mjs` expects alphabetical order `Game Hub` before `Game Journey`; current page renders `Game Journey` before `Game Hub`.
107+
108+
Assessment:
109+
- These two remaining workspace-lane failures are outside the Messages segment scope.
110+
- They were not fixed in this PR to preserve one-purpose scope.
111+
112+
Skipped lanes:
113+
- Full samples validation skipped because no sample JSON or sample runtime behavior changed.
114+
- Full suite skipped because the requested workspace lane and targeted Messages validation were run.
115+
116+
## Playwright Result
117+
118+
PASS - `tests/playwright/tools/MessagesTool.spec.mjs`
119+
120+
Covered:
121+
- Messages page loads.
122+
- Categories load.
123+
- Emotion Profiles load.
124+
- Segment required validation displays visibly.
125+
- Create segment works.
126+
- Edit segment works.
127+
- Reorder segment works.
128+
- Disable segment works with Active/Inactive.
129+
- Reload segment works from Local API.
130+
- Local API persistence works.
131+
- SQLite persistence works after server restart.
132+
- No segment delete endpoint exists.
133+
- Theme V2 rendering remains functional.
134+
135+
FAIL - `npm run test:workspace-v2`
136+
137+
Covered by command:
138+
- Legacy workspace-contract lane.
139+
140+
Failure scope:
141+
- Out-of-scope Toolbox count and Game Hub/Game Journey ordering expectations.
142+
143+
## Manual Validation Notes
144+
145+
See:
146+
- `docs_build/dev/reports/PR_26171_004-messages-emotion-segments-manual-validation.md`
147+
148+
## Validation Report
149+
150+
See:
151+
- `docs_build/dev/reports/PR_26171_004-messages-emotion-segments-validation.txt`
152+
153+
## Artifact
154+
155+
Required ZIP:
156+
- `tmp/PR_26171_004-messages-emotion-segments_delta.zip`
157+
158+
ZIP validation:
159+
- PASS - Repo-structured ZIP created under `tmp/`.
160+
- PASS - Python `zipfile.testzip()` returned no bad entries.
161+
- PASS - ZIP contains 46 repo-relative entries.

0 commit comments

Comments
 (0)