docs: design and plan projects as first-class entities

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-15 13:55:37 -05:00
1 parent 9fed24c09a
commit 5e1fcf0315
2 files changed
+1052

No files matched your search

@@ -0,0 +1,933 @@
# 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**
`chrnx_project_edit_form_fields` must be dispatched the way `chrnx_show_edit_form_fields` is. Check `inc/release-meta.php` for the `{$taxonomy}_edit_form_fields` dispatcher and confirm it covers `chrnx_project`; if it enumerates taxonomies explicitly, add `chrnx_project` to that list.
- [ ] **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`
- Test: `tests/php/ProjectBlocksTest.php` (create)
**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 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' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</article>
<?php endforeach; ?>
</div>
```
- [ ] **Step 5: Confirm the icon lookup**
`chrnx_get_platform_links_markup()` resolves icons by slot key. Read its definition in `inc/release-meta.php` and confirm it accepts the project slots (`repo`, `package`, `site`). If it looks icons up from `chrnx_get_release_platforms()`, extend it to take an explicit slot-definition array and pass `chrnx_get_project_link_slots()`.
- [ ] **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`
- Test: `tests/php/ProjectBlocksTest.php` (extend)
**Interfaces:**
- Consumes: `chrnx_get_project_links()`, `chrnx_get_topic_portrait_markup()`.
- Produces: block `chrnx/project-detail`, consumed by `templates/taxonomy-chrnx_project.html`.
- [ ] **Step 1: Read the release equivalent**
Run: `cat blocks/release-detail/render.php`
The project version renders the same shape: cover, status, description, links. Copy its structure exactly rather than inventing a new one.
- [ ] **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' );
$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 );
}
```
- [ ] **Step 3: Run the test to verify it fails**
Run: `npm run test:php`
Expected: FAIL, block not registered.
- [ ] **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 and links for the queried project."`, and no `headingLevel` attribute.
`blocks/project-detail/render.php` follows `blocks/release-detail/render.php` line for line, substituting `chrnx_release` with `chrnx_project`, `chrnx_get_release_links` with `chrnx_get_project_links`, `chrnx_release_cover` with `chrnx_project_cover`, `chrnx_release_status` with `chrnx_project_status`, `placeholder-release` with `placeholder-project`, and the `chrnx-release-` class prefix with `chrnx-project-`.
- [ ] **Step 5: Run the tests to verify they pass**
Run: `npm run test:php && npm run phpcs`
Expected: PASS.
- [ ] **Step 6: Commit**
```bash
git add blocks/project-detail tests/php/ProjectBlocksTest.php
git commit -m "feat: give each project its own page header"
```
---
### 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 /-->
</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:**
- Delete: `blocks/selected-work/`
- Modify: `inc/queries.php` (remove `chrnx_get_selected_project_ids()`, around line 274)
- Modify: `inc/blocks.php` if it names the block explicitly
- Modify: `tests/php/EditorialQueriesTest.php`
**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" \
--include="*.php" --include="*.js" --include="*.json" --include="*.html" --include="*.mjs" \
inc blocks patterns templates assets tests
```
Every hit must be one of the files listed above. A hit anywhere else means this task is incomplete; handle it before deleting.
- [ ] **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: Remove the post meta registration**
The `chrnx_project_featured` registration is already gone, because Task 2 replaced the whole file. Confirm with the grep from Step 1.
- [ ] **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.
@@ -0,0 +1,119 @@
# CHRNX Projects as First-Class Entities — Design
<!-- markdownlint-disable MD013 -->
**Status:** Approved 2026-08-15
**Supersedes:** the `projects` topic term as a grouping mechanism
## Problem
`projects` is a topic term, so it cannot separate the thing from the writing about it.
Green Tea is a project with a repository, a published package, and a release status.
The posts about Green Tea are a different kind of object. Today both collapse into one
term, and the term cannot hold a repository URL or a cover.
That collapse already produced an inconsistency. Announcement posts landed in
`projects` while deep dives on the same product landed in `code`:
| Product | Announcement | Deep dive |
|---|---|---|
| Expressive Tea | 692 (`projects`) | 695 (`code`) |
| Ailed | 678 (`projects`) | 716 (`code`) |
| Green Tea | 838 (`projects`) | 730 (`code`) |
A reader browsing Green Tea finds half its material. The split exists only because one
term was doing two jobs.
Music and podcasts already solved this. `chrnx_release` is the album, `chrnx_show` is the
programme, and posts reference them. Projects never got the same treatment.
## Solution
Promote projects to an entity taxonomy modelled on `chrnx_release`, and return `code`
to being a general topic about writing code.
### Content model
New taxonomy `chrnx_project`, registered through the existing
`chrnx_register_editorial_taxonomy` contract with `rest_base` `project`.
Seeded terms: `green-tea` (Green Tea), `ailed` (Ailed).
Term meta, mirroring `chrnx_release`:
| Meta key | Type | Sanitizer | Purpose |
|---|---|---|---|
| `chrnx_project_cover` | integer | `absint` | Attachment ID for the project cover |
| `chrnx_project_status` | string | `sanitize_text_field` | Free text, e.g. `Beta`, `Activo`, `Archivado` |
| `chrnx_project_repo` | string | `chrnx_sanitize_https_url` | Source repository |
| `chrnx_project_site` | string | `chrnx_sanitize_https_url` | Documentation or product site |
| `chrnx_project_package` | string | `chrnx_sanitize_https_url` | Where the package lives |
`chrnx_project_package` is deliberately one generic URL rather than an npm-specific
field. Green Tea publishes to npm, a Rust project would publish to crates.io, a Python
one to PyPI. One URL covers all three; a per-registry field list would need editing
every time a new language shows up.
Cover falls back to shared placeholder art when unset, exactly as
`chrnx_release_cover` falls back to `placeholder-release`.
### Retired
`chrnx_project_featured` (post meta), `chrnx_get_selected_project_ids()`, and the
`chrnx/selected-work` block are removed.
Music proves they are unnecessary. `music-landing` lists every release through
`chrnx/release-list` with no notion of a featured release, and `home-music` carries no
list at all. With two or three projects, picking a favourite is ceremony, not curation.
The `projects` topic term is retired. Posts that carried it move to `code`, and grouping
moves to their project term.
### Surfaces
| Surface | Today | After |
|---|---|---|
| `/projects/` page (740) | `chrnx/home-projects` pattern + `journal-stream {"topic":"projects"}` | `chrnx/projects-landing` pattern |
| Project archive | none | `templates/taxonomy-chrnx_project.html` |
| Home section | `chrnx/selected-work` inside `home-projects` | banner copy only, mirroring `home-music` |
The landing gets a character-stage banner in the established three-layer shape
(atmosphere, content, art), followed by `chrnx/project-list`.
Landing copy, in the author's voice:
> **Proyectos**
> Aquí va lo que mi cerebro tira en formato de código.
> 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.
### Debt repaid alongside
`chrnx_show` has no `taxonomy-chrnx_show.html` and falls through to the generic archive,
so a podcast programme page never renders its own detail block. Adding
`templates/taxonomy-chrnx_show.html` alongside the project template closes that gap
while the same shape is fresh.
## Migration
Pages store pattern references rather than expanded markup, so theme changes propagate
without touching stored content. Verified on production:
```text
740 /projects/ <!-- wp:pattern {"slug":"chrnx/home-projects"} /-->
<!-- wp:chrnx/journal-stream {"topic":"projects"} /-->
743 /music/ <!-- wp:pattern {"slug":"chrnx/music-landing"} /-->
```
One stored block breaks: `journal-stream {"topic":"projects"}` on page 740, because its
topic disappears. Page 740 becomes a single `chrnx/projects-landing` pattern reference.
Six published posts need project terms assigned and their topic corrected. The exact
post-to-project mapping is supplied by the author, not inferred.
## Non-goals
- No custom post type. Projects are terms, like releases and shows.
- No per-registry package fields.
- No project-level prose page beyond the term description.
- No changes to `chrnx_release`, `chrnx_show`, Related Stories, or theme preference.