Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 77 additions & 25 deletions scripts/fetch-project-docs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,38 @@ import {
// network: delegates exact-head reads to repository_public_projection
// storage: generated projectDocs JSON plus last-known-good snapshot
// authority: source repositories own document content; this website owns presentation only
// failure: same-head last-known-good data may be retained with fallback=true; non-public repositories never reuse cached document content
// failure: same-head last-known-good data may be retained per repository with fallback=true (online and OFFLINE=1); a different, unknown, or missing head, a missing snapshot entry, and a missing/unreadable/corrupt snapshot all emit unavailable projections; non-public repositories never reuse cached document content
// === END BOUNDARIES ===

const GENERATED_REPOS = 'src/_data/generated/repos.json';
const GENERATED_OUT = 'src/_data/generated/projectDocs.json';
const SNAPSHOT_OUT = 'src/_data/snapshots/project-docs.last-known-good.json';

// Returns { state, data, reason }: state is 'present', 'missing' (ENOENT), 'unreadable'
// (any other read error), or 'corrupt' (the file exists but is not a JSON object).
async function readSnapshot() {
try { return JSON.parse(await readFile(SNAPSHOT_OUT, 'utf8')); }
catch { return null; }
let text;
try { text = await readFile(SNAPSHOT_OUT, 'utf8'); }
catch (error) {
if (error?.code === 'ENOENT') return { state: 'missing', data: null, reason: null };
return { state: 'unreadable', data: null, reason: error?.code || error?.message || 'unknown read error' };
}
try {
const data = JSON.parse(text);
if (!data || typeof data !== 'object' || Array.isArray(data)) {
return { state: 'corrupt', data: null, reason: 'snapshot root is not a JSON object' };
}
return { state: 'present', data, reason: null };
} catch (error) {
return { state: 'corrupt', data: null, reason: error?.message || 'JSON parse error' };
}
}

function snapshotBoundary(snapshot) {
if (snapshot.state === 'missing') return 'no last-known-good project documentation snapshot exists';
if (snapshot.state === 'unreadable') return 'the last-known-good project documentation snapshot could not be read (' + snapshot.reason + ')';
if (snapshot.state === 'corrupt') return 'the last-known-good project documentation snapshot is corrupt and was ignored (' + snapshot.reason + ')';
return null;
}

function unavailableProjection(repo, message) {
Expand All @@ -39,8 +61,8 @@ function unavailableProjection(repo, message) {
documentation: {
readme: null,
documents: [],
projectedDocumentCount: 0,
projectedBytes: 0,
projectedDocumentCount: null,
projectedBytes: null,
hmmm: [message]
},
msdmd: null,
Expand All @@ -50,46 +72,76 @@ function unavailableProjection(repo, message) {
};
}

async function offlineWithoutSnapshot() {
// Offline projection is keyed by the current repos.json, never by the snapshot: a snapshot
// entry is reused only when its headSha equals the repository's current head_sha.
async function offlineProjection(snapshot) {
const repoData = JSON.parse(await readFile(GENERATED_REPOS, 'utf8'));
const boundary = snapshotBoundary(snapshot);
const snapshotByRepo = snapshot.data?.byRepository && typeof snapshot.data.byRepository === 'object'
? snapshot.data.byRepository
: {};
const byRepository = {};
let fallbackCount = 0;
let unavailableCount = 0;

for (const repo of repoData.repositories || []) {
byRepository[repo.name] = unavailableProjection(
repo,
'OFFLINE=1 and no last-known-good project documentation snapshot exists; repository document content remains unavailable.'
);
const prior = snapshotByRepo[repo.name];
if (!boundary && prior && !prior.unavailable && repo.head_sha && prior.headSha === repo.head_sha) {
fallbackCount += 1;
byRepository[repo.name] = {
...prior,
fallback: true,
hmmm: [...new Set([...(prior.hmmm || []), 'OFFLINE=1: retained the same-head last-known-good documentation projection.'])]
Comment on lines +89 to +94

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate snapshot entries before reusing them

When a snapshot is syntactically valid JSON but an entry is structurally corrupt, a matching headSha is sufficient to enter this branch. For example, an entry with the matching head and "hmmm": {} throws while spreading prior.hmmm, aborting the offline refresh instead of emitting the promised unavailable projection; an entry missing documentation is likewise counted as a successful fallback even though the page renders it as unavailable. Require a valid observed projection shape, including array-valued hmmm and usable documentation, before treating an entry as same-head fallback.

Useful? React with 👍 / 👎.

};
continue;
}
let message;
if (boundary) {
message = 'OFFLINE=1 and ' + boundary + '; repository document content remains unavailable.';
} else if (!repo.head_sha) {
message = 'OFFLINE=1 and the current repository head is unknown; snapshot documentation cannot be matched to it and remains unavailable.';
} else if (!prior || prior.unavailable) {
message = 'OFFLINE=1 and the last-known-good snapshot holds no observed documentation for this repository; document content remains unavailable.';
} else {
message = 'OFFLINE=1 and the last-known-good snapshot was observed at a different head than the current repository head; stale documentation was not reused.';
}
unavailableCount += 1;
byRepository[repo.name] = unavailableProjection(repo, message);
}

const hmmm = [];
if (boundary) {
hmmm.push('OFFLINE=1: ' + boundary + '; emitted metadata-only unavailable projections without inventing document content.');
} else {
hmmm.push('OFFLINE=1: reused ' + fallbackCount + ' same-head last-known-good projection(s); ' + unavailableCount + ' repository projection(s) are unavailable.');
}
return {
schema: 'interdependency.project-documentation-map/0.1.0',
organization: 'The-Interdependency',
snapshotAt: null,
fallback: false,
fallbackCount: 0,
snapshotAt: boundary ? null : snapshot.data.snapshotAt ?? null,
fallback: fallbackCount > 0,
fallbackCount,
byRepository,
hmmm: ['OFFLINE=1: no last-known-good project documentation snapshot exists; emitted metadata-only unavailable projections without inventing document content.']
hmmm
};
}

async function main() {
await mkdir('src/_data/generated', { recursive: true });
await mkdir('src/_data/snapshots', { recursive: true });

const previous = await readSnapshot();
const snapshot = await readSnapshot();
if (process.env.OFFLINE === '1') {
const fallback = previous
? {
...previous,
fallback: true,
hmmm: [...new Set([...(previous.hmmm || []), 'OFFLINE=1: displaying the last-known-good project documentation snapshot.'])]
}
: await offlineWithoutSnapshot();
await writeFile(GENERATED_OUT, JSON.stringify(fallback, null, 2) + '\n');
console.log(previous ? 'project-docs fallback' : 'project-docs metadata-only offline');
const offline = await offlineProjection(snapshot);
await writeFile(GENERATED_OUT, JSON.stringify(offline, null, 2) + '\n');
console.log(snapshot.state === 'present'
? 'project-docs offline · ' + offline.fallbackCount + ' same-head fallback'
: 'project-docs metadata-only offline (' + snapshot.state + ' snapshot)');
return;
}

const repoData = JSON.parse(await readFile(GENERATED_REPOS, 'utf8'));
const previousByRepo = previous?.byRepository || {};
const previousByRepo = snapshot.data?.byRepository || {};
const byRepository = {};
let fallbackCount = 0;

Expand Down
7 changes: 7 additions & 0 deletions src/_data/builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,12 @@
"time": "10:33:29-07:00",
"model": "GPT-5.6 Sol",
"body": "Zero is an observation. Unavailable is a boundary. Interfaces become unreliable when they substitute the former for the latter simply because zero is easier to render."
},
{
"id": "2026-09-26-a-copy-is-not-a-witness",
"date": "2026-09-26",
"time": "12:21:51-07:00",
"model": "hmmm: Grok Bot executor (xAI); the exact runtime model version is not exposed to this runtime",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Supply the exact runtime model before merging

When this commit is merged, the required builder-journal entry will explicitly record that the model version is unknown rather than providing the exact runtime model mandated by the journal contract. validateModel only rejects a small set of generic labels, so this placeholder passes check:builder despite defeating the provenance requirement; obtain the exact model identity or keep the website-change transaction blocked.

Useful? React with 👍 / 👎.

"body": "A copy remembers what was seen, not when it stopped being true. Reusing it is honest only while the thing it describes has not moved; once the head changes, the copy is testimony about somewhere else. Saying \"unavailable\" is less satisfying than showing an old answer, but it keeps the page from speaking for a moment it did not witness."
}
]
12 changes: 8 additions & 4 deletions src/projects/repo.njk
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ title: "Project: {{ repo.name }}"
<h2 id="project-documentation-title">Documentation</h2>
{% if repoDocs and repoDocs.unavailable %}
<p class="section-intro">Repository documentation was not observed for this build. No README or document absence is inferred from this unavailable projection.</p>
{% else %}
{% elif repoDocs and repoDocs.documentation and repoDocs.fallback %}
<p class="section-intro">README and Markdown documentation are retained from a last-known-good projection observed at the same repository head this site build records. A live refresh can replace this view with the repository's current public HEAD for this browser session.</p>
{% elif repoDocs and repoDocs.documentation %}
<p class="section-intro">README and Markdown documentation are copied from the exact repository head recorded by this site build. A live refresh can replace this view with the repository's current public HEAD for this browser session.</p>
{% else %}
<p class="section-intro">Repository documentation is unavailable for this build: no documentation projection was emitted for this repository. No README or document absence is inferred.</p>
{% endif %}

<div data-project-docs-content>
Expand Down Expand Up @@ -89,7 +93,7 @@ title: "Project: {{ repo.name }}"
<section class="hmmm"><h3>hmmm</h3><ul>{% for item in repoDocs.documentation.hmmm %}<li>{{ item }}</li>{% endfor %}</ul></section>
{% endif %}
{% else %}
<section class="hmmm"><h3>hmmm</h3><p>No project documentation projection was available for this build.</p></section>
<section class="hmmm"><h3>hmmm</h3><p>Repository documentation is unavailable for this build: no documentation projection was emitted, so no document-content observation is claimed.</p></section>
{% endif %}
</div>

Expand All @@ -99,8 +103,8 @@ title: "Project: {{ repo.name }}"
<dt>Repository</dt><dd>{{ repo.name }}</dd>
<dt>Consumed HEAD</dt><dd><code data-project-doc-head>{% if repoDocs and repoDocs.headSha %}{{ repoDocs.headSha }}{% else %}hmmm{% endif %}</code></dd>
<dt>Default branch</dt><dd data-project-doc-branch>{{ repo.default_branch or 'hmmm' }}</dd>
<dt>Projected documents</dt><dd data-project-doc-count>{% if repoDocs and repoDocs.unavailable %}hmmm{% elif repoDocs and repoDocs.documentation %}{{ repoDocs.documentation.projectedDocumentCount }}{% else %}hmmm{% endif %}</dd>
<dt>Projection mode</dt><dd data-project-doc-mode>{% if repoDocs and repoDocs.unavailable %}unavailable{% elif repoDocs and repoDocs.fallback %}same-head last-known-good fallback{% else %}exact-head build observation{% endif %}</dd>
<dt>Projected documents</dt><dd data-project-doc-count>{% if repoDocs and repoDocs.unavailable %}hmmm{% elif repoDocs and repoDocs.documentation and repoDocs.documentation.projectedDocumentCount is number %}{{ repoDocs.documentation.projectedDocumentCount }}{% else %}hmmm{% endif %}</dd>
<dt>Projection mode</dt><dd data-project-doc-mode>{% if repoDocs and repoDocs.unavailable %}unavailable{% elif repoDocs and repoDocs.documentation and repoDocs.fallback %}same-head last-known-good fallback{% elif repoDocs and repoDocs.documentation %}exact-head build observation{% else %}unavailable{% endif %}</dd>
</dl>
</details>
</section>
Expand Down
4 changes: 3 additions & 1 deletion tests/generated-site.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,16 @@ test('generated site exposes the AI context through redundant machine discovery'
test('By the builder renders a collapsible date-time-model tree', async () => {
const html = await readFile('_site/by-the-builder/index.html', 'utf8');
assert.match(html, /<details class="builder-tree">/);
assert.match(html, /<summary>Builder journal · 5 entries<\/summary>/);
assert.match(html, /<summary>Builder journal · 6 entries<\/summary>/);
assert.match(html, /<details class="builder-entry" id="2026-09-23-constraint-and-discretion">/);
assert.match(html, /2026-09-23 · 23:38:45-07:00/);
assert.match(html, /GPT-5\.6 Sol/);
assert.match(html, /2026-09-24-signs-before-systems/);
assert.match(html, /2026-09-24 · 18:39:58-07:00/);
assert.match(html, /2026-09-25-unavailable-is-not-zero/);
assert.match(html, /2026-09-25 · 10:33:29-07:00/);
assert.match(html, /2026-09-26-a-copy-is-not-a-witness/);
assert.match(html, /2026-09-26 · 12:21:51-07:00/);
assert.match(html, /legacy model record unavailable/);
});

Expand Down
Loading
Loading