carlos / platform Public

analytics-pages: the overflow row stays its own group, last (Astra R1 P2 on analytics-agents)

The singleton-folder fold matched _other, so 'Everything else' joined the
top level as if it were a page. Witness: TestBuildPageSectionsKeepsOverflowLast.
Findings: docs/superpowers/reviews/CODEX-FINDINGS-analytics-agents-R1.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 964d9bdd8f2973cd510773e2c2c60eee209e4b1c parent 08a205a
3 files changed, +34 −1
  • docs/superpowers/reviews/CODEX-FINDINGS-analytics-agents-R1.md +24 −0
  • internal/console/analyticsdisplay.go +1 −1
  • internal/console/analyticspages_test.go +9 −0

CI failed — run details

diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-analytics-agents-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-analytics-agents-R1.md
new file mode 100644
index 000000000..86312d52d
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-analytics-agents-R1.md
@@ -0,0 +1,24 @@
+Reviewed `origin/main...9e23ed3099` under the brief at `52e3ce5f`. No P1 findings.
+
+1. **P2 — Named bots are counted as people.**
+ [agents.go:15](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/analytics-agents/internal/analytics/agents.go:15) names Google InspectionTool, ChatGPT-User, Claude-User and Meta ExternalAgent, but `IsPageview` first requires `IsBot`, whose markers omit them. Verified: each returns a bot name yet produces `pageview=true, bot=false`. Their requests inflate visitors and page-view breakdowns instead of their named bot counts.
+ **Fix:** Make named-bot recognition part of `IsBot`, and test classification through `Observe`.
+ **Fault family:** Consistency between bot recognition, naming and counting.
+
+2. **P2 — Overflow is incorrectly grouped as a top-level page.**
+ At [analyticsdisplay.go:571](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/analytics-agents/internal/console/analyticsdisplay.go:571), the singleton-folder condition also matches `_other`. Verified with `/blog/a:1, _other:100`: “Top level” becomes the first section, reporting one page and 100 views. The intended separate, last overflow section disappears.
+ **Fix:** Exclude `analytics.OtherKey` from singleton-folder folding; add an overflow grouping witness.
+ **Fault family:** Overflow represents unattributed mass, not a page or folder.
+
+3. **P2 — Backward timestamps can prematurely release a flagged crawler.**
+ [pace.go:64](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/analytics-agents/internal/analytics/pace.go:64) replaces `last` unconditionally. Verified: flag a visitor at noon, observe an out-of-order timestamp at 11:00, then observe 12:00:01. The visitor becomes unflagged because the hold calculation uses 11:00.
+ **Fix:** Keep the latest timestamp monotonically increasing for hold expiry and pruning; define and test backward-time window handling separately.
+ **Fault family:** The crawler hold lasts until 30 minutes after the latest observation.
+
+The heuristic can flag genuine reload/tab bursts and is easily evaded by changing UA or staying below the threshold. Declared prefetches are excluded. Midnight changes the visitor hash and starts fresh pace state; salt failure bypasses detection. Those are v1 limitations, not additional findings.
+
+Targeted analytics tests and server-free console tests passed. Additional witnesses ran through memory-only Go overlays; no files were edited. Console integration tests were blocked by the sandbox’s socket restriction, so their runtime behavior remains unverified. An external working-tree edit to the Bots sentence was left untouched.
+
+**Census: APPROVE** the `internal/analytics` envelope re-pin. The changed functions add counting and classification state without introducing root read paths or weakening checks on existing reads. No individual units receive new dispositions.
+
+**READY AFTER FIXES**
\ No newline at end of file
diff --git a/internal/console/analyticsdisplay.go b/internal/console/analyticsdisplay.go
index c29435826..790712078 100644
--- a/internal/console/analyticsdisplay.go
+++ b/internal/console/analyticsdisplay.go
@@ -563,7 +563,7 @@ func buildPageSections(sum analytics.Summary, daily bool) []pageSection {
var top *pageSection
for _, name := range order {
sec := bySection[name]
- if name != "/" && len(sec.Pages) == 1 && sec.Pages[0].Path == name {
+ if name != "/" && name != analytics.OtherKey && len(sec.Pages) == 1 && sec.Pages[0].Path == name {
// A folder of one, its own index: a top-level page.
if top = bySection["/"]; top == nil {
top = &pageSection{Name: "/", Label: "Top level"}
diff --git a/internal/console/analyticspages_test.go b/internal/console/analyticspages_test.go
index c06886ca8..876146f1a 100644
--- a/internal/console/analyticspages_test.go
+++ b/internal/console/analyticspages_test.go
@@ -58,6 +58,15 @@ func TestBuildPageSections(t *testing.T) {
}
}
+// The overflow row is unattributed views, not a page: it stays its own
+// group, last, however small, and never joins the top level.
+func TestBuildPageSectionsKeepsOverflowLast(t *testing.T) {
+ secs := buildPageSections(analytics.Summary{Pages: map[string]int64{"/blog/a": 1, analytics.OtherKey: 100}}, false)
+ if len(secs) != 2 || secs[0].Name != "/blog/" || secs[1].Name != analytics.OtherKey || secs[1].Label != "Everything else" {
+ t.Fatalf("sections = %v", sectionNames(secs))
+ }
+}
+
func sectionNames(secs []pageSection) []string {
var out []string
for _, s := range secs {