# Theme architecture review, 2026-11-30

> Dependency and state ownership in the Hugo module, with reproducible checks and the disposition of each refactoring candidate.

---

LLMS index: [llms.txt](/llms.txt)

---

## Scope and method {#method}

The theme baseline was `15217bf` and the documentation baseline was `25e679d`.
The review used paired worktrees. It traced template calls, Page Store access,
script assembly and Python imports, then compared fresh builds and exercised
the public command-line entry points. Hugo 0.170.1, Go 1.27.4, Python 3.14.8
and Node 26.13.0 were installed. The site tests used npm 12.2.2.

## Dependency and ownership map {#map}

In the candidate theme, `python3 bin/check-architecture.py --json` lists the
literal partial calls and Page Store reads and writes for each layout. It also
lists dynamic calls and external targets for review. The ordinary command
checks for cycles between distinct templates connected by literal calls.
At this snapshot the scan covers 437 layout files, 446 template nodes and
1,139 literal internal edges. Nineteen templates recurse directly. Six
templates choose a partial dynamically. The scanner records possible names
where it sees literal assignments. Hugo resolves `block "main"`, site overrides
and runtime data. The literal scan found 38 Store keys with both a reader and
a writer. The checker rejects an ambiguous cross-file named-template call and lists its competing definitions. Computed keys, such as per-component IDs, require their owning
feature checks.

| Change | Implementation and flow | Verification |
| --- | --- | --- |
| Site policy and page overrides | Hugo merges site configuration and cascades. `hugo.yaml` supplies defaults. The feature resolver interprets values from `ui-param.html`. Editor schemas project those inputs. | `check-params.py`, schema generator in check mode |
| Reading surfaces | Hugo selects the base layout by kind, type and output. Its sidebar drawer assembles the panel, backdrop and launcher. The article topline combines the resolved breadcrumb with the caller's actions. Blog owns its feed and index action. | `check-shell.py`, Book, Expo and browser navigation checks |
| Authoring and output | Shortcodes and Goldmark hooks pass content through the `content/` partials. HTML, Print, RSS, Markdown and machine indexes have distinct rendering and link contracts. Book owns reading order, target IDs and manifest output. | Components, Book, agent-index and golden checks |
| Landing and Expo | Landing resolves an ordered section registry and localized data before dispatch. Expo reads album bundles. Article galleries share layout geometry with Expo and retain their own controls and preferences. | Landing, Expo and gallery checks |
| Styles and translations | `css/layers.html` orders the CSS. `css/bundle.html` builds named bundles. Presets supply palettes. Locale catalogs supply labels. `VENDOR.json` identifies distributed assets. | Stylesheet, preset, font, i18n and vendor checks |
| Browser interaction | Actions read the embedded manifest. The surface coordinator manages dismissal and focus. Capability chunks load from `scripts.html` after content rendering. Search, comparison, diagrams and media own their respective asynchronous operations. | Runtime isolation, Node units and site Playwright suites |
| Contributor tools | Checkers build synthetic fixtures. Publication reads a finished site. Migration scans Markdown and reports unsupported input. Consumer maintenance selects external repositories. | CI theme and publication jobs, migration and consumer tests |

For parallel changes, the unit of ownership is a feature resolver, output
partial, CSS layer or browser module. The corresponding fixture exercises the
public entry point. Coordinate changes that touch the ordered chunk list in `scripts.html` or the stylesheet cascade in `css/layers.html`. The docs site owns
cross-feature browser checks. A Python AST inventory of the 80 Python files in `bin/` found 104 ordinary internal import relationships and no import cycle after the migration changes. String-based plugin loading is covered by the transformation registry tests. The separate Go CLI owns site inspection and
maintenance workflows. Theme builds run with Hugo alone.

## State, caches and failure boundaries {#state}

- The output entry point sets `tdOutputFormat`. Render hooks and shortcodes
  register capabilities and component IDs for that page. `scripts.html` reads
  the capabilities. Book aggregate Print additionally scopes heading and
  cross-reference state to its render.
- Hugo caches language-specific and deployment-specific resources using the
  owning partial's cache key. A sidebar can cache a neutral tree and let its
  browser controller restore the active path. Reader preferences remain
  browser-local. Appearance owns preset choice, dark mode owns color choice,
  and history owns its site-scoped list. The head reads selected preferences
  before paint.
- A failed search-body request leaves the index usable and allows another
  request. A failed comparison pane offers its own retry and direct link.
  Third-party engines have component-specific fallbacks. Offline generation,
  configured network endpoints and explicit publication are separate trust
  boundaries. Authentication and HTTP cache headers belong to the host or
  external service. The theme has no account database or server request log.
- CI reviews Hugo diagnostics alongside output. The synthetic fixture runner
  bounds each build. Go module selection, deployment credentials and
  publication executables are toolchain inputs. Site content does not select
  them.

## Refactoring ledger {#ledger}

