Repository navigation
fix(distill): add to existing articles; name the PR head; create labels - #297
Conversation
rolling_pr's create path checked out the base and wrote a fresh draft rendered from the theme's members alone to theme.ExistingArticle, so a theme joining an existing compiled article replaced it: its prose, its cited sources and its tier were lost (unbound-force#295). The update path rendered the same way. - RenderThemeArticle renders onto the article as checked out: the base body and frontmatter stay, members it does not already cite are appended as sections and added to its sources, and tier becomes draft. A base citing every member is returned unchanged (no commit), and a render that would drop a citation is refused. - gh pr create gets --head <owner>:<branch>, the owner read from the push remote, so a fork checkout (origin = fork) opens its PR: the branch is pushed by explicit refspec with no upstream, so gh could not infer the head. - The human-gate, dewey-distill and needs-human-resolution labels are created once per run where missing; gh pr create fails on an unknown label. The edge-case fixture that opened a "prior run" PR for an article already citing every member now opens it before the citation lands, as a real prior run would: re-rendering a fully cited article is a no-op. Co-Authored-By: Claude Opus 5.5 <[email protected]>
writeThemeFiles crossed cyclomatic complexity 15, pushing CI's Gaze CRAPload count to 49 against the 48 ceiling. Extract the pure newly-cited-members computation (dropped/existing set filtering) into newlyCitedMembers, dropping writeThemeFiles to cx 10 (crap 10.3) with the helper at cx 6 and 100% line coverage. Behavior-preserving: identical iteration order and outputs. CI parity verified locally: build, vet, full -race test suite, and gaze 47/48 CRAPload, 43/45 GazeCRAPload (both PASS).
Address all nine review-council findings on the dewey_rolling_pr fix: - fakeGH now models gh label semantics: a label registry populated by 'label create' and consulted by 'pr create --label' and 'pr edit --add-label' (unknown labels fail), a failure-injection knob for the ensureLabels hard-failure arm, a runErr knob for the gh.Run error wrap, and ordered call recording so tests enforce labels-before-create ordering. - writeThemeFiles read path gains the same traversal guard writeFileInVault enforces on writes. - distillLabels mutable package map becomes the distillLabelMeta lookup function (CS-007: no mutable package-level state). - ownerFromRemoteURL treats file:// remotes as local transports and returns "" instead of a bogus owner. - New tests: citation-preservation refusal negative path (render that would drop a quoted cited source is refused, nothing written), frontmatter helper unit tests (splitFrontmatter CRLF/unterminated/ fence-edge cases, renderSourcesBlock, setFrontmatterLine block replacement), owner-qualified --head on fork remotes with label-before-create ordering, ensureLabels failure arms, and append-preservation assertions in the second-run update test. CI parity: go build/vet, go test -race -count=1 (all packages), gaze CRAPload 47/48 and GazeCRAPload 43/45 both pass.
uf-divisor
left a comment
There was a problem hiding this comment.
Council verdict: APPROVE WITH ADVISORIES — 5/5 reviewers succeeded; adversary, architect, and guard returned APPROVE; gaze-testing and testing returned APPROVE WITH ADVISORIES. All findings are test-quality advisories (1 MEDIUM, 2 LOW after dedup); none block the merge.
What this fixes (issue #295)
- Existing articles are added to, never replaced:
RenderThemeArticlerenders onto the article as checked out — body and frontmatter stay, newly-cited members append as## <id>sections, tier becomesdraft, a fully-cited base returns unchanged, and a render that would drop a cited source refuses. gh pr createnames its head (--head <owner>:<branch>), resolving fork checkouts.- Labels (
human-gate,dewey-distill,needs-human-resolution) are created once per run before create/edit.
Advisories
- MEDIUM (test-coverage) — the read-path traversal guard and non-
IsNotExistread-error arm inwriteThemeFilesship without a test for either refusal arm (inline below). [gaze-testing + testing] - LOW (test-quality) — the git-fixture integration tests carry no
testing.Short()guard, sogo test -shortcannot skip them (TC-011). [gaze-testing] - LOW (assertion-depth) — the "no base renders a fresh draft" subtest uses
RenderDraftArticleas its oracle, so it cannot independently catch a regression there (inline below). [testing]
CI — all checks green on head e26ee333: build-and-test (build, vet, test -race -count=1, Gaze CRAPload 47/48, GazeCRAPload 43/45), MegaLinter, CI OK.
This review was generated by /uf.review-pr (AI-assisted).
| articlePath := themeArticlePath(theme) | ||
| content, dropped, err := RenderDraftArticle(theme, input.Texts, DistillTierDraft) | ||
| // The article as checked out (the base's on the create path, the | ||
| // branch's on the update path): the render keeps it and adds to it. |
There was a problem hiding this comment.
MEDIUM (test-coverage, advisory) — The read-path traversal guard and the non-IsNotExist read-error arm added to writeThemeFiles have no test covering either refusal arm (TC-001/TC-005). The read contract has four behaviors — read absent → fresh render (tested), read present → additive render (tested), path escaping the vault root → refuse (untested), read error other than not-exist → refuse (untested). The guard is reachable: themeArticlePath composes distillCompiledPrefix + theme.Name (tag-derived, unsanitized — only the branch goes through SanitizeThemeBranch) and uses theme.ExistingArticle verbatim, and this suite's poisoned-assignment tests (TestValidateAssignedBranches_FailsClosedOnPoisonedAssignment, TestSanitizeThemeBranch with "../../etc/passwd") treat poison tags as anticipated input. The symmetric write guard has a dedicated test (TestWriteFileInVault_RejectsTraversal, rolling_pr_test.go:1793), so deleting or breaking this read guard regresses silently. A table-driven test calling writeThemeFiles with a theme whose Name/ExistingArticle escapes the vault root, asserting the refusal error, mirrors that precedent.
|
|
||
| t.Run("no base renders a fresh draft", func(t *testing.T) { | ||
| got, _, err := RenderThemeArticle("", distillTestTheme("auth", "", alice), texts, DistillTierDraft) | ||
| want, _, _ := RenderDraftArticle(distillTestTheme("auth", "", alice), texts, DistillTierDraft) |
There was a problem hiding this comment.
LOW (assertion-depth, advisory) — This subtest derives its expected value from RenderDraftArticle — the same function RenderThemeArticle delegates to — so both sides of the assertion change together, and a regression inside RenderDraftArticle's render cannot fail this subtest (oracle coupling; the same pattern masked a trimming regression in PR #156). The risk is contained: RenderDraftArticle is independently pinned by structural tests (TestRenderDraftArticle_DraftRender, _Deterministic, _MissingTextDropped), and the delegation equivalence is the documented contract. Two literal structural assertions (frontmatter prefix, member section) — or a comment naming the dependency on the sibling structural tests — let this subtest fail independently.
Fixes the correctness bugs from #295 in
dewey_rolling_pr.Changes
theme.ExistingArticle. That dropped the article's prose, cited sources and tier. In the run that filed dewey-distill-auto: rolling_pr replaces validated articles with raw draft dumps of new learnings #295, all 33 PRs did this.RenderThemeArticlenow renders onto the article as checked out, on both the create and update paths:## <id>sections and added tosources.tierbecomesdraft, since the additions are unreviewed and the human merge is the promotion.gh pr createnow gets--head <owner>:<branch>, with the owner read from the push remote's URL. The branch is pushed by explicit refspec with no upstream, so gh couldn't infer the head whenoriginis a fork.human-gate,dewey-distillandneeds-human-resolutionare created once per run where missing, before a PR is created or labeled. An existing label is fine.The dropped learning
group_learnersdoesn't drop identities. In the #295 run,dewey_scopereturned 1,090in_scope, but the agent passed 1,089 togroup_learners. It left outissue-triage-20261102T005717-jay-flowerswhen copying the list. That's the same through-the-model problem as the truncated decisions, so it belongs with passing the grouping by reference (below), not in this PR.Not in this PR
dewey_scopeandgroup_learnerscould write a run file and return its id, androlling_prcould read it. That removes the model copying a 2,000-item list (the dropped learning, the decisions cut to one per theme, the truncated JSON) and the payload size limit.Tests
--headand both labels.RenderThemeArticlecases (fresh, unchanged, idempotent append, inlinesources, no frontmatter, tier guard), plusownerFromRemoteURLandensureLabels.TestEdgeCase_EmptyScopePostsNothingAndLeavesPRsnow opens its prior-run PR before the citing article lands.go build,go vetandgo test -race ./...pass.golangci-lintreports only the 2 staticcheck QF1001 findings inartifacts/that are already onmain./uf.review-councilhasn't been run yet, so this is a draft.🤖 Generated with Claude Code