E10 Report issue template + E12 /report archive, to spec

PHASE 0 — the spec, read not recalled. E10: "Hybrid: dark billboard header
that survives every client, light paper body Gmail can't wreck. 600px,
stacked, no webfont dependence." Content law: "One email per slate day.
Top read, what changed, the record. Nothing else." E12: "EVERY ISSUE SHOWS
ITS OWN DAY RECORD -- THE ARCHIVE IS A LEDGER TOO."

COMPOSED, NOT FORKED. The audit had E10 as PARTIAL, not absent:
newsletterService already builds the daily report's CONTENT and lints its
voice. What was missing is the designed hybrid SHELL, so reportTemplate.js
is a template over that builder rather than a second report -- the same
call made for the movement strip, and for the same reason.

PHASE 1 — the hybrid shell is an ENGINEERING constraint, not a look, and
the tests say so: Gmail strips style blocks, Outlook ignores flexbox, and
a dark body renders as a black rectangle in several clients. Hence tables,
inline styles, 600px fixed, system fonts, no image required to read, and
the green SHIFTS from #00D4A0 to #00A57D on paper because the dark-mode
green is unreadable there.

FACT-CONTRACTED: a section whose data is absent is OMITTED and NAMED in
`omitted`, never filled. There is no code path producing a placeholder
figure. The honesty block carries the real numbers -- graded count,
cleared-ceiling count, the realized rate against baseline, and that we do
not issue A grades.

E1'S LAW TRAVELS EVEN THOUGH ITS RENDERING CANNOT. An SVG strip is not
reliable in email, so movementText carries the RULE: green only when the
move favours the read, and a flat market says FLAT · [N]D rather than
showing nothing.

NO DESIGNER SAMPLE DATA. Nabers 1,120.5, No 128, DAY RECORD 9-4 are a spec
for what a live issue renders; pasting them in would be fabrication
carrying a designer's authority and would look entirely correct. Tested.

PHASE 2 — /report is now the real archive, REPLACING the S41 redirect to
/blog. That redirect existed because the surface did not; E12 built it, so
the placeholder is correctly gone and the S41 test is updated rather than
worked around. Every row carries its own day record, and an unknown record
says UNSETTLED -- never a dash that reads as zero. Empty archive is an
honest state.

Backend: public read-only /api/report over Redis issues, plus the Next
proxy. Both surfaces registered under the reachability guard.

A test bug I made twice now: my check for forbidden sample values matched
the template's own doc block, which NAMES those values as things never to
paste. Documentation worth keeping, so both suites strip comments before
matching -- a guard that reads its own warning is not reading the code.

WAVE-2 STATUS: E1, F9-F11, E10, E12 done. Still gated -- F5 article media
and E16/F8 on the card-system reconciliation; the in-season hub IA on the
social chat's formula; E9/E15 on model; E2/E6 on licensing.

