Skip to content

feat(distill): synthesize rolling-PR articles instead of appending raw learnings - #332

Merged
jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/distill-synthesize
Dec 1, 2026
Merged

jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/distill-synthesize

Conversation

@jflowers

@jflowers jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Closes #328. Refs #295.

Why

Spec 018 FR-012 called for "regenerated compiled articles", but rolling_pr never synthesized anything. Since 7fe5976 it has pasted every learning in as a raw ## <id> section, and since #297 it has appended those sections to existing articles. The 2026-12-01 hub run produced:

  • an issue-triage PR with 363 raw sections (about 400 KB);
  • a fail-fast article that contradicted itself.

Those PRs could not be meaningfully reviewed, and all 32 of them have been closed unmerged.

What changes

  • Synthesis. rolling_pr synthesizes each theme's article with the server's synthesis provider, the same one compile uses. The prompt holds the existing body plus the new learnings, both tagged as data. The model revises the whole body, puts unresolved contradictions in ## Open Conflicts, and cites learning identities inline.
  • Verification.
    • Every bracketed citation must resolve to a learning the article may cite.
    • At least one new learning must be cited.
    • Uncited new learnings are held for a later run.
    • Dewey builds the frontmatter (compiled_at, compiled_by: dewey-distill-auto, synthesis_model, and sources as a superset of the base's), so a prior citation can't be lost.
  • Cap. distill.max_new_per_theme (default 40) limits how many new learnings one run synthesizes into a theme. The rest stay uncited, so they stay in scope for the next run. dewey doctor shows the value.
  • SC-004 is scope-based. If no new, sanitization-clean member is left uncited, there is no synthesis call, no commit, and no body edit.
  • Failure handling.
    • A theme whose synthesis fails is reported skipped with a reason; nothing is written or pushed, and the run continues.
    • A real run with no available synthesizer refuses before recording anything. A dry run still previews without one.
  • PR body. It now shows the synthesizing model, open conflicts first, held learnings, and supersession proposals. The cited total counts every source.
  • Removed. RenderDraftArticle and RenderThemeArticle. Spec 018 FR-012 and SC-004 are amended, with an OpenSpec change in openspec/changes/distill-synthesize-articles/.

Notes for review

  • Breaking for unattended runs without synthesis configured. rolling_pr now errors instead of opening raw-append PRs. The hub vault has no synthesis: config yet.
  • I didn't build the .pending.md sidecar fallback from feat(distill): synthesize rolling_pr articles instead of appending raw learnings #328. On a vault without synthesis it would produce one PR of raw learnings per theme again. design.md D5 explains this.
  • Tests. Existing rolling-PR tests run against a deterministic test synthesizer. New tests cover:
    • composition: a new theme, a revised article, nothing new, the cap, sanitization, failures, and output handling;
    • a skipped theme;
    • refusal without a synthesizer;
    • the config.
  • Checks. go vet, go test -race ./... and gofmt are clean. golangci-lint reports only two staticcheck notes in artifacts/, which were already on main.

🤖 Generated with Claude Code

…w learnings

rolling_pr now writes each theme's article with the server's synthesis
provider: the prompt carries the existing article body and the theme's
new learnings (tagged as data), and the model revises the whole body,
surfacing unresolved contradictions in an Open Conflicts section and
citing learning identities inline.

Output is verified before it is written: every bracketed citation must
resolve to a learning the article may cite, at least one new learning
must be cited, and uncited new learnings are held for a later run.
Dewey builds the frontmatter (compiled_at, compiled_by, synthesis_model,
sources as a superset of the base's).

distill.max_new_per_theme (default 40) caps each run; the rest stay in
scope. SC-004 becomes scope-based, so a run with nothing new makes no
synthesis call. A theme whose synthesis fails is skipped with a reason;
a real run without a synthesizer refuses up front. The PR body adds the
model, open conflicts first, held learnings and supersession proposals.

RenderDraftArticle and RenderThemeArticle are removed. Amends spec 018
FR-012 and SC-004.

Closes unbound-force#328
Refs unbound-force#295

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jflowers
jflowers enabled auto-merge (rebase) December 1, 2026 13:01
The gaze gate failed on this branch (CRAPload 50 > max 48): the branch
introduced two functions at or over the CRAP-15 floor — composeThemeArticle
(complexity 24) and Distill.RollingPR (complexity 14 -> 17 from the
synthesizer-availability guard). Decompose both without behavior change:

- composeThemeArticle delegates to citableIdentities, verifySynthesizedBody,
  composeFrontmatter, and verifySourcesSurvive (each complexity <= 8,
  fully covered by the existing tests);
- RollingPR delegates the synthesizer refusal to rollingSynthGuard and the
  run_id theme resolution to resolveRollingThemes (complexity 17 -> 13).

Local CI-parity run: go build/vet clean, go test -race -count=1 18/18
packages green, gaze crap 47/48 and 44/45 — both thresholds pass.
jflowers and others added 5 commits December 1, 2026 09:31
A learning that quotes "[71-75]" matches the legacy {tag}-{N} identity
shape, so the verifier refused correct articles as citing an unknown
learning. Real learning tags start with a letter; a token that doesn't
is prose. An unknown identity that starts with a letter is still
refused. Found by the synthesis benchmark on the hub, where it rejected
three models' change-management articles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenAI's GPT-5 and later models answer HTTP 400 to max_tokens and ask
for max_completion_tokens, so every openai-compatible synthesis call to
them failed (seen through EnMaaS on the hub). On that specific 400 the
synthesizer resends once with max_completion_tokens and keeps using it;
any other 400 is reported as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sx/distill-synthesize

# Conflicts:
#	tools/distill_synthesis.go
Base articles carry no inline citations, so "end every factual claim
with a citation" led models to attach new-learning ids to old facts
those learnings don't contain. The prompt now says carried-forward text
keeps exactly its existing citations, none if it has none. On the hub
benchmark a blind check found misattributed citations fell from 38 to 0
for gpt-6.2-sol and from 1 to 0 for gemini-4-neon on the determinism
and change-management themes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: REQUEST CHANGES

Verdict: REQUEST CHANGES

Six reviewers ran and all six succeeded (adversary at heavy profile, architect, curator, gaze-testing, guard, testing). Consolidation produced 11 findings, 10 distinct after merging a duplicate documentation finding: 1 HIGH, 3 MEDIUM, 6 LOW. No CRITICAL findings. CI is green on head fff8b4c.

What this PR does

rolling_pr now synthesizes each theme's article through the server's synthesis provider instead of appending every new learning as a raw ## <id> section. Selection stays deterministic: selectFreshLearnings never calls the model, so the SC-004 no-op check is scope-based. Verification closes the citation set: every bracketed identity must be citable, at least one fresh learning must be cited, uncited learnings are held, and a rewrite that would drop a previously cited source refuses. Dewey owns the frontmatter; the model never touches tier or sources. A theme whose synthesis fails is skipped with its reason and the run continues. Real runs without a synthesis provider now refuse up front. This closes the failure mode from the 2026-12-01 hub run: 363 raw sections in one PR, and an article contradicting itself.

The core looks well guarded. The findings below are mostly around the edges: documentation sync, test isolation at the new config read, and what the human-edit skip path reports.

Findings

HIGH

1. Website documentation sync issue missing (tools/distill_config.go:34)

The PR adds the user-facing config key distill.max_new_per_theme (default 40, bounds 1 to 10000) and makes real rolling_pr runs refuse without a synthesis provider, a breaking workflow change. New frontmatter fields (compiled_at, compiled_by, synthesis_model) and new PR body sections (Synthesized by, Open Conflicts, held learnings, proposed supersessions) also ship. AGENTS.md's Website Documentation Sync section requires a docs-labeled issue in unbound-force/website for this class of change, and nothing in the proposal, walkthrough, or tasks.md references one. Could the sync issue be filed before merge, covering the config key, the refusal behavior, and the new PR body surfaces?

MEDIUM

2. AGENTS.md calibration section lists three of four knobs (AGENTS.md)

The Distill grouping calibration section documents similarity_threshold, tie_margin, and min_theme_size, but not the new max_new_per_theme. That section is the operator reference for distill calibration, and dewey doctor now surfaces the fourth knob. Worth extending it (and any README distill table) so all four appear in one place?

3. XDG isolation incomplete at the new config read (tools/distill_run_test.go:61)

The rolling_pr handler now calls ReadDistillGroupingConfig on every invocation, so max_new_per_theme resolves from the machine's global config. Five handler tests isolate XDG_CONFIG_HOME, but the distill_run_test.go family (TestDistillRun_RoundTrip, TestDistillRun_CancelledRunRecordsFinishedThemes, TestDistillRun_CancelledRunIDRunRecordsFinishedThemes, TestDistillRun_DryRunByRunIDRecordsNothing, TestDistillRun_RefusedRunIsRecorded) crosses the same read with no isolation. A global distill.max_new_per_theme smaller than a fixture theme's member count changes what those tests synthesize and hold. This is the coupling class that produced six machine-only tools/distill failures for min_theme_size (learning/distill-20261130T213604), with CI green throughout. Would fixture-wide isolation (pinning a distill: section into the shared fixture vaults, or centralizing the Setenv in the rolling-PR fixture) close the gap without per-test remembering?

4. Human-edit skip path understates pending work (tools/rolling_pr.go:1301)

On the regeneration-guard skip path, writeThemeFiles composes composedArticle{Sources: sel.baseCited, Dropped: sel.dropped} with no Added and no Held, not even sel.held. The review-queue body for that theme reads "0 learnings synthesized into the article", where the pre-change code reported the pending learnings by name. The PR a human is actively editing is exactly the one where pending work matters most, and the structured result cannot distinguish "nothing pending" from "pending but human owns the file". TestManageRollingPRs_HumanEditNotOverwritten still asserts only that the edit survives, so the changed WhatChanged and Held behavior ships unverified against spec 018 FR-013. Could the skip path report sel.fresh and sel.held, with a test pinning the body?

LOW

5. Citation assertions are substring checks (tools/rolling_pr_test.go:754)

The migrated tests assert Contains(" [id]") rather than a well-formed bracketed citation in the article body. A stray occurrence in prose or PR metadata satisfies the check. Worth tightening to a citation-pattern match so FR-012's bracketed-identity contract is what the test pins?

6. Transport fix outside the change record (llm/openai_compatible.go:60)

llm/openai_compatible.go gains a sticky max_completion_tokens fallback for GPT-5-family providers. The proposal's seven change points do not mention it, and the OpenSpec delta does not allocate it. It directly enables synthesis across providers, so it belongs in the change record. Worth a line in the proposal's impact section so the diff and the description agree?

7. Content coverage not noted (openspec/changes/distill-synthesize-articles/proposal.md)

Synthesis changes what reviewers validate: citations, Open Conflicts, held learnings, rather than raw sections. The OpenSpec artifacts list functional impact but no tutorial or blog candidacy. Worth a content-coverage note in the proposal?

8. sanitizeMembers error path unpinned (tools/distill_synthesis.go:119)

sanitizeMembers calls sanitize.Scan statically, with no injection seam and no test for the internal-error branch. manageOneTheme converts only themeSynthesisError into a per-theme skip, so a plain error here aborts the entire run. Is run-fatal the intended boundary for internal sanitization failures? If so, a comment or test pinning that choice would keep a future refactor honest.

9. Flow-style sources fixture lost (tools/rolling_pr_existing_test.go:83)

Deleting TestRenderThemeArticle removed the only fixture with an inline flow-style sources list (sources: [old-id]). parseArticleSources still consumes that shape on every compose. Worth one compose test with a flow-style base so a parsing regression surfaces directly?

10. Three wiring arms uncovered (tools/distill_tools.go:526)

No test drives d.RollingPR through a written max_new_per_theme config; the min_theme_size analogue (TestDistillRun_MinThemeSizeDefersSmallNewThemes) does exactly this for its field. rollingSynthGuard's non-nil-but-unavailable arm is uncovered, and the doctor line max_new_per_theme=%d (%s) is unpinned. Worth closing the three gaps while the seams are fresh?

CI

Check State
CI OK SUCCESS (required status check)
build-and-test SUCCESS
MegaLinter SUCCESS
changes/Scope SUCCESS ×2
gitleaks SKIPPED (learnings-only chore PRs only)
automerge SKIPPED (human-gate label)

Verdict rationale

REQUEST CHANGES. One HIGH documentation finding (missing website sync issue for a breaking config and workflow change) and three MEDIUM findings (AGENTS.md knob coverage, test isolation at the new config read, human-edit skip path reporting) block approval. The synthesis core itself passed all six reviewers with no CRITICAL findings; the citation closed-set verification and Dewey-owned frontmatter are solid work.


Review dispatch: correlation 28c018e0-72bb-4ee9-85df-a51ae2d235c3, 6 runs (6 success, 0 failed), 11 findings, 3 lesson proposals. Artifact: .uf/artifacts/dispatch/28c018e0-72bb-4ee9-85df-a51ae2d235c3.json.

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed by the website sync issue, unbound-force/website#499. It covers the distill.max_new_per_theme config key, the no-synthesizer refusal for real runs, the new article frontmatter, and the new PR body sections. No code change was needed in this PR.

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #334: Tracking issue for extending the AGENTS.md distill calibration section and the README distill table with max_new_per_theme, so all four knobs appear in one place. Not changed in this PR (MEDIUM).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #335: Tracking issue for isolating the config read in the distill_run_test.go family, so a machine-level global distill: section cannot change what those tests synthesize and hold. Not changed in this PR (MEDIUM).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #336: Tracking issue for reporting fresh and held learnings on the regeneration-guard skip path, with a test pinning the review-queue body against spec 018 FR-013. Not changed in this PR (MEDIUM).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #337: Tracking issue for tightening the citation assertions to a well-formed bracketed-citation pattern, so FR-012's contract is what the tests pin. Not changed in this PR (LOW).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged, the proposal's impact section omits the llm/openai_compatible.go change. The sticky max_completion_tokens fallback directly enables synthesis across GPT-5-family providers, so it belongs in the change record. Noting it here rather than amending the proposal after review. Not changed in this PR (LOW).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged. Tutorial and blog candidacy for the synthesized-article review workflow belongs to the content pipeline, assessed separately from this change's functional record. Not changed in this PR (LOW).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Run-fatal is the intended boundary there. A sanitization failure signals a broken internal invariant, unlike a provider failure, which design D5 pins as skip-and-continue; the boundary itself is unpinned by test or comment. Not changed in this PR (LOW).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #338: Tracking issue for a compose test with a flow-style base sources list, restoring the coverage the TestRenderThemeArticle deletion lost. Not changed in this PR (LOW).

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #339: Tracking issue for the three uncovered wiring arms: a written max_new_per_theme config through d.RollingPR, the rollingSynthGuard non-nil-unavailable arm, and the doctor line. Not changed in this PR (LOW).

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: APPROVE (council: APPROVE WITH ADVISORIES)

This review supersedes the prior CHANGES_REQUESTED review on this head commit: its blocking HIGH finding — the missing website documentation sync issue — is resolved out-of-band by unbound-force/website#499, filed after that review on the same unchanged head.

Six reviewers ran and all six succeeded (adversary at heavy profile; architect, curator, gaze-testing, guard at standard; testing on the host model). Adversary, architect, and curator approve cleanly; gaze-testing, guard, and testing approve with advisories. Consolidation produced 8 findings — 1 MEDIUM, 7 LOW — with no CRITICAL and no HIGH findings. CI is green on head fff8b4c.

What this PR does

rolling_pr now synthesizes each theme's article through the server's synthesis provider instead of appending every new learning as a raw ## <id> section. Selection stays deterministic, so the SC-004 no-op check remains scope-based. Verification closes the citation set: every bracketed identity must be citable, at least one fresh learning must be cited, uncited learnings are held for a later run, and a rewrite that would drop a previously cited source refuses. Dewey owns the frontmatter; the model never touches tier or sources. A theme whose synthesis fails is skipped with its reason and the run continues, and real runs without a synthesis provider refuse up front. This closes the failure mode from the 2026-12-01 hub run: 363 raw sections in one PR, and an article contradicting itself.

Advisories (1 MEDIUM, 7 LOW → 6 inline)

  • MEDIUM — test isolation (tools/distill_run_test.go:59): four handler-level tests read the developer's real global config through the new ReadDistillGroupingConfig call; isolation is incidental, not enforced.
  • LOW — error-path coverage (tools/distill_synthesis.go): the sanitize.Scan error branch is untested and unpinned; it aborts the entire run — a deliberately different contract from per-theme synthesis skips.
  • LOW — change-record gap (llm/openai_compatible.go): the sticky max_completion_tokens fallback is not listed in the OpenSpec change's tasks or delta spec.
  • LOW — coverage gap (tools/distill_tools.go): rollingSynthGuard's non-nil-but-unavailable arm has no test; the llm.NoopSynthesizer{Avail: false} fixture exists.
  • LOW — assertion mapping (tools/distill_synthesis_test.go): the prompt-leak assertion checks one poison string; other drop categories would still pass.
  • LOW — latent race (tools/distill_synthesis_helpers_test.go): perThemeSynth/testSynth lack synchronization; safe while iteration stays sequential.
  • LOW — unpinned output (cli.go): the doctor test does not assert the new max_new_per_theme segment.

Prior-round findings not re-raised

The prior round's AGENTS.md calibration-section gap (three of four knobs documented) remains factually open — this PR's only AGENTS.md edit is the Recent Changes entry — and the human-edit skip-path reporting finding was not re-raised. Both work as follow-ups.

CI

Check State
CI OK SUCCESS (required status check)
build-and-test SUCCESS
MegaLinter SUCCESS
changes/Scope SUCCESS ×2
gitleaks SKIPPED
automerge SKIPPED

Verdict rationale

The synthesis core passed all six reviewers with no CRITICAL findings; the citation closed-set verification and Dewey-owned frontmatter are solid work. The MEDIUM test-isolation advisory is the one item worth fixing before or shortly after merge — the same machine-state coupling class previously produced CI-green/local-red failures. The remaining advisories are untested error branches and unpinned output surfaces, appropriate as follow-ups.

This review was generated by /uf.review-pr (AI-assisted).

Comment thread tools/distill_run_test.go
@@ -58,7 +58,7 @@ func scopeRunID(t *testing.T, d *Distill) string {
// the rolling_pr artifact records the run as complete.
func TestDistillRun_RoundTrip(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[MEDIUM — test isolation] Four handler-level tests in this family read the developer's real global config through the new ReadDistillGroupingConfig call in the rolling_pr handler (tools/distill_tools.go:526). TestDistillRun_RoundTrip, TestDistillRun_CancelledRunIDRunRecordsFinishedThemes, TestDistillRun_DryRunByRunIDRecordsNothing, and TestDistillRun_RefusedRunIsRecorded run without XDG_CONFIG_HOME isolation, while five sibling handler tests set it. The current assertions do not consume max_new_per_theme, so nothing fails today — but the isolation is incidental: a developer with a global distill.max_new_per_theme smaller than a fixture theme's member count changes what these tests synthesize and hold, and the next assertion someone adds becomes machine-dependent, passing on CI while failing locally. This is the same coupling class that produced six machine-only tools/distill failures for min_theme_size (learning/distill-20261130T213604). Pinning a distill: section into the shared fixture vaults, or centralizing the Setenv in the rolling-PR fixture, closes the gap without per-test remembering. (Go pack TC-004, default pack TC-002.)

// run, the new members held back by the per-run cap, and the members the
// sanitization gate dropped.
type themeSelection struct {
baseCited []string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW — error-path coverage] The sanitize.Scan error branch in sanitizeMembers has no test and no failure-injection seam. A scan error propagates as a plain error and aborts the entire run — a deliberately different contract from synthesis failures, where a themeSynthesisError skips one theme and the run continues (design D5, pinned by TestManageRollingPRs_SkippedThemeDoesNotStopTheRun). Neither the branch nor the fatal-vs-skip distinction for sanitize errors is pinned. Is run-fatal the intended boundary for internal sanitization failures? If so, a seam and a test pinning that choice keeps a future refactor honest. (Go pack TC-005.)

Comment thread llm/openai_compatible.go
@@ -59,13 +60,19 @@ type OpenAICompatibleSynthesizer struct {
// shorten them to exercise retry behavior without real waits.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW — change-record gap] This sticky max_completion_tokens fallback (new atomic.Bool field, extracted send() helper, rejectsMaxTokens body sniff) does not appear in openspec/changes/distill-synthesize-articles/tasks.md, the delta spec, or the proposal's impact list. It directly enables the synthesizer for OpenAI-compatible endpoints serving GPT-5-family models, so it belongs in the change record — a line in the proposal's impact section keeps the diff and the description in agreement.

Comment thread tools/distill_tools.go
// rollingSynthGuard refuses a real rolling_pr run that has no available
// synthesizer (#328): rolling PRs carry synthesized articles, so a run
// without one could only produce the raw-append PRs the design removed.
// A dry run previews without one. A nil result means the run may proceed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW — coverage gap] rollingSynthGuard's second arm — a non-nil synthesizer reporting Available() == false — has no test. The arm is reachable in production (the server constructs a provider whose endpoint probe fails) and produces a different refusal message than the nil arm, which is covered at both levels (TestDistillRollingPR_RefusesWithoutSynthesizer, TestManageRollingPRs_RequiresSynthesizer). The repo has an established fixture for exactly this case — llm.NoopSynthesizer{Avail: false}, cf. TestCompile_SynthesizerNotAvailable (tools/compile_test.go:1142) — so the arm is cheap to pin.

} {
if !strings.Contains(got.Content, want) {
t.Errorf("article missing %q:\n%s", want, got.Content)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW — assertion mapping] TestComposeThemeArticle_RevisesExistingArticle checks that dropped/poison learning bodies stay out of the prompt with a single poison-string assertion. The synthesis prompt is a P0 output that must not leak sanitization-dropped content (FR-013); a regression leaking a different drop category — empty-body or missing-text — still passes. Asserting every dropped member's text is absent pins the FR-013 contract the test names.

func fixedNow() time.Time { return time.Date(2026, 12, 1, 0, 0, 0, 0, time.UTC) }

// testSynth is a deterministic llm.Synthesizer for distill tests. By
// default it echoes the prompt's existing article and adds one cited

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW — latent race] perThemeSynth and testSynth embed testSynth without synchronization; recordingSynth correctly uses a sync.Mutex. ManageRollingPRs iterates themes sequentially today, so no race exists — but these helpers back tests asserting per-theme skipped-vs-created outcomes, and parallelizing iteration would make the shared out/err reads race and the tests flaky.

Comment thread cli.go
c.printCheck(w, "INFO", "distill grouping", fmt.Sprintf("similarity_threshold=%v (%s), tie_margin=%v (%s), min_theme_size=%d (%s), max_new_per_theme=%d (%s)",
cfg.SimilarityThreshold, cfg.SimilarityThresholdSource, cfg.TieMargin, cfg.TieMarginSource,
cfg.MinThemeSize, cfg.MinThemeSizeSource))
cfg.MinThemeSize, cfg.MinThemeSizeSource, cfg.MaxNewPerTheme, cfg.MaxNewPerThemeSource))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[LOW — unpinned output] printDistillGroupingChecks now appends max_new_per_theme=%d (%s) to the doctor's distill-grouping line — the user-facing half of task 2.2 — but the doctor test (cli_test.go:8941-8977) pins only the three prior fields. Because those assertions are substring-based, a regression dropping the new field passes every test. The config-resolution half is well covered (TestResolveDistillGroupingConfig_MaxNewPerTheme); only the rendered line needs an assertion.

@jflowers
jflowers merged commit 60775dd into unbound-force:main Dec 1, 2026
7 checks passed
jflowers added a commit to jflowers/dewey that referenced this pull request Dec 1, 2026
- Human-edit skip path: the review queue names the learnings left
  pending behind a human's edit ("human edit preserved, not
  synthesized; N learnings held") instead of "0 learnings synthesized",
  and the result counts them as held.
- Tests in tools never read the machine's global config: TestMain
  points XDG_CONFIG_HOME at an empty directory for the package.
- Citation assertions match a well-formed bracketed citation in the
  article body, not a substring anywhere in the file.
- New tests: a compose over a flow-style sources base; a configured
  max_new_per_theme reaching rolling_pr through the handler; refusal
  when a synthesizer is configured but unavailable; the doctor line.
- sanitizeMembers documents why a scanner error is run-fatal.
- AGENTS.md and README document max_new_per_theme beside the other
  calibration knobs; the proposal records the max_completion_tokens
  transport fix and content coverage (website sync: website#499).

Closes unbound-force#338
Closes unbound-force#339

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the council review in 5f0da2d:

  1. HIGH, website sync: already filed as docs: sync dewey distill synthesis documentation website#499. It covers max_new_per_theme, the refusal without a synthesis provider, the new frontmatter and the new PR body sections. The proposal now links it.
  2. MEDIUM, AGENTS.md knobs: the calibration section and the README's distill table now list max_new_per_theme beside the other three settings.
  3. MEDIUM, XDG isolation: the new tools/main_test.go points XDG_CONFIG_HOME at an empty directory for the whole package, so no test reads the machine's global config. A test that needs a global setting still sets its own with t.Setenv.
  4. MEDIUM, human-edit skip path: the review queue now reports "human edit preserved, not synthesized; N learnings held for a later run" and lists those learnings under Held for a later run. The result counts them as held. TestManageRollingPRs_HumanEditNotOverwritten checks the body and the count.
  5. LOW, citation assertions: a new citesInBody helper matches a well-formed [id] in the article body, with frontmatter excluded.
  6. LOW, transport fix: the proposal's Impact section records the max_completion_tokens fallback.
  7. LOW, content coverage: the proposal notes it as a candidate for a tutorial and a blog post.
  8. LOW, sanitize error boundary: a comment on sanitizeMembers records why a scanner error stops the run.
  9. LOW, flow-style sources: added TestComposeThemeArticle_FlowStyleSourcesBase (closes compose path lost its flow-style sources fixture #338).
  10. LOW, wiring arms: added TestDistillRun_MaxNewPerThemeConfigHoldsTheRest and TestDistillRollingPR_RefusesUnavailableSynthesizer, and the doctor test now checks the max_new_per_theme line (closes three distill_tools wiring arms uncovered #339).

go vet, gofmt and go test -race ./... pass locally.

🤖 Generated with Claude Code

@jflowers

jflowers commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Correction: this PR merged at fff8b4c before 5f0da2d was pushed, so the review fixes listed above aren't in main. They're in #341, cherry-picked onto current main.

jflowers added a commit that referenced this pull request Dec 1, 2026
- Human-edit skip path: the review queue names the learnings left
  pending behind a human's edit ("human edit preserved, not
  synthesized; N learnings held") instead of "0 learnings synthesized",
  and the result counts them as held.
- Tests in tools never read the machine's global config: TestMain
  points XDG_CONFIG_HOME at an empty directory for the package.
- Citation assertions match a well-formed bracketed citation in the
  article body, not a substring anywhere in the file.
- New tests: a compose over a flow-style sources base; a configured
  max_new_per_theme reaching rolling_pr through the handler; refusal
  when a synthesizer is configured but unavailable; the doctor line.
- sanitizeMembers documents why a scanner error is run-fatal.
- AGENTS.md and README document max_new_per_theme beside the other
  calibration knobs; the proposal records the max_completion_tokens
  transport fix and content coverage (website sync: website#499).

Closes #338
Closes #339

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(distill): synthesize rolling_pr articles instead of appending raw learnings

2 participants