Files
chrnx-dev-wp/docs/superpowers/plans/2026-08-15-projects-as-entities.md
T
2026-08-15 14:15:20 -05:00

1044 lines
41 KiB
Markdown

# CHRNX Projects as First-Class Entities Implementation Plan
<!-- markdownlint-disable MD013 -->
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Promote projects from a topic term to an entity taxonomy with its own term meta, landing page, and archive, modelled exactly on the existing `chrnx_release` pattern.
**Architecture:** Register `chrnx_project` through the shared editorial taxonomy contract, give it term meta mirroring `chrnx_release` (cover, status, and three URLs), and render it through two new dynamic blocks cloned from `release-list` and `release-detail`. Retire the `chrnx_project_featured` post meta and the `selected-work` block, because music already proves a landing does not need a featured picker. Repair the missing `taxonomy-chrnx_show.html` while the same template shape is fresh.
**Tech Stack:** WordPress 7.0.4 block theme, PHP 8.3, dynamic blocks with `render.php`, term meta on term edit screens, PHPUnit, Node smoke tests, Playwright on Chromium/Firefox/WebKit, PHPCS, WordPress Scripts linting.
**Spec:** `docs/superpowers/specs/2026-08-15-projects-as-entities-design.md`
## Global Constraints
- Theme version is `0.4.4`. Any release bump updates `style.css`, `functions.php` (`CHRNX_VERSION`), and all 20 `blocks/*/block.json` together, or `npm run package` refuses to build.
- New block `block.json` files use `"apiVersion": 3` and `"version": "0.4.4"` to match every existing block.
- All PHP follows the theme's PHPCS ruleset; run `npm run phpcs` before every commit.
- Term meta sanitizers reuse existing helpers: `chrnx_sanitize_https_url`, `absint`, `sanitize_text_field`.
- Term meta auth reuses `chrnx_auth_release_meta`, as `show-meta.php` already does.
- Never invent project metadata. Repository, site, package URLs, and status come from the author.
- Do not push, deploy, or mutate production content. Production migration is Task 9 and is executed only after the author confirms the post-to-project mapping.
- Work on a branch off `main`. `main` is at the merge commit for `fix/document-language`.
---
## File map
| File | Responsibility |
|---|---|
| `inc/taxonomies.php` | Add the `chrnx_project` definition to the shared contract |
| `inc/project-meta.php` | Rewritten: project term meta, edit fields, save handler |
| `inc/queries.php` | Remove `chrnx_get_selected_project_ids()` |
| `blocks/project-list/` | New: lists every project as a card |
| `blocks/project-detail/` | New: renders one project's header on its archive |
| `blocks/selected-work/` | Deleted |
| `templates/taxonomy-chrnx_project.html` | New: project archive |
| `templates/taxonomy-chrnx_show.html` | New: repairs the podcast archive gap |
| `patterns/projects-landing.php` | New: banner plus project list |
| `patterns/home-projects.php` | Banner copy only, no list |
| `tests/php/TaxonomiesTest.php` | Extend definitions with `chrnx_project` |
| `tests/php/ProjectMetaTest.php` | New: term meta contract |
| `tests/smoke/templates.test.mjs` | Assert both new templates exist |
---
### Task 1: Register the project taxonomy
**Files:**
- Modify: `inc/taxonomies.php:14-56`
- Test: `tests/php/TaxonomiesTest.php:24-60`
**Interfaces:**
- Consumes: `chrnx_register_editorial_taxonomy( $name, $definition )`, already defined at `inc/taxonomies.php:66`.
- Produces: taxonomy `chrnx_project` with `rest_base` `project` and seeded terms `green-tea`, `ailed`.
- [ ] **Step 1: Write the failing test**
In `tests/php/TaxonomiesTest.php`, add to the `$this->definitions` array in `set_up()`, after the `chrnx_release` entry:
```php
'chrnx_project' => array(
'rest_base' => 'project',
'terms' => array(
'green-tea' => 'Green Tea',
'ailed' => 'Ailed',
),
),
```
- [ ] **Step 2: Run the test to verify it fails**
Run: `npm run test:php`
Expected: FAIL. The existing loop over `$this->definitions` asserts `taxonomy_exists()` and term presence, so `chrnx_project` reports as missing.
- [ ] **Step 3: Add the taxonomy definition**
In `inc/taxonomies.php`, inside `chrnx_get_editorial_taxonomies()`, add after the `chrnx_release` entry:
```php
'chrnx_project' => array(
'singular' => __( 'Project', 'chrnx' ),
'plural' => __( 'Projects', 'chrnx' ),
'rest_base' => 'project',
'terms' => array(
'green-tea' => __( 'Green Tea', 'chrnx' ),
'ailed' => __( 'Ailed', 'chrnx' ),
),
),
```
- [ ] **Step 4: Run the test to verify it passes**
Run: `npm run test:php`
Expected: PASS.
- [ ] **Step 5: Commit**
```bash
git add inc/taxonomies.php tests/php/TaxonomiesTest.php
git commit -m "feat: model projects as their own editorial taxonomy"
```
---
### Task 2: Project term metadata
**Files:**
- Modify: `inc/project-meta.php` (replace the whole file, currently 37 lines of post meta)
- Test: `tests/php/ProjectMetaTest.php` (create)
**Interfaces:**
- Consumes: `chrnx_sanitize_https_url()` from `inc/release-meta.php`, `chrnx_auth_release_meta()`, `chrnx_print_release_field( $name, $label, $value, $type, $description )`.
- Produces: `chrnx_get_project_meta_definitions(): array<string,string>`, `chrnx_get_project_links( int $term_id ): array<string,string>`.
- [ ] **Step 1: Write the failing test**
Create `tests/php/ProjectMetaTest.php`:
```php
<?php
/**
* Tests for project term metadata.
*
* @package CHRNX
*/
/**
* Verify the project term meta contract.
*/
class ProjectMetaTest extends WP_UnitTestCase {
/**
* Register taxonomies and meta before each test.
*/
public function set_up() {
parent::set_up();
do_action( 'init' );
}
/**
* Ensure every project meta key is registered for the taxonomy.
*/
public function test_project_meta_keys_are_registered() {
$registered = get_registered_meta_keys( 'term', 'chrnx_project' );
foreach ( array_keys( chrnx_get_project_meta_definitions() ) as $meta_key ) {
$this->assertArrayHasKey( $meta_key, $registered );
}
}
/**
* Ensure a plain http repository URL is rejected.
*/
public function test_project_links_reject_insecure_urls() {
$term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project' ) );
update_term_meta( $term_id, 'chrnx_project_repo', 'http://example.com/repo' );
$this->assertArrayNotHasKey( 'repo', chrnx_get_project_links( $term_id ) );
}
/**
* Ensure stored https links come back keyed by their slot.
*/
public function test_project_links_return_stored_https_urls() {
$term_id = self::factory()->term->create( array( 'taxonomy' => 'chrnx_project' ) );
update_term_meta( $term_id, 'chrnx_project_repo', 'https://github.com/Expressive-Tea/green-tea' );
update_term_meta( $term_id, 'chrnx_project_package', 'https://www.npmjs.com/package/@green-tea/core' );
$links = chrnx_get_project_links( $term_id );
$this->assertSame( 'https://github.com/Expressive-Tea/green-tea', $links['repo'] );
$this->assertSame( 'https://www.npmjs.com/package/@green-tea/core', $links['package'] );
$this->assertArrayNotHasKey( 'site', $links );
}
}
```
- [ ] **Step 2: Run the test to verify it fails**
Run: `npm run test:php`
Expected: FAIL with "Call to undefined function chrnx_get_project_meta_definitions()".
- [ ] **Step 3: Replace `inc/project-meta.php`**
```php
<?php
/**
* Project term metadata.
*
* @package CHRNX
*/
/**
* Return the outbound link slots a project can carry.
*
* One generic package slot rather than one field per registry: Green Tea ships
* to npm, a Rust project would ship to crates.io, a Python one to PyPI. A
* per-registry list would need editing every time a new language shows up.
*
* @return array<string,array<string,string>> Slot key to label and icon.
*/
function chrnx_get_project_link_slots() {
return array(
'repo' => array(
'label' => __( 'Repository', 'chrnx' ),
'icon' => '<path d="M9 19c-5 1.5-5-2.5-7-3"/><path d="M15 22v-4a3.4 3.4 0 0 0-1-2.6c3-.3 6-1.5 6-6.6a5 5 0 0 0-1.4-3.5 4.6 4.6 0 0 0-.1-3.5s-1.1-.3-3.5 1.3a12 12 0 0 0-6 0C6.6 1.5 5.5 1.8 5.5 1.8a4.6 4.6 0 0 0-.1 3.5A5 5 0 0 0 4 8.8c0 5.1 3 6.3 6 6.6a3.4 3.4 0 0 0-1 2.6v4"/>',
),
'package' => array(
'label' => __( 'Package', 'chrnx' ),
'icon' => '<path d="m7.5 4.3 9 5.2"/><path d="M21 16V8a2 2 0 0 0-1-1.7l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.7l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16"/><path d="M3.3 7 12 12l8.7-5"/><path d="M12 22V12"/>',
),
'site' => array(
'label' => __( 'Website', 'chrnx' ),
'icon' => '<circle cx="12" cy="12" r="10"/><path d="M12 2a15 15 0 0 1 0 20"/><path d="M12 2a15 15 0 0 0 0 20"/><path d="M2 12h20"/>',
),
);
}
/**
* Return the project term meta keys and their sanitizers.
*
* @return array<string,string> Meta key to sanitize callback.
*/
function chrnx_get_project_meta_definitions() {
$definitions = array(
'chrnx_project_cover' => 'absint',
'chrnx_project_status' => 'sanitize_text_field',
);
foreach ( array_keys( chrnx_get_project_link_slots() ) as $slot ) {
$definitions[ 'chrnx_project_' . $slot ] = 'chrnx_sanitize_https_url';
}
return $definitions;
}
/**
* Register project term metadata.
*/
function chrnx_register_project_meta() {
foreach ( chrnx_get_project_meta_definitions() as $meta_key => $sanitize ) {
register_term_meta(
'chrnx_project',
$meta_key,
array(
'type' => 'chrnx_project_cover' === $meta_key ? 'integer' : 'string',
'single' => true,
'show_in_rest' => true,
'sanitize_callback' => $sanitize,
'auth_callback' => 'chrnx_auth_release_meta',
)
);
}
}
add_action( 'init', 'chrnx_register_project_meta' );
/**
* Return the stored outbound links for one project.
*
* @param int $term_id Project term ID.
* @return array<string,string> Slot key to URL, omitting empty ones.
*/
function chrnx_get_project_links( $term_id ) {
$links = array();
foreach ( array_keys( chrnx_get_project_link_slots() ) as $slot ) {
$url = chrnx_sanitize_https_url( get_term_meta( $term_id, 'chrnx_project_' . $slot, true ) );
if ( '' !== $url ) {
$links[ $slot ] = $url;
}
}
return $links;
}
/**
* Render the project metadata fields on the term edit screen.
*
* @param WP_Term $term Project term.
*/
function chrnx_render_project_edit_fields( $term ) {
chrnx_print_release_field(
'chrnx_project_status',
__( 'Status', 'chrnx' ),
(string) get_term_meta( $term->term_id, 'chrnx_project_status', true ),
'text',
__( 'Short and honest, for example Beta, Activo or Archivado.', 'chrnx' )
);
foreach ( chrnx_get_project_link_slots() as $slot => $definition ) {
chrnx_print_release_field(
'chrnx_project_' . $slot,
$definition['label'],
(string) get_term_meta( $term->term_id, 'chrnx_project_' . $slot, true ),
'url',
__( 'HTTPS only. Leave empty to hide this icon.', 'chrnx' )
);
}
chrnx_print_release_field(
'chrnx_project_cover',
__( 'Cover attachment ID', 'chrnx' ),
(string) absint( get_term_meta( $term->term_id, 'chrnx_project_cover', true ) ),
'text',
__( 'Leave empty to use the shared placeholder art.', 'chrnx' )
);
}
add_action( 'chrnx_project_edit_form_fields', 'chrnx_render_project_edit_fields' );
/**
* Persist project term metadata from the term edit screen.
*
* @param int $term_id Project term ID.
*/
function chrnx_save_project_meta( $term_id ) {
if ( ! chrnx_auth_release_meta() ) {
return;
}
// Core supplies and verifies the add/update term nonce on these screens.
$nonce = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : '';
if ( ! wp_verify_nonce( $nonce, 'update-tag_' . $term_id ) && ! wp_verify_nonce( $nonce, 'add-tag' ) ) {
return;
}
foreach ( chrnx_get_project_meta_definitions() as $meta_key => $sanitize ) {
if ( ! isset( $_POST[ $meta_key ] ) ) {
continue;
}
$value = call_user_func( $sanitize, wp_unslash( $_POST[ $meta_key ] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized by the mapped callback.
if ( '' === $value || 0 === $value ) {
delete_term_meta( $term_id, $meta_key );
continue;
}
update_term_meta( $term_id, $meta_key, $value );
}
}
add_action( 'edited_chrnx_project', 'chrnx_save_project_meta' );
add_action( 'created_chrnx_project', 'chrnx_save_project_meta' );
```
- [ ] **Step 4: Confirm the term edit hook fires**
Resolved before dispatch, no theme code needed. `{$taxonomy}_edit_form_fields` is a WordPress core hook fired by `wp-admin/edit-tag-form.php`, which is why `inc/show-meta.php` hooks `chrnx_show_edit_form_fields` without any dispatcher of its own. Hooking `chrnx_project_edit_form_fields` is enough. Confirm the fields appear by loading `/wp-admin/term.php?taxonomy=chrnx_project&tag_ID=<id>`.
- [ ] **Step 5: Run the tests to verify they pass**
Run: `npm run test:php && npm run phpcs`
Expected: PASS, no PHPCS output.
- [ ] **Step 6: Commit**
```bash
git add inc/project-meta.php tests/php/ProjectMetaTest.php
git commit -m "feat: give projects a repository, package and status"
```
---
### Task 3: Placeholder cover art
**Files:**
- Create: `assets/images/generated/placeholder-project-384.{webp,avif}`, `-768.{webp,avif}`, `placeholder-project.json`
- Modify: `inc/media.php` allowlist
**Interfaces:**
- Produces: art slug `placeholder-project`, consumed by `chrnx_get_topic_portrait_markup( 'placeholder-project', ... )`.
- [ ] **Step 1: Read how `placeholder-release` is allowlisted**
Run: `grep -n "placeholder-release" inc/media.php`
The art slug must appear in the same allowlist, or `chrnx_get_topic_art_asset()` returns an empty string and the helper renders nothing.
- [ ] **Step 2: Generate the master image**
Ask the author for the master PNG. Do not substitute CSS art, an SVG, or a stock image. Stop here until the author approves the generated master.
- [ ] **Step 3: Build the derivatives**
Run: `./scripts/build-responsive-images.sh <path-to-master.png>`
Expected: `384` and `768` variants in both webp and avif, plus the JSON dimensions sidecar.
- [ ] **Step 4: Add the slug to the allowlist**
Mirror the `placeholder-release` entry in `inc/media.php` exactly, changing only the slug.
- [ ] **Step 5: Verify the helper returns markup**
Run: `npx wp-env run cli wp eval 'echo chrnx_get_topic_portrait_markup( "placeholder-project", "", "test" ) === "" ? "VACIO" : "OK";'`
Expected: `OK`.
- [ ] **Step 6: Commit**
```bash
git add assets/images/generated/placeholder-project* inc/media.php
git commit -m "feat: add shared placeholder art for projects without a cover"
```
---
### Task 4: The project list block
**Files:**
- Create: `blocks/project-list/block.json`, `blocks/project-list/render.php`
- Modify: `inc/blocks.php:235` — add `'project-list'` to the `$blocks` array
- Test: `tests/php/ProjectBlocksTest.php` (create)
**Registration is not automatic.** `chrnx_register_editorial_blocks()` iterates an explicit allowlist array and only then calls `register_block_type()` on the matching directory. Creating `blocks/project-list/` without adding its name to that array leaves the block unregistered, and `do_blocks()` returns the raw comment, so the test fails with no useful message.
**Interfaces:**
- Consumes: `chrnx_get_project_links()`, `chrnx_get_heading_level()`, `chrnx_get_topic_portrait_markup()`, `chrnx_get_platform_links_markup()`.
- Produces: block `chrnx/project-list`, consumed by `patterns/projects-landing.php`.
- [ ] **Step 1: Write the failing test**
Create `tests/php/ProjectBlocksTest.php`:
```php
<?php
/**
* Tests for the project blocks.
*
* @package CHRNX
*/
/**
* Verify project block rendering.
*/
class ProjectBlocksTest extends WP_UnitTestCase {
/**
* Register blocks and taxonomies before each test.
*/
public function set_up() {
parent::set_up();
do_action( 'init' );
}
/**
* Ensure the list renders one card per project with its status.
*/
public function test_project_list_renders_a_card_per_project() {
$term_id = self::factory()->term->create(
array(
'taxonomy' => 'chrnx_project',
'name' => 'Green Tea',
'slug' => 'green-tea-test',
)
);
update_term_meta( $term_id, 'chrnx_project_status', 'Beta' );
$markup = do_blocks( '<!-- wp:chrnx/project-list /-->' );
$this->assertStringContainsString( 'chrnx-project-card', $markup );
$this->assertStringContainsString( 'Green Tea', $markup );
$this->assertStringContainsString( 'Beta', $markup );
}
/**
* Ensure a project without a cover still renders art.
*/
public function test_project_without_cover_uses_placeholder_art() {
self::factory()->term->create(
array(
'taxonomy' => 'chrnx_project',
'slug' => 'coverless-test',
)
);
$markup = do_blocks( '<!-- wp:chrnx/project-list /-->' );
$this->assertStringContainsString( 'chrnx-project-card__fallback', $markup );
}
}
```
- [ ] **Step 2: Run the test to verify it fails**
Run: `npm run test:php`
Expected: FAIL. `do_blocks()` returns the unrendered comment because `chrnx/project-list` is not registered.
- [ ] **Step 3: Create `blocks/project-list/block.json`**
```json
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "chrnx/project-list",
"version": "0.4.4",
"title": "Project List",
"category": "theme",
"description": "Every project, each linking to its own page.",
"textdomain": "chrnx",
"attributes": {
"headingLevel": { "type": "integer", "default": 4, "enum": [2, 3, 4, 5, 6] }
},
"supports": { "html": false },
"render": "file:./render.php"
}
```
- [ ] **Step 3b: Register the block**
Add `'project-list'` to the `$blocks` array in `chrnx_register_editorial_blocks()` at `inc/blocks.php:235`, keeping the existing single-line array format.
- [ ] **Step 4: Create `blocks/project-list/render.php`**
```php
<?php
/**
* Project List block render.
*
* @package CHRNX
*/
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 4, 4 );
$chrnx_terms = get_terms(
array(
'taxonomy' => 'chrnx_project',
'hide_empty' => false,
)
);
if ( is_wp_error( $chrnx_terms ) || empty( $chrnx_terms ) ) {
return;
}
?>
<div <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-project-list' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<?php
foreach ( $chrnx_terms as $chrnx_term ) :
$chrnx_link = get_term_link( $chrnx_term );
$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_project_status', true );
$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_project_cover', true ) );
$chrnx_links = chrnx_get_project_links( $chrnx_term->term_id );
?>
<article class="chrnx-project-card">
<?php if ( ! is_wp_error( $chrnx_link ) ) : ?>
<a class="chrnx-project-card__link" href="<?php echo esc_url( $chrnx_link ); ?>">
<?php endif; ?>
<span class="chrnx-project-card__art">
<?php if ( $chrnx_cover > 0 ) : ?>
<?php echo wp_get_attachment_image( $chrnx_cover, 'chrnx-card', false, array( 'class' => 'chrnx-project-card__cover' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<?php echo chrnx_get_topic_portrait_markup( 'placeholder-project', '', 'chrnx-project-card__fallback' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?>
<?php endif; ?>
</span>
<h<?php echo esc_attr( $chrnx_heading ); ?> class="chrnx-project-card__title"><?php echo esc_html( $chrnx_term->name ); ?></h<?php echo esc_attr( $chrnx_heading ); ?>>
<?php if ( '' !== $chrnx_status ) : ?>
<p class="chrnx-project-card__status"><?php echo esc_html( $chrnx_status ); ?></p>
<?php endif; ?>
<?php if ( ! is_wp_error( $chrnx_link ) ) : ?>
</a>
<?php endif; ?>
<?php echo chrnx_get_platform_links_markup( $chrnx_links, 'chrnx-platform-links', chrnx_get_project_link_slots() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</article>
<?php endforeach; ?>
</div>
```
- [ ] **Step 5: Confirm the icon lookup**
Resolved before dispatch, no change needed to the helper. `chrnx_get_platform_links_markup( array $links, $class_name, $platforms = null )` at `inc/release-meta.php:120` already takes an explicit slot-definition array as its third argument and falls back to `chrnx_get_release_platforms()` only when that argument is omitted. Its loop skips any slot missing from `$platforms`, so omitting the third argument would silently render no links at all for projects. The render code above passes `chrnx_get_project_link_slots()` explicitly. Verify that argument is present.
- [ ] **Step 6: Run the tests to verify they pass**
Run: `npm run test:php && npm run phpcs`
Expected: PASS.
- [ ] **Step 7: Commit**
```bash
git add blocks/project-list tests/php/ProjectBlocksTest.php
git commit -m "feat: list every project with its status and links"
```
---
### Task 5: The project detail block
**Files:**
- Create: `blocks/project-detail/block.json`, `blocks/project-detail/render.php`
- Modify: `inc/blocks.php:235` — add `'project-detail'` to the `$blocks` array, exactly as Task 4 added `'project-list'`
- Modify: `inc/blocks.php:32` — add `'chrnx_project'` to the `is_tax()` list
- Modify: `inc/queries.php` lines 377, 404, 434, 489, 529 — add `'chrnx_project'` to each taxonomy list
- Test: `tests/php/ProjectBlocksTest.php` (extend)
**This block renders a HEADER ONLY. It does not list posts.** `blocks/release-detail/render.php` also renders a tracklist, and the first draft of this plan said to clone it line for line. That was wrong twice over: projects have no track numbers, and the posts belonging to a project are ordinary reverse-chronological editorial posts — which is exactly what `chrnx/journal-stream` already renders on an archive.
The correct model is `chrnx_show`, not `chrnx_release`. Podcast programmes list their episodes through `journal-stream` on the archive, because `chrnx_show` appears in the taxonomy lists inside `inc/queries.php`. `chrnx_project` appears in none of them, so without those five edits a project archive would render the whole unfiltered journal — the wrong posts, with no error.
**Interfaces:**
- Consumes: `chrnx_get_project_links()`, `chrnx_get_topic_portrait_markup()`, `chrnx_get_heading_level()`.
- Produces: block `chrnx/project-detail`, consumed by `templates/taxonomy-chrnx_project.html`.
- [ ] **Step 1: Add `chrnx_project` to every taxonomy list**
Five in `inc/queries.php` and one in `inc/blocks.php`. Read each one before editing; two of them list only two taxonomies rather than three.
```bash
grep -n "chrnx_topic', 'chrnx_language'" inc/queries.php inc/blocks.php
```
- [ ] **Step 2: Write the failing test**
Append to `tests/php/ProjectBlocksTest.php`:
```php
/**
* Ensure the detail block renders the queried project header.
*/
public function test_project_detail_renders_the_queried_term() {
$term_id = self::factory()->term->create(
array(
'taxonomy' => 'chrnx_project',
'name' => 'Ailed',
'slug' => 'ailed-test',
'description' => 'A chess engine that feels.',
)
);
update_term_meta( $term_id, 'chrnx_project_repo', 'https://github.com/example/ailed' );
update_term_meta( $term_id, 'chrnx_project_status', 'Activo' );
$this->go_to( get_term_link( $term_id ) );
$markup = do_blocks( '<!-- wp:chrnx/project-detail /-->' );
$this->assertStringContainsString( 'A chess engine that feels.', $markup );
$this->assertStringContainsString( 'https://github.com/example/ailed', $markup );
$this->assertStringContainsString( 'Activo', $markup );
}
/**
* Ensure the detail block renders nothing outside a project archive.
*/
public function test_project_detail_is_silent_off_its_archive() {
$this->go_to( home_url( '/' ) );
$this->assertSame( '', trim( do_blocks( '<!-- wp:chrnx/project-detail /-->' ) ) );
}
/**
* Ensure a project archive filters the journal to that project.
*/
public function test_project_archive_filters_the_journal() {
$term_id = self::factory()->term->create(
array(
'taxonomy' => 'chrnx_project',
'slug' => 'filter-test',
)
);
$mine = self::factory()->post->create( array( 'post_title' => 'Belongs to the project' ) );
self::factory()->post->create( array( 'post_title' => 'Unrelated post' ) );
wp_set_object_terms( $mine, array( $term_id ), 'chrnx_project' );
$this->go_to( get_term_link( $term_id ) );
$markup = do_blocks( '<!-- wp:chrnx/journal-stream /-->' );
$this->assertStringContainsString( 'Belongs to the project', $markup );
$this->assertStringNotContainsString( 'Unrelated post', $markup );
}
```
- [ ] **Step 3: Run the tests to verify they fail**
Run: `npm run test:php`
Expected: FAIL — the block is unregistered, and the archive filter test shows the unrelated post.
- [ ] **Step 4: Create the block**
`blocks/project-detail/block.json` mirrors Task 4's JSON with `"name": "chrnx/project-detail"`, `"title": "Project Detail"`, `"description": "Cover, status, description and links for the queried project."`, and a `headingLevel` attribute defaulting to 2.
`blocks/project-detail/render.php` follows the HEAD section of `blocks/release-detail/render.php` only — its guard, its art column, and its intro column. Stop before the tracklist; do not port it.
```php
<?php
/**
* Project Detail block render.
*
* @package CHRNX
*/
$chrnx_term = get_queried_object();
if ( ! $chrnx_term instanceof WP_Term || 'chrnx_project' !== $chrnx_term->taxonomy ) {
return;
}
$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_project_status', true );
$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_project_cover', true ) );
$chrnx_links = chrnx_get_project_links( $chrnx_term->term_id );
// Without status, description or links there is no second column to fill.
$chrnx_has_intro = '' !== $chrnx_status || '' !== $chrnx_term->description || ! empty( $chrnx_links );
$chrnx_head_class = 'chrnx-project-detail__head' . ( $chrnx_has_intro ? '' : ' is-bare' );
?>
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-project-detail' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<div class="<?php echo esc_attr( $chrnx_head_class ); ?>">
<div class="chrnx-project-detail__art">
<?php if ( $chrnx_cover > 0 ) : ?>
<?php echo wp_get_attachment_image( $chrnx_cover, 'large', false, array( 'class' => 'chrnx-project-detail__cover' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<?php echo chrnx_get_topic_portrait_markup( 'placeholder-project', '', 'chrnx-project-detail__fallback' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?>
<?php endif; ?>
</div>
<div class="chrnx-project-detail__intro">
<?php if ( '' !== $chrnx_status ) : ?>
<p class="chrnx-project-detail__status"><?php echo esc_html( $chrnx_status ); ?></p>
<?php endif; ?>
<?php if ( '' !== $chrnx_term->description ) : ?>
<p class="chrnx-project-detail__description"><?php echo esc_html( $chrnx_term->description ); ?></p>
<?php endif; ?>
<?php echo chrnx_get_platform_links_markup( $chrnx_links, 'chrnx-platform-links', chrnx_get_project_link_slots() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
</section>
```
- [ ] **Step 5: Register the block**
Add `'project-detail'` to the `$blocks` array at `inc/blocks.php:235`.
- [ ] **Step 6: Run the tests to verify they pass**
Run: `npm run test:php && npm run phpcs`
Expected: PASS.
- [ ] **Step 7: Commit**
```bash
git add blocks/project-detail inc/blocks.php inc/queries.php tests/php/ProjectBlocksTest.php
git commit -m "feat: give each project its own page header and post stream"
```
---
### Task 6: Archive templates for projects and shows
**Files:**
- Create: `templates/taxonomy-chrnx_project.html`
- Create: `templates/taxonomy-chrnx_show.html`
- Test: `tests/smoke/templates.test.mjs`
**Interfaces:**
- Consumes: blocks `chrnx/project-detail` (Task 5) and `chrnx/show-links` (existing).
- [ ] **Step 1: Write the failing test**
Read `tests/smoke/templates.test.mjs` first to match its existing assertion style, then add both filenames to whatever list it checks.
- [ ] **Step 2: Run the test to verify it fails**
Run: `npm run test:smoke`
Expected: FAIL, both templates missing.
- [ ] **Step 3: Create `templates/taxonomy-chrnx_project.html`**
```html
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-archive chrnx-project-archive","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group chrnx-archive chrnx-project-archive" tabindex="-1">
<!-- wp:query-title {"type":"archive","level":1,"showPrefix":false} /-->
<!-- wp:chrnx/project-detail /-->
<!-- wp:chrnx/journal-stream /-->
<!-- wp:chrnx/subscribe-cta {"className":"is-style-quiet"} /-->
</main>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
```
- [ ] **Step 4: Create `templates/taxonomy-chrnx_show.html`**
This repairs the gap named in the spec: shows currently fall through to the generic archive and never render their own detail.
```html
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-archive chrnx-show-archive","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group chrnx-archive chrnx-show-archive" tabindex="-1">
<!-- wp:query-title {"type":"archive","level":1,"showPrefix":false} /-->
<!-- wp:chrnx/show-links /-->
</main>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
```
- [ ] **Step 5: Verify both archives render**
Run: `npx wp-env run cli wp eval 'echo get_term_link( "green-tea", "chrnx_project" );'` then curl that URL and confirm HTTP 200 with the project title in the output. Repeat for `silicon-ranch` in `chrnx_show`.
- [ ] **Step 6: Run the tests to verify they pass**
Run: `npm run test:smoke && npm run test:php`
Expected: PASS.
- [ ] **Step 7: Commit**
```bash
git add templates/taxonomy-chrnx_project.html templates/taxonomy-chrnx_show.html tests/smoke/templates.test.mjs
git commit -m "feat: give project and show archives their own templates"
```
---
### Task 7: The projects landing
**Files:**
- Create: `patterns/projects-landing.php`
- Modify: `patterns/home-projects.php`
- Modify: `assets/css/components.css`
**Interfaces:**
- Consumes: `chrnx/project-list` (Task 4), `chrnx_get_atmosphere_markup()`, `chrnx_get_topic_portrait_markup()`.
- Produces: pattern slug `chrnx/projects-landing`, referenced by production page 740 in Task 9.
- [ ] **Step 1: Create `patterns/projects-landing.php`**
Mirrors `patterns/music-landing.php` exactly: a `chrnx-character-stage` with atmosphere, content, and art layers, then the list block. Copy is the author's, approved in the spec.
```php
<?php
/**
* Title: Projects landing
* Slug: chrnx/projects-landing
* Categories: chrnx-projects
* Description: Honest introduction to the projects and every one that exists.
* Inserter: yes
*
* @package CHRNX
*/
?>
<!-- wp:group {"tagName":"section","className":"chrnx-projects-landing","layout":{"type":"constrained"}} -->
<section class="wp-block-group chrnx-projects-landing">
<!-- wp:group {"className":"chrnx-character-stage","layout":{"type":"constrained"}} -->
<div class="wp-block-group chrnx-character-stage">
<!-- wp:html --><div class="chrnx-character-stage__atmosphere" aria-hidden="true"><?php echo chrnx_get_atmosphere_markup( 'projects-grunge', 'chrnx-character-stage__backdrop' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?></div><!-- /wp:html -->
<!-- wp:group {"className":"chrnx-character-stage__content","layout":{"type":"constrained"}} -->
<div class="wp-block-group chrnx-character-stage__content">
<!-- wp:heading {"level":2} --><h2 class="wp-block-heading"><?php echo esc_html__( 'Proyectos', 'chrnx' ); ?></h2><!-- /wp:heading -->
<!-- wp:paragraph --><p><?php echo esc_html__( 'Aquí va lo que mi cerebro tira en formato de código.', 'chrnx' ); ?></p><!-- /wp:paragraph -->
<!-- wp:paragraph --><p><?php echo esc_html__( 'Una noche me agarra la loquera y sale código. A veces sirve, a veces nomás me deja dormir. Lo que sobrevive lo dejo aquí, con su repo y su estado real, sin adornos.', 'chrnx' ); ?></p><!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
<!-- wp:html --><div class="chrnx-character-stage__art"><?php echo chrnx_get_topic_portrait_markup( 'code', '', 'chrnx-projects-landing__portrait' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?></div><!-- /wp:html -->
</div>
<!-- /wp:group -->
<!-- wp:heading {"level":3} --><h3 class="wp-block-heading"><?php echo esc_html__( 'Lo que existe', 'chrnx' ); ?></h3><!-- /wp:heading -->
<!-- wp:chrnx/project-list /-->
</section>
<!-- /wp:group -->
```
- [ ] **Step 2: Strip the list out of `patterns/home-projects.php`**
Replace the `<!-- wp:chrnx/selected-work /-->` line with a paragraph, so the home section becomes banner copy only, matching `home-music.php`:
```php
<!-- wp:paragraph --><p><?php echo esc_html__( 'Lo que sobrevive a la loquera nocturna, con su repo y su estado real.', 'chrnx' ); ?></p><!-- /wp:paragraph -->
```
- [ ] **Step 3: Add card styles**
In `assets/css/components.css`, find the `.chrnx-release-card` rules and add `.chrnx-project-card` to the same selectors rather than duplicating the block. The two cards are the same object with a different label.
- [ ] **Step 4: Verify the landing renders locally**
Create a local page containing only `<!-- wp:pattern {"slug":"chrnx/projects-landing"} /-->`, then curl it and confirm the heading, both paragraphs, and one `chrnx-project-card` per seeded term.
- [ ] **Step 5: Run the full local suite**
Run: `npm run test:smoke && npm run test:php && npm run lint:css && npm run phpcs`
Expected: PASS.
- [ ] **Step 6: Commit**
```bash
git add patterns/projects-landing.php patterns/home-projects.php assets/css/components.css
git commit -m "feat: give projects a landing of their own"
```
---
### Task 8: Retire the featured picker
**Files:** the surface is wider than a block deletion. Every one of these was verified to reference the retired feature.
- Delete: `blocks/selected-work/` (block.json + render.php)
- Delete: `assets/js/editor-project.js` — the editor sidebar panel exists only to toggle `chrnx_project_featured`, and it self-hides unless the post carries the `projects` topic, which Task 9 retires
- Delete: `tests/js/editor-project.test.js` — four references, all covering the deleted panel
- Modify: `inc/queries.php:274` remove `chrnx_get_selected_project_ids()` and its docblock
- Modify: `inc/blocks.php:235` remove `'selected-work'` from the registration list
- Modify: `inc/editor.php:49-50` remove the `chrnx-editor-project` enqueue, and `:66` its `wp_set_script_translations()` call
- Modify: `scripts/seed-test-content.php:143,147` remove `chrnx_project_featured` from the seeded meta keys and the `update_post_meta()` call
- Modify: `assets/css/components.css` remove `.chrnx-selected-work*` rules
- Modify: `tests/php/EditorialQueriesTest.php` drop the coverage of the removed query
**Interfaces:**
- Removes: `chrnx_get_selected_project_ids()`, post meta `chrnx_project_featured`, block `chrnx/selected-work`.
- [ ] **Step 1: Confirm nothing else references them**
```bash
grep -rn "selected-work\|selected_project\|chrnx_project_featured\|chrnx-editor-project" \
--include="*.php" --include="*.js" --include="*.json" --include="*.html" --include="*.mjs" \
--include="*.css" inc blocks patterns templates assets tests scripts
```
Note `scripts` in the search path and `--include="*.css"` in the filters: the first pass of this plan omitted both and missed four real references. Every hit must be one of the files listed above. A hit anywhere else means this task is incomplete; handle it before deleting. Re-run this grep after the deletions and expect zero output.
- [ ] **Step 2: Confirm production stores no copy of the block**
Already verified on 2026-08-15: pages hold `wp:pattern` references, and page 740 holds `chrnx/home-projects` plus `chrnx/journal-stream`, not `chrnx/selected-work`. Re-run the check before deleting:
```bash
WP_PASS=$(pass show personal/chrnx-dev | head -1)
WP_USER=$(pass show personal/chrnx-dev | sed -n 's/^user:[[:space:]]*//p' | head -1)
curl -s -u "$WP_USER:$WP_PASS" "https://chrnx.dev/wp-json/wp/v2/pages?per_page=50&context=edit&_fields=id,slug,content" \
| grep -c "chrnx/selected-work"
```
Expected: `0`. If it is not zero, stop and migrate that page's content first.
- [ ] **Step 3: Delete the block and the query**
```bash
git rm -r blocks/selected-work
```
Then remove `chrnx_get_selected_project_ids()` from `inc/queries.php` along with its docblock, and drop the tests covering it from `tests/php/EditorialQueriesTest.php`.
- [ ] **Step 4: Confirm the post meta registration is gone**
Task 2 replaced `inc/project-meta.php` wholesale, so the `register_post_meta()` call for `chrnx_project_featured` no longer exists. What survives is every CONSUMER of that meta, listed in this task's file map. Confirm with the grep from Step 1 that none remain.
- [ ] **Step 4b: Run the JavaScript suite**
Deleting an editor script and its test file changes the JS surface, which the PHP suite does not cover.
Run: `npm run test:js && npm run lint:js`
Expected: PASS, with one fewer suite than before.
- [ ] **Step 5: Run the full local suite**
Run: `npm test`
Expected: PASS across smoke, lint, phpcs, php, js, and e2e.
- [ ] **Step 6: Commit**
```bash
git add -A
git commit -m "refactor: drop the featured-project picker in favour of the project list"
```
---
### Task 9: Production migration
**Files:** none in the repository. This task mutates production content and runs only after the author confirms the mapping.
**Interfaces:**
- Consumes: taxonomy `chrnx_project` and its terms, live after the theme ZIP is uploaded.
- [ ] **Step 1: Get the mapping from the author**
Do not infer it. Ask for the project term and the corrected topic for each of these six posts:
| ID | Title | Topic today |
|---|---|---|
| 730 | I Built a Framework on Express. Then I Had to Rebuild It From Scratch. | code |
| 838 | req.user no existe, tú nomás rezas | projects |
| 695 | What's New in Expressive Tea 2.0: The Full Breakdown | code |
| 692 | Expressive Tea 2.0 Is Here | projects |
| 678 | Ailed: A Chess Engine That Feels | projects |
| 716 | Processing 1M Chess Games in 15 Seconds with Rust | code |
Note that Expressive Tea is a separate project from Green Tea, so it likely needs a third term that Task 1 does not seed.
- [ ] **Step 2: Release and upload the theme**
Bump `style.css`, `functions.php`, and all `blocks/*/block.json` to the new version together, then:
```bash
npm run package
```
The author uploads `dist/chrnx-<version>.zip` through Appearance then Themes. Do not attempt to deploy.
- [ ] **Step 3: Fill in each project's term meta**
Through the term edit screen or REST, set status, repository, package, and site for `green-tea`, `ailed`, and any term added in Step 1. Values come from the author.
- [ ] **Step 4: Assign project terms and correct topics**
Apply the Step 1 mapping through REST, one post at a time, verifying each response before moving on.
- [ ] **Step 5: Repoint page 740**
Replace the page content with a single pattern reference:
```text
<!-- wp:pattern {"slug":"chrnx/projects-landing"} /-->
```
This drops the `chrnx/journal-stream {"topic":"projects"}` block, which breaks once the `projects` topic is retired.
- [ ] **Step 6: Retire the projects topic term**
Only after Step 4 shows every post rehomed. Delete the `projects` term from `chrnx_topic` and remove it from the seeded definitions in `inc/taxonomies.php` and `tests/php/TaxonomiesTest.php`.
- [ ] **Step 7: Verify production**
```bash
for u in / /projects/ /project/green-tea/ /project/ailed/ /topic/code/; do
printf "%-4s %s\n" "$(curl -sL -o /dev/null -w '%{http_code}' "https://chrnx.dev$u")" "$u"
done
```
Expected: `200` on every route. Then confirm each project page lists its posts, and that no route leaks a PHP notice.
- [ ] **Step 8: Regenerate the critical CSS**
After the theme upload, never before. The author regenerates Jetpack Boost's critical CSS from the plugin settings.
---
## Self-review
**Spec coverage.** Content model is Tasks 1 and 2. The generic package field is Task 2. Cover fallback is Tasks 3 and 4. Retiring the featured picker is Task 8. The landing and its copy are Task 7. Project and show archives are Task 6. Migration and the retirement of the `projects` topic are Task 9.
**Open item carried into execution.** Task 4 Step 5 and Task 2 Step 4 both depend on how `inc/release-meta.php` dispatches term-edit hooks and resolves platform icons. Both steps read the file first and adapt. These are the only places where the release code may not generalise without a small change, and both are flagged rather than assumed.
**Naming consistency.** `chrnx_get_project_link_slots()`, `chrnx_get_project_meta_definitions()`, and `chrnx_get_project_links()` are defined in Task 2 and used under those exact names in Tasks 4 and 5. Meta keys are `chrnx_project_cover`, `chrnx_project_status`, `chrnx_project_repo`, `chrnx_project_package`, `chrnx_project_site` throughout. CSS classes use the `chrnx-project-` prefix throughout.