Read-only throughout; serving fingerprint unchanged including
newsletterService; accrual clock unchanged at 0 eligible dates.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1sivYNqY2TS5ftykmHBU9
This commit is contained in:
Kev
2026-08-07 22:17:59 -04:00
parent 49e76068da
commit 71d3b7b786
10 changed files with 501 additions and 7 deletions
+3
View File
@@ -204,6 +204,9 @@ app.use('/api/content', contentRoutes);
// Session S7 (a1) — THE VYNDR REPORT: public double-opt-in subscribe
// (forwards to the self-hosted Listmonk; graceful no-op without env).
app.use('/api/newsletter', require('./routes/newsletter'));
// E12 — The Report archive. Public, read-only; every issue carries its own
// day record, because the archive is a ledger too.
app.use('/api/report', require('./routes/report'));
// A1 S9 — Slip Reader: OCR a bet-slip screenshot into legs (auth +
// per-tier daily quota inside the router). Values are user-slip values.
app.use('/api/slips', require('./routes/slips'));
+55
View File
@@ -0,0 +1,55 @@
'use strict';
/**
* /api/report — E12, the issue archive.
*
* The spec's law is one line: **"EVERY ISSUE SHOWS ITS OWN DAY RECORD — THE
* ARCHIVE IS A LEDGER TOO."** So an archive row is not a headline with a date;
* it carries the record that issue's reads actually produced. An archive that
* showed only titles would be a blog, and the point of this one is that it
* cannot quietly bury a bad day.
*
* Public and READ-ONLY. Issues live in Redis under `report:issue:{date}`,
* written by the send path; nothing here touches a serving, model or ledger
* table.
*/
const express = require('express');
const router = express.Router();
const INDEX_KEY = 'report:index';
const ISSUE_KEY = (d) => `report:issue:${d}`;
/** GET /api/report — the archive list, newest first. */
router.get('/', async (req, res) => {
try {
const { cacheGet } = require('../utils/redis');
const index = (await cacheGet(INDEX_KEY)) || [];
const issues = Array.isArray(index) ? index : [];
const limit = Math.min(200, Math.max(1, Number(req.query.limit) || 60));
res.set('Cache-Control', 'public, max-age=300');
res.json({
count: issues.length,
// Honest empty state is the caller's to render; we simply report zero.
issues: issues.slice(0, limit),
});
} catch (e) {
res.status(500).json({ error: e.message });
}
});
/** GET /api/report/:date — one issue. 404 rather than an invented shell. */
router.get('/:date', async (req, res) => {
try {
const { cacheGet } = require('../utils/redis');
const issue = await cacheGet(ISSUE_KEY(req.params.date));
if (!issue) return res.status(404).json({ error: 'no issue for that date' });
res.set('Cache-Control', 'public, max-age=300');
return res.json(issue);
} catch (e) {
return res.status(500).json({ error: e.message });
}
});
module.exports = router;
module.exports.__internals = { INDEX_KEY, ISSUE_KEY };
+169
View File
@@ -0,0 +1,169 @@
'use strict';
/**
* E10 — THE VYNDR REPORT, the designed issue template.
*
* The gap audit had this as PARTIAL, not absent: `newsletterService` already
* builds the daily report's CONTENT and lints its voice. What was missing is the
* designed HYBRID SHELL. So this is a template over that builder, not a second
* report — the same compose-don't-fork call made for the movement strip.
*
* ── THE SPEC'S STRUCTURAL LAW ────────────────────────────────────────────
* "Hybrid: dark billboard header that survives every client, light paper body
* Gmail can't wreck. 600px, stacked, no webfont dependence."
*
* That is an engineering constraint, not a look. Gmail strips `<style>` blocks,
* Outlook ignores flexbox, and a dark body renders as a black rectangle in
* several clients. Hence: tables, inline styles only, 600px fixed, system-font
* stacks, and no image required to read the issue.
*
* Its content law is equally short: *"One email per slate day. Top read, what
* changed, the record. Nothing else."*
*
* ── FACT-CONTRACTED ──────────────────────────────────────────────────────
* Same discipline as the content engine: a section whose data is absent is
* OMITTED, never filled. There is no code path producing a placeholder figure,
* and the designer's sample values (Nabers 1,120.5, Nº 128, 9-4) are a spec for
* what a live issue renders — never content to paste.
*/
const { knownNumber } = require('../../utils/known');
/** Design tokens, inlined because email clients drop stylesheets. */
const T = Object.freeze({
billboard: '#06060B', // dark header — survives every client
paper: '#F7F6F2', // light body — Gmail cannot wreck it
ink: '#1A1A22',
greenOnDark: '#00D4A0',
greenOnPaper: '#00A57D', // the green SHIFTS on paper for contrast
rule: '#D8D5CC',
dim: '#6B6B76',
mono: "'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace",
sans: "-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif",
});
const WIDTH = 600;
const esc = (s) => String(s == null ? '' : s)
.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
/** Present means renderable. Zero is present; empty and null are not. */
const has = (v) => v !== null && v !== undefined && !(typeof v === 'string' && v.trim() === '')
&& !(Array.isArray(v) && v.length === 0) && !(typeof v === 'number' && !Number.isFinite(v));
/**
* The movement line — E1's law expressed in email-safe text.
*
* A `<canvas>` or SVG strip cannot be relied on in email, so the primitive's
* RULE travels even though its rendering cannot: green only when the move
* favours the read, and a flat market says FLAT rather than showing nothing.
*/
function movementText(m) {
if (!m || !has(m.from) || !has(m.to)) return null;
const from = knownNumber(m.from);
const to = knownNumber(m.to);
if (from === null || to === null) return null;
if (from === to) return { text: `FLAT${has(m.days) ? ` · ${m.days}D` : ''}`, colour: T.dim };
const favours = m.dir === 'toward';
return {
text: `${from} → ${to}`,
colour: favours ? T.greenOnPaper : '#B0762A', // amber-on-paper for against
};
}
const row = (inner) => `<tr><td style="padding:0 28px;">${inner}</td></tr>`;
/**
* @param {object} issue
* number, date_label, read_time
* top_read { grade, subject, line_text, movement:{from,to,dir,days}, model, best_book, note }
* changed [{ time, tag, text }]
* record { line, hit, miss, pct|null, note|null }
* honesty { graded, cleared_ceiling, ceiling_letter, ceiling_realized, base_rate, unissuable }
* @returns {object} { html, text, omitted[] } — omitted names what had no data.
*/
function renderIssue(issue = {}) {
const omitted = [];
const parts = [];
// ── DARK BILLBOARD HEADER ──
parts.push(`<tr><td style="background:${T.billboard};padding:26px 28px;">
<div style="font-family:${T.mono};font-size:20px;font-weight:800;letter-spacing:2px;color:#FFFFFF;">VYND<span style="color:${T.greenOnDark};">R</span></div>
<div style="font-family:${T.mono};font-size:11px;letter-spacing:2px;color:#8A8A96;padding-top:8px;">
THE REPORT${has(issue.number) ? ` &middot; N&ordm; ${esc(issue.number)}` : ''}${has(issue.date_label) ? ` &middot; ${esc(issue.date_label)}` : ''}${has(issue.read_time) ? ` &middot; READ TIME ${esc(issue.read_time)}` : ''}
</div></td></tr>`);
// ── TOP READ OF THE DAY ──
const tr = issue.top_read;
if (tr && has(tr.subject) && has(tr.grade)) {
const mv = movementText(tr.movement);
parts.push(row(`<div style="padding:22px 0 0;">
<div style="font-family:${T.mono};font-size:10px;letter-spacing:2px;color:${T.dim};">TOP READ OF THE DAY</div>
<div style="font-family:${T.sans};font-size:19px;font-weight:700;color:${T.ink};padding-top:10px;">
<span style="font-family:${T.mono};color:${T.greenOnPaper};font-weight:800;">${esc(tr.grade)}</span>
&nbsp;${esc(tr.subject)}${has(tr.line_text) ? ` <span style="font-weight:400;">${esc(tr.line_text)}</span>` : ''}
</div>
${mv || has(tr.model) || has(tr.best_book) ? `<div style="font-family:${T.mono};font-size:12px;color:${T.dim};padding-top:8px;">
${mv ? `<span style="color:${mv.colour};font-weight:700;">${esc(mv.text)}</span>` : ''}
${has(tr.model) ? ` &middot; VYNDR ${esc(tr.model)}` : ''}
${has(tr.best_book) ? ` &middot; BEST: ${esc(tr.best_book)}` : ''}
</div>` : ''}
${has(tr.note) ? `<p style="font-family:${T.sans};font-size:14px;line-height:1.6;color:${T.ink};padding-top:12px;margin:0;">${esc(tr.note)}</p>` : ''}
</div>`));
} else omitted.push('top_read');
// ── WHAT CHANGED ──
if (Array.isArray(issue.changed) && issue.changed.length) {
const rows = issue.changed.map((c) => `<div style="padding:7px 0;border-top:1px solid ${T.rule};">
<span style="font-family:${T.mono};font-size:11px;color:${T.dim};">${esc(c.time)}</span>
<span style="font-family:${T.mono};font-size:11px;font-weight:800;color:${T.ink};">&nbsp;${esc(String(c.tag).toUpperCase())}</span>
<span style="font-family:${T.sans};font-size:13px;color:${T.ink};">&nbsp;${esc(c.text)}</span></div>`).join('');
parts.push(row(`<div style="padding:26px 0 0;">
<div style="font-family:${T.mono};font-size:10px;letter-spacing:2px;color:${T.dim};padding-bottom:6px;">WHAT CHANGED</div>${rows}</div>`));
} else omitted.push('changed');
// ── THE RECORD ── (dark band: survives every client, per spec)
const rec = issue.record;
if (rec && has(rec.line)) {
parts.push(`<tr><td style="background:${T.billboard};padding:18px 28px;margin-top:20px;">
<div style="font-family:${T.mono};font-size:10px;letter-spacing:2px;color:#8A8A96;">THE RECORD</div>
<div style="font-family:${T.mono};font-size:16px;font-weight:800;color:#FFFFFF;padding-top:6px;">${esc(rec.line)}</div>
${has(rec.note) ? `<div style="font-family:${T.mono};font-size:11px;color:#8A8A96;padding-top:6px;">${esc(rec.note)}</div>` : ''}
</td></tr>`);
} else omitted.push('record');
// ── THE HONESTY BLOCK ── real figures or nothing.
const h = issue.honesty;
if (h && has(h.graded) && has(h.ceiling_letter)) {
parts.push(row(`<div style="padding:22px 0 0;">
<div style="font-family:${T.mono};font-size:10px;letter-spacing:2px;color:${T.dim};">HONESTLY</div>
<p style="font-family:${T.sans};font-size:13px;line-height:1.65;color:${T.ink};padding-top:8px;margin:0;">
We graded ${esc(h.graded)} props${has(h.cleared_ceiling) ? ` and ${esc(h.cleared_ceiling)} cleared ${esc(h.ceiling_letter)}` : ''}.
${has(h.ceiling_realized) && has(h.base_rate) ? `Those reads land about ${esc(h.ceiling_realized)}% against a ${esc(h.base_rate)}% baseline. ` : ''}
${has(h.unissuable) ? `We do not issue ${esc(h.unissuable)} — no band of this model has hit at a rate that would justify one.` : ''}
</p></div>`));
} else omitted.push('honesty');
const html = `<!doctype html><html><body style="margin:0;padding:0;background:${T.paper};">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:${T.paper};">
<tr><td align="center">
<table role="presentation" width="${WIDTH}" cellpadding="0" cellspacing="0" style="width:${WIDTH}px;max-width:${WIDTH}px;background:${T.paper};">
${parts.join('\n')}
<tr><td style="padding:22px 28px 30px;">
<div style="font-family:${T.mono};font-size:10px;color:${T.dim};line-height:1.7;">
One email per slate day. Top read, what changed, the record. Nothing else.<br>
No outcome is promised. 21+. <a href="{{ UnsubscribeURL }}" style="color:${T.dim};">Unsubscribe</a>.
</div></td></tr>
</table></td></tr></table></body></html>`;
const text = [
`THE REPORT${has(issue.number) ? ` No ${issue.number}` : ''}${has(issue.date_label) ? ` — ${issue.date_label}` : ''}`,
tr && has(tr.subject) ? `\nTOP READ: ${tr.grade} ${tr.subject}${has(tr.line_text) ? ` ${tr.line_text}` : ''}` : '',
tr && has(tr.note) ? tr.note : '',
rec && has(rec.line) ? `\nRECORD: ${rec.line}` : '',
'\nOne email per slate day. Top read, what changed, the record. Nothing else.',
].filter(Boolean).join('\n');
return { html, text, omitted, width: WIDTH };
}
module.exports = { renderIssue, movementText, T, WIDTH, has };