carlos / platform Public

console: dpaPending only reports versions newer than the one in force

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 634c0c5b46f0548752cd231217d3cd84ed817046 parent 6c88b72
2 files changed, +13 −5
  • internal/console/dpainforce.go +7 −5
  • internal/console/dpainforce_test.go +6 −0

Intent

Human

<task-notification> <task-id>a4f37797b22525a8e</task-id> <tool-use-id>toolu_01HKYuuttEjao31FATE2mMH8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/260ddc60-0dfc-4cf8-8857-7688d6275097/tasks/a4f37797b22525a8e.output</output-file> <status>completed</status> <summary>Agent "Implement Task 2: guarded fetch" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE Commit: 6c88b72c "console: refuse unclosed and unbalanced legal fragments". The commit landed even though git printed the stale `packed-refs.lock` error again. Fixes: - **Unclosed tag (Critical 1):** `canonicalAgreement` now sums `len(z.Raw())` over every token and refuses with "unclosed tag" if the total is short of `len(b)` at EOF. All four probes you listed are in the table and refused, plus `&lt;p&gt;Terms&lt;/p&gt;&lt;script `. - **Unbalanced elements:** a stack of open elements gives "unbalanced &lt;/x&gt;" and "unclosed &lt;x&gt;". `br` is void and never pushed. I also refuse `&lt;/br&gt;`, since browsers read it as `&lt;br&gt;`. The carloku-shaped fragment, `&lt;p&gt;a&lt;br&gt;b&lt;/p&gt;`, `&lt;p&gt;a&lt;br/&gt;b&lt;/p&gt;` and a properly nested section/h2/ul/li/a/strong/em fragment are all accepted. - **Unicode format characters:** `shortToken` now maps them to `?`. I tested it with an attribute name containing U+202E, which comes out as `a?b`. Tests: `go test ./internal/console -run 'TestFetchLegal|TestCanonicalAgreement' -count=1` passes. gofmt and vet are clean. Concerns: an `href` containing a Unicode format character is still accepted, since you didn't ask for that to change. It is a one-line addition to `agreementHref` if you want it. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/.superpowers/sdd/2026-11-25-dpa-acceptance/task-2-report.md</result> <usage><subagent_tokens>59193</subagent_tokens><tool_uses>3</tool_uses><duration_ms>126858</duration_ms></usage> </task-notification>

Attributed to this commit: 19.1 g CO₂e (2,457,585 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on dpa-and-retention, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/dpainforce.go b/internal/console/dpainforce.go
index d53fd6e7f..dfab4cee6 100644
--- a/internal/console/dpainforce.go
+++ b/internal/console/dpainforce.go
@@ -34,13 +34,14 @@ func dpaQualifies(d LegalDocument, accountID int64, notified noticeLookup, now t
// it returns a zero document carrying the accepted ID.
func dpaInForce(accepted DPAAcceptance, docs []LegalDocument, notified noticeLookup, now time.Time) LegalDocument {
best := LegalDocument{ID: accepted.DocumentID}
+ found := false
for _, d := range docs {
if d.Kind != "dpa" || d.ID < accepted.DocumentID {
continue
}
if d.ID == accepted.DocumentID {
- if best.ID == accepted.DocumentID {
- best = d
+ if !found {
+ best, found = d, true
}
continue
}
@@ -51,13 +52,14 @@ func dpaInForce(accepted DPAAcceptance, docs []LegalDocument, notified noticeLoo
return best
}
-// dpaPending returns the newest dpa document after the accepted one that
-// does not apply yet, for the pane's "applies from" line, or nil.
+// dpaPending returns the newest dpa document strictly newer than the one in
+// force that does not apply yet, for the pane's "applies from" line, or nil.
func dpaPending(accepted DPAAcceptance, docs []LegalDocument, notified noticeLookup, now time.Time) *LegalDocument {
+ inForce := dpaInForce(accepted, docs, notified, now).ID
var pending *LegalDocument
for i := range docs {
d := docs[i]
- if d.Kind != "dpa" || d.ID <= accepted.DocumentID {
+ if d.Kind != "dpa" || d.ID <= inForce {
continue
}
if dpaQualifies(d, accepted.AccountID, notified, now) {
diff --git a/internal/console/dpainforce_test.go b/internal/console/dpainforce_test.go
index 3730f9d8a..efbb0db34 100644
--- a/internal/console/dpainforce_test.go
+++ b/internal/console/dpainforce_test.go
@@ -51,6 +51,12 @@ func TestDPAInForce(t *testing.T) {
{"three versions out of order, only v2 qualifies", 1,
[]LegalDocument{doc(3, pp(future), false), doc(1, pp(past), true), doc(2, pp(past), false)},
nil, 2, 3},
+ {"newer qualifying version hides the older pending one", 1,
+ []LegalDocument{doc(1, pp(past), true), doc(2, pp(past), true), doc(3, pp(past), false)},
+ nil, 3, 0},
+ {"v2 qualifies and v3 is pending", 1,
+ []LegalDocument{doc(1, pp(past), true), doc(2, pp(past), false), doc(3, pp(past), true)},
+ nil, 2, 3},
{"accepted v2 during v2's notice period", 2,
[]LegalDocument{doc(1, pp(past), true), doc(2, pp(past), true)}, nil, 2, 0},
{"earlier documents are ignored", 2,