Repository source: docs/plans/archive/codebase_state_feature_plan_v1.md
Codebase State Feature Plan
Status
Implementation completed on feature/codebase-state. This captures the lightweight feature sketch from the chat discussion and is not yet an approved FDP Step 2 or Step 3 artifact.
Slice commits:
Slice 1:
5afc319Add codebase state collector.Slice 2:
21f2b8eWire codebase state page.Slice 3:
e137f1fPolish codebase state presentation.Slice 4:
381b1ffCover codebase state page.
Goal
Add a user/operator-facing surface that shows the current codebase and derived-state health of the running forum. A user or operator should be able to answer: "What version/state is this forum running from, and is the read model healthy?" without shell access.
Proposed Surface
Add
GET /tools/codebase/.Link the page from
/tools/.Keep
/api/read_model_statusas the machine-oriented recovery endpoint.Reuse existing read-model status logic where possible instead of duplicating health checks.
Information To Show
Overall state: ready, stale, locked, or configuration issue.
Current app version, using the existing repository-head based version.
Current canonical repository HEAD.
Read-model repository HEAD.
Read-model schema version.
Last rebuild time.
Rebuild reason.
Execution-lock status.
Stale-marker status and reason, if present.
Basic repository checks:
.gitexists.records/exists.short commit SHA.
optional latest commit subject/date if available through
git log -1.
Basic read-model checks:
SQLite database exists.
metadata is readable.
safe row counts for core tables such as posts, profiles/users, tags, approvals, reactions, and analyses where those tables exist.
Existing backup links:
/downloads/repository.tar.gz/downloads/repository.zip/downloads/read_model.sqlite3
Implementation Slices
Slice 1 - Status Collection
Status: Completed.
Add a private collector method or small service to gather repository, read-model, lock, and stale-marker facts.
Reuse
ReadModelMetadata::repositoryHead(), existing metadata reads, stale-marker access, and execution-lock checks.Return explicit
missing,unreadable, orunknownvalues for optional or unavailable facts instead of throwing from the page.
Slice 2 - Route And Template
Status: Completed.
Add
/tools/codebase/handling inApplication::handle().Add
renderCodebaseState().Create
templates/pages/codebase_state.php.Add a Codebase entry to
renderTools().
Slice 3 - Presentation
Status: Completed.
Use existing
stackandcardconventions.Put a terse status summary first.
Use compact fact rows or tables for operator details.
Avoid prose-heavy explanatory content on the operational surface.
Slice 4 - Verification
Status: Completed.
Extend
LocalAppSmokeTest::testApplicationRendersCoreRoutes()to render/tools/codebase/.Assert stable page strings such as:
CodebaseRepository headRead modelSchema versionLock status
Add focused stale/lock assertions by adapting the existing read-model status tests.
Implementation Verification
php -l src/ForumRewrite/Application.phppassed.php -l templates/pages/codebase_state.phppassed.Targeted
LocalAppSmokeTestroute/lock/stale checks passed.php tests/run.phpwas run; the codebase-state coverage passed, but the suite still failed at the pre-existingWriteApiSmokeTest::testApprovedFlagTagSubtractsFromScoreassertion expectingScore: -100on/posts/reply-001.
Open Question
Decide whether full filesystem paths should be shown publicly. Full paths are useful for operators, but they may disclose host layout. A conservative first version should show status and basename-level path hints unless an operator-only access model is introduced.
Recommended FDP Follow-Up
If this feature proceeds through the formal feature-development process, convert this draft into:
docs/plans/codebase_state_step2_feature_description.md
Then follow with:
docs/plans/codebase_state_step3_development_plan.md