Skip to content

Commit b545ad0

Browse files
committed
Resolve ALFA_047 against current main
2 parents 65acd18 + 48d52b1 commit b545ad0

120 files changed

Lines changed: 5211 additions & 221 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.

admin/system-health.html

Lines changed: 243 additions & 21 deletions
Large diffs are not rendered by default.

assets/theme-v2/js/admin-system-health.js

Lines changed: 627 additions & 35 deletions
Large diffs are not rendered by default.

assets/toolbox/idea-board/js/index.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ function previousStatusForRestore(record) {
129129
: "Refining";
130130
}
131131

132+
function isEditableStatus(status) {
133+
return editableStatusOptions.includes(status);
134+
}
135+
132136
function rememberPreviousStatus(record) {
133137
if (record.status !== "Archived") {
134138
record.previousStatus = record.status;
@@ -433,10 +437,11 @@ function ideaIdFromText(text) {
433437
}
434438

435439
function saveIdeaRow(root, row) {
440+
if (!requireAuthenticatedWrite(root)) return;
436441
const idea = row.querySelector("[data-idea-board-idea-input]")?.value.trim();
437442
const pitch = row.querySelector("[data-idea-board-pitch-input]")?.value.trim();
438443
const status = row.querySelector("[data-idea-board-idea-status-input]")?.value;
439-
if (!idea || !pitch || !status) {
444+
if (!idea || !pitch || !isEditableStatus(status)) {
440445
updateStatus(root, "Enter an idea, pitch, and status before saving.");
441446
return;
442447
}
@@ -475,6 +480,7 @@ function saveIdeaRow(root, row) {
475480
}
476481

477482
function saveNoteRow(root, row) {
483+
if (!requireAuthenticatedWrite(root)) return;
478484
const ideaId = row.dataset.ideaId;
479485
const idea = ideaRecord(ideaId);
480486
if (idea && isLockedIdea(idea)) {
@@ -529,6 +535,7 @@ function toggleNotes(root, ideaId) {
529535
}
530536

531537
function deleteIdea(root, ideaId) {
538+
if (!requireAuthenticatedWrite(root)) return;
532539
const index = ideaTable.findIndex((record) => record.ideaId === ideaId);
533540
if (index < 0) {
534541
updateStatus(root, "Idea Board could not delete that idea.");
@@ -584,6 +591,20 @@ function currentSessionState() {
584591
}
585592
}
586593

594+
function requireAuthenticatedWrite(root) {
595+
const sessionState = currentSessionState();
596+
if (!sessionState.apiAvailable) {
597+
updateStatus(root, "API session status could not be verified. Try again shortly.");
598+
return false;
599+
}
600+
if (!sessionState.authenticated) {
601+
updateStatus(root, "Sign in before saving Idea Board changes.");
602+
window.location.href = signInUrl();
603+
return false;
604+
}
605+
return true;
606+
}
607+
587608
function createProject(root, ideaId) {
588609
const record = ideaRecord(ideaId);
589610
if (!record) {
@@ -594,16 +615,7 @@ function createProject(root, ideaId) {
594615
updateStatus(root, "Set this idea to Ready before creating a project.");
595616
return;
596617
}
597-
const sessionState = currentSessionState();
598-
if (!sessionState.apiAvailable) {
599-
updateStatus(root, "Sign-in status could not be verified. Try again shortly.");
600-
return;
601-
}
602-
if (!sessionState.authenticated) {
603-
updateStatus(root, "Sign in to create a Game Hub project.");
604-
window.location.href = signInUrl();
605-
return;
606-
}
618+
if (!requireAuthenticatedWrite(root)) return;
607619
const repository = gameHubProjectRepository();
608620
const project = repository.createGame({
609621
name: record.idea,
@@ -634,6 +646,7 @@ function archiveIdea(root, ideaId) {
634646
updateStatus(root, "Idea Board could not archive that idea.");
635647
return;
636648
}
649+
if (!requireAuthenticatedWrite(root)) return;
637650
if (record.status !== "Archived") record.previousStatus = record.status;
638651
record.status = "Archived";
639652
record.updated = today();
@@ -653,6 +666,7 @@ function restoreIdea(root, ideaId) {
653666
updateStatus(root, "Idea Board could not restore that idea.");
654667
return;
655668
}
669+
if (!requireAuthenticatedWrite(root)) return;
656670
record.status = previousStatusForRestore(record);
657671
record.previousStatus = record.status;
658672
record.updated = today();
@@ -738,6 +752,7 @@ function handleNoteAction(root, actionControl) {
738752
updateStatus(root, "Editing note.");
739753
render(root);
740754
} else if (action === "delete") {
755+
if (!requireAuthenticatedWrite(root)) return;
741756
const index = noteTable.findIndex((note) => note.noteId === noteId && note.ideaId === ideaId && !note.system);
742757
if (index >= 0) {
743758
noteTable.splice(index, 1);

docs_build/dev/PROJECT_INSTRUCTIONS.md

Lines changed: 103 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ You are working in a docs-first repo workflow.
55
Workflow:
66
PLAN_PR → BUILD_PR → APPLY_PR
77

8+
PR lifecycle gate:
9+
PR Open → Plan → Build → Validation → Approved → Merged → Main Verified → Closed
10+
11+
The PLAN_PR → BUILD_PR → APPLY_PR workflow remains preserved. PR Open is the first lifecycle status for active work, Plan happens after PR Open on the same PR branch, and Closed is the final repository-state gate.
12+
813
# WORKFLOW & EXECUTION
914

1015
## PR NAMING STANDARD
@@ -44,6 +49,66 @@ Rules:
4449
- Existing PC/LAPTOP, desktop/laptop, workspace, environment, or machine-parity examples are historical only
4550
- Future PR reports, recovery reports, validation reports, and manual validation notes must include TEAM ownership
4651

52+
## PR LIFECYCLE STATE GATE
53+
54+
Required state order:
55+
56+
1. PR Open
57+
2. Plan
58+
3. Build
59+
4. Validation
60+
5. Approved
61+
6. Merged
62+
7. Main Verified
63+
8. Closed
64+
65+
Definitions:
66+
- PR Open is the first active lifecycle state.
67+
- PR Open means the tracked PR identity and source branch have been created and named before Plan begins.
68+
- Plan happens after PR Open on the same PR branch.
69+
- Build, validation, reports, ZIP packaging, and closeout stay tied to that same PR identity and source branch.
70+
- No BUILD_PR may proceed without a PR name and active branch/PR identity unless it is explicitly marked `PLAN_ONLY`.
71+
- Build means scoped implementation, audit, report, validation, governance, or cleanup work is in progress for that PR identity.
72+
- Validation means requested checks, required report creation, manual validation notes, and ZIP packaging are being completed.
73+
- Approved means the owner or required reviewer has approved the PR outcome for merge.
74+
- Merged means the PR has merged and changes have been pushed.
75+
- Main Verified means Codex is back on `main`, `main` includes the merge commit or recorded final commit, the worktree is clean, local/origin sync is `0/0`, and no untracked files remain.
76+
- Closed means every Closed gate below is PASS.
77+
78+
Closed is valid only when all are PASS:
79+
- PR merged and changes pushed.
80+
- Current branch is `main`.
81+
- `main` includes the merge commit or recorded final commit.
82+
- Worktree clean.
83+
- Local/origin sync is `0/0`.
84+
- No untracked files.
85+
- Branch disposition recorded as `retained`.
86+
- Required reports exist.
87+
- Required repo-structured ZIP under `tmp/` exists.
88+
- Backlog updated.
89+
- Tool state updated when applicable.
90+
91+
Hard stop:
92+
- A team must not begin another PR if its previous PR is not Closed.
93+
- Exception is allowed only for explicitly documented stacked PR chains.
94+
95+
Required final closeout output:
96+
97+
```text
98+
FINAL REPOSITORY STATE:
99+
- Branch
100+
- Worktree
101+
- Local/origin sync
102+
- PR number/name
103+
- PR status
104+
- Merge/final commit
105+
- Branch disposition
106+
- Backlog update status
107+
- Tool state update status
108+
- ZIP path
109+
- Closeout PASS/FAIL
110+
```
111+
47112
## CHATGPT EXECUTION ROLE
48113

49114
ChatGPT no longer creates PLAN_PR, BUILD_PR, APPLY_PR docs, ZIP bundles, or implementation code.
@@ -784,12 +849,13 @@ The full samples smoke test rule remains separate and runs only when broadly imp
784849

785850
## CODEX REVIEW DIFF REQUIREMENT
786851

787-
Every Codex PR must produce review artifacts so ChatGPT can review the exact code changes.
852+
Every completed Codex PR or completed Codex run must produce review artifacts so ChatGPT can review the exact repo changes or the no-change evidence.
788853

789854
Codex must create:
790855

791856
- `docs_build/dev/reports/codex_review.diff`
792857
- `docs_build/dev/reports/codex_changed_files.txt`
858+
- a PR-specific or EOD-specific report under `docs_build/dev/reports/`
793859

794860
`codex_review.diff` must contain:
795861
- `git diff --cached`
@@ -804,6 +870,9 @@ Rules:
804870
- Do not pause commits
805871
- Do not add dependencies
806872
- Do not change runtime behavior just to create review artifacts
873+
- Required reports remain required even when a ZIP is created.
874+
- Required report evidence must include branch validation PASS/FAIL, a requirement-by-requirement PASS/FAIL checklist, a validation lane report, and manual validation notes.
875+
- A ZIP artifact must not replace or move required report files out of `docs_build/dev/reports/`.
807876

808877
When user asks for code review, they should upload:
809878
- PR delta ZIP
@@ -812,7 +881,7 @@ When user asks for code review, they should upload:
812881

813882
## MANUAL TEST REQUIREMENT
814883

815-
Every PR must include:
884+
Every completed PR, audit, report-only, validation-only, or EOD closeout run must include:
816885
- exact manual validation steps
817886
- expected outcome
818887
- any known out-of-scope checks
@@ -870,8 +939,15 @@ Codex ZIPs must:
870939
- be repo-structured
871940
- preserve exact repo-relative paths
872941
- be placed under `<project folder>/tmp/`
873-
- use the PR name in the ZIP filename
942+
- use the PR or EOD run name in the ZIP filename
874943
- contain no extra files outside the defined structure
944+
- include all changed or preserved repo files from the completed run
945+
- not include or depend on generated loose files under `tmp/`
946+
- not replace required report files under `docs_build/dev/reports/`
947+
948+
If a completed run changes no repo files, Codex must still create a ZIP containing the PR or EOD report that proves no repo files changed.
949+
950+
The no-change ZIP rule does not apply when the run hard-stopped before producing outputs.
875951

876952
Before Codex returns any ZIP, Codex must:
877953
1. Physically create the ZIP file.
@@ -1584,11 +1660,21 @@ Required reports:
15841660

15851661
## REQUIRED ZIP OUTPUT
15861662

1587-
Codex must ALWAYS produce a repo-structured ZIP for every PR.
1663+
Codex must ALWAYS produce a repo-structured ZIP for every completed Codex run.
1664+
1665+
This applies to:
1666+
- implementation PRs
1667+
- audit PRs
1668+
- report-only PRs
1669+
- validation-only PRs
1670+
- EOD closeout runs
1671+
- governance and cleanup runs
15881672

15891673
The ZIP must follow the existing CODEX ZIP STANDARD.
15901674

1591-
The ZIP is required output, not optional.
1675+
The ZIP must include all changed or preserved repo files from the run.
1676+
1677+
The ZIP is required output, not optional, and it does not replace required reports under `docs_build/dev/reports/`.
15921678

15931679
## HTML FILE RESTRICTIONS
15941680

@@ -1641,6 +1727,8 @@ Before packaging any PR, Codex must:
16411727

16421728
Codex must not package partially completed PRs.
16431729

1730+
PR completion is not the same as Closed. Closed requires the final repository-state gate from `PR LIFECYCLE STATE GATE`.
1731+
16441732
## ERROR HANDLING CONTRACT
16451733

16461734
- No silent fallback.
@@ -1823,10 +1911,12 @@ Do NOT require:
18231911

18241912
## CODEX ZIP RETURN CONTRACT
18251913

1826-
Codex must include the repo-structured ZIP in returned artifacts for user and ChatGPT review.
1914+
Codex must include the repo-structured ZIP path in returned artifacts for user and ChatGPT review for every completed run.
18271915

18281916
The ZIP must still follow the CODEX ZIP STANDARD.
18291917

1918+
If no repo files changed, the returned ZIP must contain the PR or EOD report proving the no-change result unless the run hard-stopped before outputs were produced.
1919+
18301920
## CODE REVIEW EVIDENCE RULE
18311921

18321922
ChatGPT must not claim code review was completed unless it inspected uploaded source, ZIP contents, or `codex_review.diff`.
@@ -2044,6 +2134,7 @@ Required steps:
20442134
- local/origin sync = 0 0
20452135
5. Record final main commit.
20462136
6. Report final repository state.
2137+
7. Produce the required repo-structured ZIP under `tmp/` containing the EOD report and any changed or preserved repo files from the closeout.
20472138

20482139
Required final state:
20492140

@@ -2082,7 +2173,7 @@ Each reviewed item must be classified as one of:
20822173
- Historical/Archive
20832174

20842175
Rules:
2085-
- Merged branches should be deleted after successful merge and main sync.
2176+
- Merged source branches should be retained by default after successful merge and main sync.
20862177
- Superseded draft PRs should be closed.
20872178
- Abandoned branches should be documented before removal.
20882179
- Active workstream branches remain.
@@ -2108,7 +2199,7 @@ Required PI closeout report fields:
21082199
- active PRs
21092200
- active branches
21102201
- closed/superseded PRs
2111-
- deleted branch candidates
2202+
- retained branch disposition and any owner-approved deletion candidates
21122203
- deferred work
21132204
- next PI priorities
21142205

@@ -2131,8 +2222,7 @@ Audit targets:
21312222
Recommendation-only first pass values:
21322223
- keep
21332224
- close
2134-
- delete local
2135-
- delete remote
2225+
- retained
21362226
- defer
21372227

21382228
Rules:
@@ -2235,6 +2325,9 @@ Completion hard stops:
22352325
- If required reports are missing, HARD STOP.
22362326
- If `docs_build/dev/reports/codex_review.diff` is missing, HARD STOP.
22372327
- If `docs_build/dev/reports/codex_changed_files.txt` is missing, HARD STOP.
2328+
- If branch validation PASS/FAIL is missing, HARD STOP.
2329+
- If the requirement-by-requirement PASS/FAIL checklist is missing, HARD STOP.
2330+
- If the validation lane report is missing, HARD STOP.
22382331
- If manual validation notes are missing, HARD STOP.
22392332
- If the PR-specific report is missing, HARD STOP.
22402333
- If an instruction compliance checklist is required and missing, HARD STOP.

docs_build/dev/ProjectInstructions/addendums/branch_context_governance.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ At the start of work, report or validate:
1818
- worktree status
1919
- active team
2020
- active assignment
21+
- active PR number/name or explicit `PLAN_ONLY`
22+
- previous PR Closed status unless this is an explicitly documented stacked PR chain
2123

2224
## Stop Conditions
2325

@@ -28,6 +30,8 @@ Stop and report before changing files when:
2830
- worktree has unrelated changes
2931
- active assignment is missing or unclear
3032
- active team does not match the branch or OWNER instruction
33+
- BUILD_PR work has no PR name and active branch/PR identity, unless explicitly marked `PLAN_ONLY`
34+
- the team's previous PR is not Closed and no stacked PR chain is documented
3135
- the requested work would modify files outside the approved scope
3236

3337
## Continuation Rule
@@ -45,6 +49,16 @@ Do not automatically return to `main` after:
4549

4650
Return to `main` only after the PR is merged, the branch is retired, or OWNER explicitly says to return to `main`.
4751

52+
Returning to `main` is required before Closed can be recorded.
53+
54+
Closed branch context requires:
55+
- current branch is `main`
56+
- `main` includes the merge commit or recorded final commit
57+
- worktree clean
58+
- local/origin sync is `0/0`
59+
- no untracked files
60+
- source branch disposition recorded as `retained`
61+
4862
## GitHub Authority
4963

5064
GitHub is authoritative for open PR state, merged PR state, review state, and remote branch state.

docs_build/dev/ProjectInstructions/addendums/branch_lock_governance.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Keep active work attached to the correct assigned team, branch, and OWNER decisi
1313
- An assigned work item keeps its owner of record until complete or OWNER reassignment.
1414
- Work must not move to another team, branch, or PR without OWNER approval.
1515
- A team with no active assignment, active branch, or active PR is inactive.
16+
- A team with a previous PR that is not Closed must not begin another PR unless OWNER documented an explicit stacked PR chain.
17+
- PR Open begins only after the branch and PR identity are named.
18+
- Plan, Build, validation, reports, ZIP packaging, and closeout stay tied to the same PR identity and source branch.
19+
- Closed ends only after the final main-return, clean-worktree, local/origin `0/0`, no-untracked-files, required-report, required-ZIP, backlog, applicable tool-state, and branch-disposition gates pass.
1620
- Project Instructions must not assume a permanent team roster.
1721

1822
## Branch Rules
@@ -22,6 +26,8 @@ Keep active work attached to the correct assigned team, branch, and OWNER decisi
2226
- Keep work on the active branch until the PR is merged, the branch is retired, or OWNER says to return to `main`.
2327
- Do not commit directly to `main` unless OWNER explicitly approves.
2428
- Do not merge stale historical branches directly unless they are current, clean, still needed, and OWNER-approved.
29+
- Retain source branches by default after merge and closeout.
30+
- Record branch disposition before Closed as `retained`.
2531

2632
## OWNER Override
2733

0 commit comments

Comments
 (0)