// Shared, read-only briefing renderer. Never interpret project Markdown as HTML. (() => { const text = (value) => String(value ?? '').slice(0, 1200).replace(/[&<>"']/g, (character) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', })[character]); const count = (value) => Number.isInteger(value) && value >= 0 ? value : null; function list(title, section, describe) { const items = Array.isArray(section?.items) ? section.items.slice(0, 100) : []; let body; if (section?.available !== true) body = '

Evidence unavailable.

'; else if (!items.length) body = '

No matching recorded items.

'; else body = ``; const total = count(section?.count); if (section?.truncated || (total !== null && total > items.length)) body += `

Showing ${items.length} of ${total ?? 'an unknown total'}.

`; return `

${title}

${body}
`; } function render(publication, { now = new Date() } = {}) { const report = publication?.report; if (report?.schema !== 'torch.dev/owner-digest/v1alpha1' || !Number.isFinite(Date.parse(report.generatedAt))) { return '

No published briefing

Generate a local report with torch digest build. To save it for this view, the owner can review and run torch digest publish --by owner --yes.

Publication does not send a message, deploy work or install a timer.

'; } const elapsed = now.getTime() - Date.parse(report.generatedAt); const hours = Number.isFinite(report.window?.hours) && report.window.hours > 0 ? report.window.hours : 24; const freshness = elapsed < -300_000 ? 'Check publication clock' : elapsed > hours * 2 * 3_600_000 ? 'Older publication' : 'Saved publication'; const deployment = report.lastDeployment; const states = { unknown: 'Outcome unknown', running: 'Execution unresolved', failed: 'Failed', succeeded: 'Success reported; local reconciliation pending', applied: 'Receipt applied; live verification separate', 'reviewed-not-applied': 'Owner confirmed no deployment' }; return `

${freshness}

Window: ${text(report.window?.since)} to ${text(report.window?.until)} (UTC). Recorded evidence, not independent live verification.

This briefing stays as published. Approvals and work may have changed since then.

${report.activityCoverage?.complete === false ? '

Activity history is incomplete; inactivity is not proven.

' : ''}
${list('Needs you', report.needsOwner, (item) => `${text(item.title)}${text(item.requester)} · ${text(item.id)}`)} ${list('Delivery needs review', report.deliveryReview, (item) => `${text(item.operation)}: ${text(states[item.state] ?? item.state)}${text(item.commit)}`)}

Review current approvals and session waits

Last deployment

${deployment ? `

${text(deployment.label)} — ${text(states[deployment.state] ?? deployment.state)}

${text(deployment.commit)}${deployment.failureReason ? `

${text(deployment.failureReason)}

` : ''}` : '

No deployment operation recorded.

'}
Shipping and integration ${list('Shipped — receipt reported', report.shipped, (item) => `${text(item.label ?? item.deliveryId)}${text(item.state)} · ${text(item.recordedAt)}${text(item.commit)}`)} ${list('Landed — not necessarily deployed', report.landed, (item) => `${text(item.sourceArea)}${text(item.commit)}`)} ${list('Completed tasks', report.completed, (item) => `${text(item.title)}${text(item.taskId)}`)}
Decisions, blockers and neglected requests ${list('Recorded approval decisions', report.decisions, (item) => `${text(item.title)}${text(item.status)} · ${text(item.decidedBy)}`)} ${list('Blocked work', report.blocked, (item) => `${text(item.taskId)}${text(item.reason)}`)} ${list('Neglected owner requests', report.neglectedRequests, (item) => `${text(item.title)}${text(item.taskId)} · ${text(item.ageDays)} days${item.expectedWaiting ? ' · recorded blocked wait' : ''}`)}
Evidence coverage
`; } globalThis.TorchOwnerDigest = Object.freeze({ render }); })();