These entries describe the 30 November candidate. The [patch review](#patch-review) revised the script boundaries.

| Candidate | Finding and disposition |
| --- | --- |
| Keyboard and dark-mode configuration | Two invalid values warned and then stopped Hugo at a bare `nil` assignment. Ten keyboard readers now use one policy. Tests require a successful build, diagnostics and the actual script, hint, history and color-mode output. |
| Shell composition | Seven bases assembled the same sidebar drawer. Four assembled the same article topline. The narrow partials preserve the base files and the previous panel, launcher, breadcrumb and title-menu override points. Two Book snapshots record the shared component's whitespace. |
| Script selection | Core and action bundles now share the existing classic-script publisher. Development and production probes compared script order, URLs, integrity attributes and file bytes before changing any chunk members. |
| Global shortcuts | Keyboard and Palette shared a text-input predicate by copying it. Keyboard, Palette and the lazy comparison reader now ship one input policy through their existing chunks. Open shadow-root text inputs keep typed characters. A focused slider or radio allows the comparison shortcut. |
| Fixture dependencies | Six checker entry points share ordinary navigation and action fixture modules. Five dynamic checker-to-checker imports and their untyped module parameters were removed. Four checkers also moved their Hugo builds to the existing timeout owner. |
| Publication | PDF and EPUB use the same manifest envelope and local resource resolver. EPUB requires per-page identifiers for chapter links. PDF can render a whole-Book Print document without reading those identifiers. |
| Migration | Gallery and FileTree share marker discovery, row scanning, diagnostic locations and bottom-up traversal. The two transformations still interpret images and nested tree rows separately. |
| Migration command dependencies | `report.py` imported scan functions from `cli.py`, which in turn imported the report. All three commands now read the file selection from `oink06/site.py`. The importer test loads report generation without loading command dispatch. The normal JSON, Markdown, diagnostics and exit codes were compared across the change. |
| Migration file selection | Selecting one non-Markdown file explicitly previously bypassed the directory suffix filter. Directory and file selections now share the accepted extensions and site boundary, and overlapping roots process a source once. |
| Page Store | The Mermaid hook uses the same explicit Page Store access as other diagram hooks. The blog form switch uses its rendered control and shell runtime. Its write-only capability flag was removed. |

## Verification {#verification}

The theme worktree closed at `8a2a2b0`. All 49 local steps from the CI
`scripts` and `build` jobs passed. Focused reruns on the final source passed
seven architecture tests, 153 JavaScript units, 102 migration tests and 64
output goldens. The migration review additionally exercised 14 files through
the CLI, including nested marked lists and CRLF input. A second write changed
zero files.

The configuration review reproduced the original build failures. A site override
probe checked evaluation order across Docs, Book, Swagger and Blog. A second
probe exercised a maintained consumer's title menu. The drawer kept its seven
lookup paths and the two intentional Book snapshot changes are whitespace only.

Hugo built the Book fixture at the root, under `/subpath/` and under the encoded
prefix `/%E4%B9%A6/`. Each EPUB contained five content chapters and 31 numbered
targets. EPUBCheck 5.4.0 reported zero warnings and errors. Chrome 158 produced
a 23-page PDF at each prefix and Poppler found all five titles. Inputs without
chapter IDs remained valid for PDF. Six publication input and isolation tests
ran with Chrome enabled. Pandoc was 3.13.

The full sibling-site browser suite passed 691 tests during development. With
the layout and shortcut changes fixed, another 240 tests passed across
accessibility, responsive shells, keyboard navigation and document comparison.
The accessibility run included the English and Chinese versions of the
research, architecture, shell and migration pages. The ordinary sibling build
and development preview passed. A separate production build used the published
pin with workspaces and replacements disabled.

## Patch review, 1 December {#patch-review}

Because the `pgsty.com` portal assembles its own Command Palette bundle and its
corporate pages publish keyboard navigation separately, both entries inline
their input-target guard so they keep full focus handling when loaded on their
own. Core and action scripts also remain direct synchronous tags rather than
passing through `script-resource.html`, so sites that defer optional chunks can
still call `OinkSidebar.ready` from `hooks/body-end.html`. Explicit `null` page
overrides on `keyboard_nav` now emit the same non-boolean warning instead of
silently overriding a site-level `false`.

The migration fixtures verify which list Goldmark binds a marker to, which
source lines the CLI replaces, and how `--paths` resolves project content mounts
and language directories across both root config files and `config/_default/`
directories while keeping theme imports disabled. The EPUB fixture places two
distinct images at `literal%20code.png` and `literal code.png` and verifies the
embedded bytes for each link. Deployment checks cover ordinary subpaths, spaces,
and Unicode text; a literal `#` or `%20` inside a deployment prefix also affects
the links Hugo writes into Print HTML and would require a separate end-to-end
change.

## Remaining decisions {#remaining}

| Candidate | Reason to retain the current boundary | Reopen when |
| --- | --- | --- |
| Book artifact and manifest pairing | The publication job builds the manifest and book together. The artifact checkers can accept an older book after chapters are reordered. | A workflow needs to verify independently delivered artifacts against a manifest. |
| Base-template lookup and Print overrides | A consumer can override one content type, one output format or a type-specific Print partial. | A proposed lookup change includes consumer override fixtures and migration scope. |
| CSS layer boundaries and locale files | Cascade order and 32 native catalogs are part of the rendering and authoring contract. | A measured styling defect or missing translation identifies an owning layer or catalog. |
| Runtime retry and storage interfaces | Search indexes, comparison frames, color preferences and session layout state have different lifetimes and recovery behavior. | Two callers need the same state transitions, invalidation and fallback. |
| Dynamic template edges | Landing accepts a site-owned section partial. Print discovers overrides by type. Sidebar dispatch chooses a tree according to data. | A new built-in dispatch family needs a dedicated fixture. Site-specific code needs a consumer checkout. |

The dependency map can be regenerated after any change. The ledger describes
this local candidate. The release and consumer workflows have their own gates.

---

Backlinks:

- [Configuration](/docs/design/decisions/configuration/)
- [Research](/docs/design/research/)
