feat(linkedin-studio): SB-S3c — cross-silo id-threading + post→analytics assembler [skip-docs]
Hub-side design: the published record now carries the specifics/trends ids it was built from (additive, omit-empty → byte-backward-compatible), and a new pure assembler (scripts/brain/src/assemble.ts + `brain assemble`) joins post↔analytics by normalized title-prefix + date with honest confidence tiers (high/low/none). Answers the arc's north-star query: which raw material actually performs? (specific → post → measured analytics). All four tributaries untouched (analytics READ-only via inlined raw-JSON, no package import); profile.md grammar untouched (the fact→post link stays OUT — C-1). The repeatable --specific/--trend ingest flags collect via a new collectRepeated helper, leaving parseFlags untouched. TDD: 19 new brain tests (ingest 4 + publish 3 + assemble 8 + cli 4), all SC1–SC12. brain 113/113, gate 95/0/0, BRAIN_TESTS_FLOOR 94→113, ASSERT_BASELINE_FLOOR unchanged at 80. Light-Voyage hardened (brief-review 5 FIX · plan-critic 1 BLOCK+4 MAJOR+4 MINOR · scope-guardian ALIGNED). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RigJBiRFNtFZKCz21qNbQ4
This commit is contained in:
parent
016d823f3b
commit
edd3e15ef7
12 changed files with 515 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, test, beforeEach, afterEach } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdtempSync, rmSync, existsSync, writeFileSync } from "node:fs";
|
||||
import { mkdtempSync, rmSync, existsSync, writeFileSync, readFileSync, readdirSync, mkdirSync } from "node:fs";
|
||||
import { join, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { tmpdir } from "node:os";
|
||||
|
|
@ -75,4 +75,58 @@ describe("brain CLI dispatch (SB-S1)", () => {
|
|||
const { code } = runCli(root, ["bogus"]);
|
||||
assert.equal(code, 2);
|
||||
});
|
||||
|
||||
// SC5 — repeatable producer flags collect into arrays.
|
||||
test("SC5: `ingest --specific a --specific c --trend b` tags the record [a,c]/[b]", () => {
|
||||
const f = join(root, "post.md");
|
||||
writeFileSync(f, "A tagged published post body.", "utf8");
|
||||
const { stdout, code } = runCli(root, [
|
||||
"ingest", "--file", f,
|
||||
"--specific", "aaaaaaaaaaaa", "--specific", "cccccccccccc", "--trend", "bbbbbbbbbbbb",
|
||||
]);
|
||||
assert.equal(code, 0);
|
||||
const idMatch = stdout.match(/published\/([0-9a-f]{12})\.md/);
|
||||
assert.ok(idMatch, "wrote a record");
|
||||
const recText = readFileSync(join(root, "ingest", "published", `${idMatch![1]}.md`), "utf8");
|
||||
assert.match(recText, /specifics: aaaaaaaaaaaa,cccccccccccc/);
|
||||
assert.match(recText, /trends: bbbbbbbbbbbb/);
|
||||
});
|
||||
|
||||
// SC12 — single-value flags unregressed by the repeatable-flag change.
|
||||
test("SC12: single-value `--source` + boolean `--scan-inbox` still parse as today", () => {
|
||||
const f = join(root, "p.md");
|
||||
writeFileSync(f, "single-flag body", "utf8");
|
||||
runCli(root, ["ingest", "--file", f, "--source", "connector-x"]);
|
||||
const recDir = join(root, "ingest", "published");
|
||||
const recFile = readFileSync(join(recDir, readdirSync(recDir)[0]), "utf8");
|
||||
assert.match(recFile, /source: connector-x/);
|
||||
const { code } = runCli(root, ["ingest", "--scan-inbox"]);
|
||||
assert.equal(code, 0);
|
||||
});
|
||||
|
||||
// SC9 — read-only `assemble` prints the join and writes nothing.
|
||||
test("SC9: `assemble` joins post↔analytics and writes nothing", () => {
|
||||
const f = join(root, "post.md");
|
||||
const body = "Jeg lærte noe viktig om dømmekraft i dag. Del 1.";
|
||||
writeFileSync(f, body, "utf8");
|
||||
runCli(root, ["ingest", "--file", f, "--date", "2026-05-26", "--specific", "aaaaaaaaaaaa"]);
|
||||
// Seed an analytics batch JSON (raw shape; assemble inlines the read).
|
||||
const postsDir = join(root, "analytics", "posts");
|
||||
mkdirSync(postsDir, { recursive: true });
|
||||
writeFileSync(
|
||||
join(postsDir, "2026-05-26-batch.json"),
|
||||
JSON.stringify({ posts: [{ title: "Jeg lærte noe viktig om dømmekraft i dag.", publishedDate: "2026-05-26", metrics: { engagementRate: 5.1 } }] }),
|
||||
"utf8",
|
||||
);
|
||||
const { stdout, code } = runCli(root, ["assemble"]);
|
||||
assert.equal(code, 0);
|
||||
assert.match(stdout, /aaaaaaaaaaaa/, "surfaces the specific id");
|
||||
assert.match(stdout, /high/i, "shows the high-confidence analytics match");
|
||||
assert.ok(!existsSync(join(root, "brain", "profile.md")), "assemble wrote no profile.md");
|
||||
});
|
||||
|
||||
test("SC9: `assemble` on an empty root degrades cleanly (no crash)", () => {
|
||||
const { code } = runCli(root, ["assemble"]);
|
||||
assert.equal(code, 0);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue