feat(linkedin-studio): brain emits OKF-compatible form — Stage 1 (bundle=brain/, ingest/ excluded) [skip-docs]

Cross-plugin OKF convergence, Stage 1 (docs/okf-convergence-brief.md): the
second-brain hub now conforms to OKF-compatible form so a shared retrieval
skill (and a sibling agent) can traverse it.

- serializeProfile leads with a constant `type: Profile` frontmatter block
  (round-trip-safe: parseProfile skips it, parse-serialize identity holds).
- operations.md seed -> `type: Operations`; index.md seed -> `okf_version: 0.1`
  marker (markdown text; index files carry no frontmatter per OKF); new
  brain/journal/index.md (per-level index).

Premise correction: the brain is deliberately YAML-free and ingest/published
has a byte-exact round-trip invariant (SC2) a frontmatter block would break,
so the concept-bundle is scoped to brain/ ONLY; the ingest/ tributary is
excluded and pointed to from the hub. We emit frontmatter, add no parser.

Verified: new tests/okf-conform.test.ts (5/5); full brain suite 132/132 (0
regressions); cross-tool — okr/scripts/okf-check.mjs validates brain/ (exit 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011vmzxpsFpc8q19LaogAWLD
This commit is contained in:
Kjell Tore Guttormsen 2026-06-26 20:52:41 +02:00
commit 9e95222d12
3 changed files with 129 additions and 2 deletions

View file

@ -36,9 +36,18 @@ function serializeFact(f: ProfileFact): string {
return f.value === "" ? `- [${bracket}]` : `- [${bracket}] ${f.value}`;
}
/** Deterministic full-document serialization; both sections always present. */
/**
* Deterministic full-document serialization; both sections always present. A
* constant OKF frontmatter block (`type: Profile`) leads the document so the brain
* bundle is OKF-compatible form (docs/okf-convergence-brief.md); it carries no
* typed-doc data, so `parseProfile` skips it and `parse ∘ serialize` stays identity.
*/
export function serializeProfile(doc: ProfileDoc): string {
const lines: string[] = [
"---",
"type: Profile",
"---",
"",
"# Profile",
"",
`schemaVersion: ${doc.schemaVersion}`,

View file

@ -35,6 +35,8 @@ function indexSeed(): string {
> Map of Content one screen pointing at every tributary, with a freshness flag.
> Generated by \`brain init\`; safe to hand-edit (a re-run never clobbers it).
okf_version: 0.1
| Tributary | What it holds | Freshness |
|-----------|---------------|-----------|
| voice-samples | writing style | |
@ -50,7 +52,10 @@ function indexSeed(): string {
}
function operationsSeed(): string {
return `# Operations
return `---
type: Operations
---
# Operations
> The operations centre where you're headed now, what you're working on, what you might
> do next. User-authored: the brain motor never writes here (a re-run of init never
@ -74,6 +79,15 @@ _As of YYYY-MM-DD:_ <one or two sentences on your current direction — replace
`;
}
function journalIndexSeed(): string {
return `# Journal — episodic log
> Append-only session entries (\`YYYY-MM-session.md\`). Raw, never edited — the
> source the consolidation loop distils from. One concept per file. A reserved
> OKF index (no frontmatter); the entries carry the \`type\`.
`;
}
function profileSeed(): string {
const templateText = readFileSync(TEMPLATE_PATH, "utf8");
const instancePath = dataRoot(INSTANCE_SUB);
@ -111,6 +125,7 @@ export function initBrain(): InitResult {
{ sub: "brain/profile.md", seed: profileSeed },
{ sub: "brain/index.md", seed: indexSeed },
{ sub: "brain/operations.md", seed: operationsSeed },
{ sub: "brain/journal/index.md", seed: journalIndexSeed },
];
for (const { sub, seed } of files) {