Skip to content

Commit c1a4771

Browse files
committed
Rework Alfa tags to DB-backed API services
1 parent e028775 commit c1a4771

28 files changed

Lines changed: 4470 additions & 2992 deletions

assets/toolbox/game-configuration/js/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getSessionCurrent } from "../../../../src/api/session-api-client.js";
12
import {
23
createServerRepositoryClient,
34
readServerToolConstants,
@@ -65,6 +66,23 @@ function setText(element, value) {
6566
}
6667
}
6768

69+
function currentSession() {
70+
try {
71+
return getSessionCurrent();
72+
} catch {
73+
return { authenticated: false };
74+
}
75+
}
76+
77+
function redirectGuestWriteAction() {
78+
if (currentSession()?.authenticated === true) {
79+
return false;
80+
}
81+
setText(elements.statusLog, "Sign in before saving Game Configuration.");
82+
window.location.href = new URL("/account/sign-in.html", window.location.href).href;
83+
return true;
84+
}
85+
6886
function createListItem(text) {
6987
const item = document.createElement("li");
7088
item.textContent = text;
@@ -190,6 +208,9 @@ elements.form?.addEventListener("change", renderFormValidation);
190208

191209
elements.form?.addEventListener("submit", (event) => {
192210
event.preventDefault();
211+
if (redirectGuestWriteAction()) {
212+
return;
213+
}
193214
const snapshot = repository.getSnapshot();
194215
const projectId = snapshot.handoff.activeProject?.id || "";
195216

assets/toolbox/game-design/js/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getSessionCurrent } from "../../../../src/api/session-api-client.js";
12
import {
23
createServerRepositoryClient,
34
readServerToolConstants,
@@ -62,6 +63,23 @@ function setText(element, value) {
6263
}
6364
}
6465

66+
function currentSession() {
67+
try {
68+
return getSessionCurrent();
69+
} catch {
70+
return { authenticated: false };
71+
}
72+
}
73+
74+
function redirectGuestWriteAction() {
75+
if (currentSession()?.authenticated === true) {
76+
return false;
77+
}
78+
setText(elements.statusLog, "Sign in before saving Game Design.");
79+
window.location.href = new URL("/account/sign-in.html", window.location.href).href;
80+
return true;
81+
}
82+
6583
function populateSelect(select, values, placeholder) {
6684
if (!select) {
6785
return;
@@ -291,6 +309,9 @@ elements.form?.addEventListener("input", renderFormValidation);
291309

292310
elements.form?.addEventListener("submit", (event) => {
293311
event.preventDefault();
312+
if (redirectGuestWriteAction()) {
313+
return;
314+
}
294315
const result = repository.saveDesign(readForm());
295316
setText(elements.statusLog, result.message);
296317
render();

docs_build/database/ddl/game-configuration.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ CREATE TABLE IF NOT EXISTS game_configuration_records (
2020
CREATE INDEX IF NOT EXISTS idx_game_configuration_records_gamekey ON game_configuration_records ("gameKey");
2121
CREATE INDEX IF NOT EXISTS idx_game_configuration_records_createdby ON game_configuration_records ("createdBy");
2222
CREATE INDEX IF NOT EXISTS idx_game_configuration_records_updatedby ON game_configuration_records ("updatedBy");
23+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "gameName" text;
24+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "gamePurpose" text;
25+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "gameType" text;
26+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "genre" text;
27+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "playStyle" text;
28+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "gameBasics" text;
29+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "gameRules" text;
30+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "playerSetup" text;
31+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "worldSetup" text;
32+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "objectSetup" text;
33+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "audioSetup" text;
34+
ALTER TABLE game_configuration_records ADD COLUMN IF NOT EXISTS "testReadiness" text;
2335

2436
CREATE TABLE IF NOT EXISTS game_configuration_validation_items (
2537
key text PRIMARY KEY,
@@ -36,3 +48,4 @@ CREATE TABLE IF NOT EXISTS game_configuration_validation_items (
3648
CREATE INDEX IF NOT EXISTS idx_game_configuration_validation_items_gamekey ON game_configuration_validation_items ("gameKey");
3749
CREATE INDEX IF NOT EXISTS idx_game_configuration_validation_items_createdby ON game_configuration_validation_items ("createdBy");
3850
CREATE INDEX IF NOT EXISTS idx_game_configuration_validation_items_updatedby ON game_configuration_validation_items ("updatedBy");
51+
ALTER TABLE game_configuration_validation_items ADD COLUMN IF NOT EXISTS "section" text;

docs_build/database/ddl/game-design.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ CREATE INDEX IF NOT EXISTS idx_game_design_documents_gamekey ON game_design_docu
2020
CREATE INDEX IF NOT EXISTS idx_game_design_documents_createdby ON game_design_documents ("createdBy");
2121
CREATE INDEX IF NOT EXISTS idx_game_design_documents_updatedby ON game_design_documents ("updatedBy");
2222

23+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "gamePurpose" text;
24+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "gameType" text;
25+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "genre" text;
26+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "playStyle" text;
27+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "playerMode" text;
28+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "designSummary" text;
29+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "capabilityDemoAuthoring" boolean NOT NULL DEFAULT false;
30+
ALTER TABLE game_design_documents ADD COLUMN IF NOT EXISTS "capabilityDemoNotes" text;
31+
2332
CREATE TABLE IF NOT EXISTS game_design_validation_items (
2433
key text PRIMARY KEY,
2534
"gameKey" text REFERENCES game_workspace_games(key),
@@ -35,3 +44,21 @@ CREATE TABLE IF NOT EXISTS game_design_validation_items (
3544
CREATE INDEX IF NOT EXISTS idx_game_design_validation_items_gamekey ON game_design_validation_items ("gameKey");
3645
CREATE INDEX IF NOT EXISTS idx_game_design_validation_items_createdby ON game_design_validation_items ("createdBy");
3746
CREATE INDEX IF NOT EXISTS idx_game_design_validation_items_updatedby ON game_design_validation_items ("updatedBy");
47+
ALTER TABLE game_design_validation_items ADD COLUMN IF NOT EXISTS "field" text;
48+
49+
CREATE TABLE IF NOT EXISTS game_design_capability_demos (
50+
key text PRIMARY KEY,
51+
"gameKey" text REFERENCES game_workspace_games(key),
52+
"gameName" text,
53+
"gamePurpose" text,
54+
"authoringMode" text,
55+
"status" text,
56+
"createdAt" timestamptz NOT NULL DEFAULT now(),
57+
"updatedAt" timestamptz NOT NULL DEFAULT now(),
58+
"createdBy" text NOT NULL REFERENCES users(key),
59+
"updatedBy" text NOT NULL REFERENCES users(key)
60+
);
61+
62+
CREATE INDEX IF NOT EXISTS idx_game_design_capability_demos_gamekey ON game_design_capability_demos ("gameKey");
63+
CREATE INDEX IF NOT EXISTS idx_game_design_capability_demos_createdby ON game_design_capability_demos ("createdBy");
64+
CREATE INDEX IF NOT EXISTS idx_game_design_capability_demos_updatedby ON game_design_capability_demos ("updatedBy");
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# PR_26177_ALFA_058-flat-project-tags Branch Validation
1+
# PR_26177_ALFA_058 Branch Validation
22

3-
Generated: 2026-06-26 18:53:15 UTC
4-
5-
- Branch check: PASS - current branch is `PR_26177_ALFA_058-flat-project-tags`.
6-
- Scope check: PASS - changes are limited to Tags UI/runtime seed behavior, API/DB tests, database seed artifact, reports, and packaging.
7-
- Architecture check: PASS - targeted validation uses Browser -> API -> Database.
8-
- Current game check: PASS - status bar and Tags active project both show Demo Game.
9-
- Validation result: PASS.
3+
- Branch: PR_26177_ALFA_058-flat-project-tags
4+
- Runtime architecture: Browser -> API -> Database
5+
- Worktree validation before package: PASS pending final status check
6+
- Retired mock repository files absent: PASS
7+
- Router uses DB-backed Alfa API services: PASS
8+
- Local/origin sync: pending push after report package
9+
- Validation result: PASS
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# PR_26177_ALFA_058-flat-project-tags Manual Validation Notes
1+
# PR_26177_ALFA_058 Manual Validation Notes
22

3-
Generated: 2026-06-26 18:53:15 UTC
4-
5-
- Loaded /toolbox/tags/index.html and confirmed the status bar selected game is Demo Game.
6-
- Confirmed the Tags center panel shows current-game starter assignments for fantasy and platformer from runtime API state.
7-
- Added Hero, assigned it to Demo Game, refreshed, reloaded, and confirmed assignment persisted.
8-
- Removed Hero from Demo Game, edited it to Hero Asset, and deleted it after assignment removal.
9-
- Verified guest browser write redirects to account/sign-in.html and direct guest API write methods return 401.
3+
- Tags page title is `Tags` and copy reads `Manage shared Game tags for assets and tool records.`
4+
- Tags are flat labels; no category UI or grouped category filter is rendered.
5+
- Signed-in flow was validated by Playwright: add, duplicate validation, assign to active Game Hub game, refresh, reload, remove, edit, delete.
6+
- Guest write flow redirects to `account/sign-in.html` before save.
7+
- API guest write flow returns 401 and does not write product data.
8+
- Active runtime no longer imports or creates the retired Tags/Game Design/Game Configuration mock repositories.
9+
- Design and Configuration copies now refer to API persistence, not mock/in-memory repositories, because shared router wiring for these tools was corrected as part of the no-mock stack rework.
Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
# PR_26177_ALFA_058-flat-project-tags Report
22

3-
Generated: 2026-06-26 18:53:15 UTC
4-
Branch: `PR_26177_ALFA_058-flat-project-tags`
5-
Base: `main`
6-
Current HEAD before packaging: `675b1a40f`
7-
83
## Summary
9-
PR058 keeps Tags as a human-testable flat tag tool. The tool loads the current Game Hub game context, shows starter current-game tag assignments from API runtime state, supports add/edit/assign/remove/delete actions through the API, persists rows to database-backed tag tables, and survives refresh/reload.
4+
- Reworked Tags to use Browser -> API -> Database through the shared server repository client and DB-backed API service.
5+
- Removed retired Tags, Game Design, and Game Configuration mock repository files from the active runtime stack.
6+
- Updated `local-api-router.mjs` so Tags, Game Design, and Game Configuration route to API database services rather than mock repositories.
7+
- Added guardrail coverage that fails if retired Alfa mock repository files exist or are imported by active JS/MJS.
8+
- Kept Tags flat: no category table, category UI, grouped category filtering, or category-owned seed data.
109

11-
## Implementation Notes
12-
- Center title is `Tags`; no Workspace wording is used.
13-
- Starter runtime tag state includes assignments for the selected Demo Game so the tool opens with current-game tag context.
14-
- Static seed JSON keeps project assignments empty because runtime project keys remain server/API-owned.
15-
- The Playwright lane uses `/toolbox/tags/index.html` and asserts the shared status bar selected game.
16-
- Guest write coverage checks add, update, assign, remove, and delete API methods.
17-
- No categories, SQLite, tmp runtime dependency, JSON source of truth, mock-db-store expansion, or new mock repository file was added.
10+
## Data Contract
11+
- DDL remains under `docs_build/database/ddl/`.
12+
- Tags use `project_tags` and `project_tag_assignments` only.
13+
- Server/API owns authoritative keys for created records.
14+
- Records include `createdAt`, `updatedAt`, `createdBy`, `updatedBy` and ownership references `users.key`.
15+
- Browser does not own product data and does not use JSON/local storage as source of truth.
1816

1917
## Validation
20-
- PASS - node --check assets/toolbox/tags/js/index.js
21-
- PASS - node --check src/dev-runtime/persistence/tool-repositories/tags-mock-repository.js
22-
- PASS - node --check src/dev-runtime/server/local-api-router.mjs
23-
- PASS - node --check tests/playwright/tools/TagsTool.spec.mjs
24-
- PASS - python -m json.tool docs_build/database/seed/tags.json
25-
- PASS - git diff --check (line-ending notices only)
26-
- PASS - npx playwright test tests/playwright/tools/TagsTool.spec.mjs --workers=1 --reporter=line (4 passed)
18+
- PASS - `node --check src/dev-runtime/toolbox-api/alfa-tool-services.mjs`
19+
- PASS - `node --check src/dev-runtime/server/local-api-router.mjs`
20+
- PASS - `node --check src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js`
21+
- PASS - `node --test tests/dev-runtime/DevRuntimeBoundary.test.mjs`
22+
- PASS - `npx playwright test tests/playwright/tools/TagsTool.spec.mjs --project=playwright`
23+
- PASS - `npx playwright test tests/playwright/tools/GameDesignApiDb.spec.mjs --project=playwright`
24+
- PASS - `npx playwright test tests/playwright/tools/GameConfigurationApiDb.spec.mjs --project=playwright`
25+
- PASS - `npx playwright test tests/playwright/tools/ToolboxSelectedGameStatusBar.spec.mjs --project=playwright`
26+
- PASS - `npx playwright test tests/playwright/tools/AssetToolMockRepository.spec.mjs --project=playwright -g "Asset repository exposes catalog tables"`
27+
- INFO - Full `AssetToolMockRepository.spec.mjs` was not part of the impacted lane and timed out when run as a broad suite; the touched Asset tag-reference test passed.
28+
29+
## Removed Mock Repository Files
30+
- `src/dev-runtime/persistence/tool-repositories/tags-mock-repository.js`
31+
- `src/dev-runtime/persistence/tool-repositories/game-design-mock-repository.js`
32+
- `src/dev-runtime/persistence/tool-repositories/game-configuration-mock-repository.js`
33+
34+
## Status
35+
PASS - PR058 is reworked and ready for owner testing after the stack-wide no-mock correction is propagated to PR059-PR061.
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# PR_26177_ALFA_058-flat-project-tags Requirement Checklist
1+
# PR_26177_ALFA_058 Requirement Checklist
22

3-
Generated: 2026-06-26 18:53:15 UTC
4-
5-
- PASS - Page title remains Tags and copy remains 'Manage shared Game tags for assets and tool records.'
6-
- PASS - Flat tags only; no category table, UI, filtering, or category-owned seed data.
7-
- PASS - Tool loads current Game Hub game context from the shared status bar/API path.
8-
- PASS - Starter tags include current-game seed assignments for Demo Game in runtime seed state; static seed JSON keeps project assignments API-owned.
9-
- PASS - Signed-in Creator can add a tag, assign it to the current game, remove it, refresh, reload, and see persistence.
10-
- PASS - API/DB validation asserts project_tags and project_tag_assignments rows.
11-
- PASS - Guest add/save/update/delete/assign/remove API actions return 401; browser guest save redirects to account/sign-in.html.
12-
- PASS - Browser -> API -> Database path only; no browser product-data source of truth.
13-
- PASS - No SQLite or tmp runtime dependency introduced.
14-
- PASS - No mock-db-store expansion and no new *-mock-repository.js file added.
15-
- PASS - DDL, DML, and seed artifacts remain under docs_build/database/ddl, dml, and seed paths.
3+
| Requirement | Status | Notes |
4+
| --- | --- | --- |
5+
| Flat tags only, no categories | PASS | Tags use `project_tags` and `project_tag_assignments` only. |
6+
| Tags tool loads through API | PASS | Browser uses shared server repository client. |
7+
| Signed-in Creator can add tag | PASS | Playwright API/UI coverage passed. |
8+
| Signed-in Creator can assign/remove current-game tag | PASS | Playwright API/UI coverage passed with refresh persistence. |
9+
| Duplicate prevention | PASS | API/UI duplicate validation covered. |
10+
| Guest save/create/update/delete redirects or 401s | PASS | UI redirect and API rejection covered. |
11+
| No browser-owned product data | PASS | Writes route through API database service. |
12+
| No JSON source of truth | PASS | No tool JSON store added. |
13+
| No mock repository source of truth | PASS | Retired mock files deleted and guardrail added. |
14+
| No new or expanded mock-db-store usage for Tags/Design/Configuration | PASS | Router uses DB-backed Alfa services. |
15+
| Server/API owns keys and audit fields | PASS | Service uses adapter key creation and audit fields. |
16+
| DDL/DML/seed location discipline | PASS | DDL under `docs_build/database/ddl/`; no duplicate tool DDL folders added. |
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# PR_26177_ALFA_058-flat-project-tags Validation Lane
1+
# PR_26177_ALFA_058 Validation Lane
22

3-
Generated: 2026-06-26 18:53:15 UTC
3+
## Static / Guardrail
4+
- PASS - `node --check src/dev-runtime/toolbox-api/alfa-tool-services.mjs`
5+
- PASS - `node --check src/dev-runtime/server/local-api-router.mjs`
6+
- PASS - `node --check src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js`
7+
- PASS - `node --test tests/dev-runtime/DevRuntimeBoundary.test.mjs`
48

5-
- PASS - node --check assets/toolbox/tags/js/index.js
6-
- PASS - node --check src/dev-runtime/persistence/tool-repositories/tags-mock-repository.js
7-
- PASS - node --check src/dev-runtime/server/local-api-router.mjs
8-
- PASS - node --check tests/playwright/tools/TagsTool.spec.mjs
9-
- PASS - python -m json.tool docs_build/database/seed/tags.json
10-
- PASS - git diff --check (line-ending notices only)
11-
- PASS - npx playwright test tests/playwright/tools/TagsTool.spec.mjs --workers=1 --reporter=line (4 passed)
9+
## Playwright
10+
- PASS - `npx playwright test tests/playwright/tools/TagsTool.spec.mjs --project=playwright`
11+
- PASS - `npx playwright test tests/playwright/tools/GameDesignApiDb.spec.mjs --project=playwright`
12+
- PASS - `npx playwright test tests/playwright/tools/GameConfigurationApiDb.spec.mjs --project=playwright`
13+
- PASS - `npx playwright test tests/playwright/tools/ToolboxSelectedGameStatusBar.spec.mjs --project=playwright`
14+
- PASS - `npx playwright test tests/playwright/tools/AssetToolMockRepository.spec.mjs --project=playwright -g "Asset repository exposes catalog tables"`
15+
16+
## Notes
17+
- Full Asset suite timed out and was not used as final validation because only the shared tag fixture test was impacted.
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
assets/toolbox/tags/js/index.js
2-
docs_build/database/ddl/tags.sql
3-
docs_build/database/dml/tags.sql
4-
docs_build/database/seed/guest/tags.json
5-
docs_build/database/seed/tags.json
1+
assets/toolbox/game-configuration/js/index.js
2+
assets/toolbox/game-design/js/index.js
3+
docs_build/database/ddl/game-configuration.sql
4+
docs_build/database/ddl/game-design.sql
5+
docs_build/dev/reports/codex_review.diff
6+
docs_build/dev/reports/coverage_changed_js_guardrail.txt
7+
docs_build/dev/reports/playwright_v8_coverage_report.txt
68
docs_build/dev/reports/PR_26177_ALFA_058-flat-project-tags_branch-validation.md
79
docs_build/dev/reports/PR_26177_ALFA_058-flat-project-tags_manual-validation-notes.md
810
docs_build/dev/reports/PR_26177_ALFA_058-flat-project-tags_report.md
911
docs_build/dev/reports/PR_26177_ALFA_058-flat-project-tags_requirement-checklist.md
1012
docs_build/dev/reports/PR_26177_ALFA_058-flat-project-tags_validation-lane.md
11-
docs_build/dev/reports/codex_changed_files.txt
12-
docs_build/dev/reports/codex_review.diff
13-
docs_build/dev/reports/coverage_changed_js_guardrail.txt
14-
docs_build/dev/reports/playwright_v8_coverage_report.txt
1513
src/dev-runtime/auth/provider-contract-stubs.mjs
14+
src/dev-runtime/persistence/tool-repositories/assets-mock-repository.js
15+
src/dev-runtime/persistence/tool-repositories/game-configuration-mock-repository.js
16+
src/dev-runtime/persistence/tool-repositories/game-design-mock-repository.js
1617
src/dev-runtime/persistence/tool-repositories/tags-mock-repository.js
1718
src/dev-runtime/server/local-api-router.mjs
19+
src/dev-runtime/toolbox-api/alfa-tool-services.mjs
20+
tests/dev-runtime/DevRuntimeBoundary.test.mjs
21+
tests/playwright/tools/AssetToolMockRepository.spec.mjs
22+
tests/playwright/tools/GameConfigurationApiDb.spec.mjs
23+
tests/playwright/tools/GameConfigurationMockRepository.spec.mjs
24+
tests/playwright/tools/GameDesignApiDb.spec.mjs
25+
tests/playwright/tools/GameDesignMockRepository.spec.mjs
1826
tests/playwright/tools/TagsTool.spec.mjs
19-
toolbox/tags/index.html
27+
tests/playwright/tools/ToolboxSelectedGameStatusBar.spec.mjs
28+
toolbox/game-configuration/index.html
29+
toolbox/game-design/index.html

0 commit comments

Comments
 (0)