oficina / equipo Public

Check glance word pieces and any 7-hex run as identifiers

Review fix round 2 (Astra), finding 4: wire.GlanceText trimmed
punctuation only at token ends, so "Running pre-checks now" and
"Opening repo:example" passed, and an all-letter short SHA such as
"deadbeef" passed too.

The whole-word checks now run on word pieces: the line split at every
character that is not a letter or digit (hyphens, colons, dots,
apostrophes; an underscore becomes a space when markdown is stripped).
Any piece holding a run of seven or more hex characters, digits or not,
is an identifier and drops the glance; a rare word like it only means
no glance. Regression cases: pre-checks, repo:example, deadbeef,
re-review, repo's, it_for_review refused; "Checking your calendar",
"Reading the summary" and "pre-launch" kept. Breaking the split once
failed TestGlanceText. Budget re-measured for internal/wire.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 07a3e63ab3e4de794a0df4f7f758772afb019cc8 parent 7bb50d4
3 files changed, +27 −21
  • .rastrillo/budgets.txt +1 −1
  • internal/wire/glance.go +23 −18
  • internal/wire/glance_test.go +3 −2

CI passed — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 6e84e7af..76d05a0f 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -15,7 +15,7 @@ time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial re
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
size internal/equipo 20392 - The web view models and templates share rendering; Roster adds bylines, fact details, sub-chat views, Stop and compact reports. Measured 20392 source lines.
-size internal/wire 6347 - Runner and person API types share Encode. 21 adds Copy fields, 22 job lanes and cards, 23 the glance frame and its guard. Measured 6347 source lines.
+size internal/wire 6352 - Runner and person API types share Encode. 21 adds Copy fields, 22 job lanes and cards, 23 the glance frame and its guard. Measured 6352 source lines.
size internal/equipotest - 13400 Task 21 repairs historical migration and conversation fixtures after Plan 3. Measured 13024 test lines; the 300s time ceiling is unchanged.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s).
diff --git a/internal/wire/glance.go b/internal/wire/glance.go
index a43295f4..9b1a7d55 100644
--- a/internal/wire/glance.go
+++ b/internal/wire/glance.go
@@ -27,28 +27,32 @@ var glanceRefusedWords = map[string]bool{"check": true, "checks": true, "repo":
// glanceRefusedMarks are a link or a path: never in a glance.
var glanceRefusedMarks = []string{"://", "www.", "/", "\\"}
-// glanceHex says whether a word holds an identifier: a run of at least
-// seven hex digits with a digit in it (a short or full SHA), or of
-// sixteen with or without one.
-func glanceHex(word string) bool {
- run, digit := 0, false
- for _, r := range word + " " {
- hex := r >= '0' && r <= '9' || r >= 'a' && r <= 'f'
- if hex {
- run++
- digit = digit || r <= '9'
+// glanceHex says whether a word piece holds an identifier: a run of at
+// least seven hex characters, digits or not (a short or full SHA). A
+// rare word like it only means no glance.
+func glanceHex(piece string) bool {
+ run := 0
+ for _, r := range piece {
+ if r >= '0' && r <= '9' || r >= 'a' && r <= 'f' {
+ if run++; run >= 7 {
+ return true
+ }
continue
}
- if run >= 16 || run >= 7 && digit {
- return true
- }
- run, digit = 0, false
+ run = 0
}
return false
}
+// glancePieces are the line's word pieces: split at every character
+// that is not a letter or digit (hyphens, colons, dots, underscores,
+// apostrophes), so "pre-checks" holds "checks".
+func glancePieces(lower string) []string {
+ return strings.FieldsFunc(lower, func(r rune) bool { return !unicode.IsLetter(r) && !unicode.IsDigit(r) })
+}
+
// glanceMarkup is markdown punctuation, dropped from a glance.
-const glanceMarkup = "*_`#>~[]|\"“”"
+const glanceMarkup = "*`#>~[]|\"“”"
// GlanceText makes raw one plain line: newlines, tabs and control
// characters become spaces, markdown and quotes go, as does a link's
@@ -68,7 +72,8 @@ func GlanceText(raw string) (string, bool) {
}
i += n + end + 1
continue
- case r == utf8.RuneError && n <= 1, unicode.IsControl(r), unicode.IsSpace(r):
+ case r == utf8.RuneError && n <= 1, unicode.IsControl(r), unicode.IsSpace(r), r == '_':
+ // An underscore is markdown or joins words: a space either way.
b.WriteByte(' ')
case strings.ContainsRune(glanceMarkup, r):
default:
@@ -106,8 +111,8 @@ func GlanceText(raw string) (string, bool) {
return "", false
}
}
- for _, w := range strings.Fields(lower) {
- if glanceRefusedWords[strings.TrimFunc(w, func(r rune) bool { return !unicode.IsLetter(r) })] || glanceHex(w) {
+ for _, w := range glancePieces(lower) {
+ if glanceRefusedWords[w] || glanceHex(w) {
return "", false
}
}
diff --git a/internal/wire/glance_test.go b/internal/wire/glance_test.go
index fd1dd997..fd76bb6b 100644
--- a/internal/wire/glance_test.go
+++ b/internal/wire/glance_test.go
@@ -58,7 +58,8 @@ func TestGlanceText(t *testing.T) {
{"Checking\tyour\x00 invoices", "Checking your invoices"},
{"Reviewing your draft for Tito", "Reviewing your draft for Tito"},
{"Checking your calendar for Friday", "Checking your calendar for Friday"},
- {"Looking at the defaced page", "Looking at the defaced page"},
+ {"Reading the summary for Tito", "Reading the summary for Tito"},
+ {"Planning the pre-launch party", "Planning the pre-launch party"},
} {
got, ok := wire.GlanceText(c.in)
if !ok || got != c.want {
@@ -71,7 +72,7 @@ func TestGlanceText(t *testing.T) {
t.Fatalf("a clean line changed: %q -> %q", got, again)
}
}
- for _, in := range []string{"", " \n ", "**", "Asking the team now", "Starting a TASK for you", "Creating a branch", "Merge coming up", "Handing it to the coordinator", "Your runner is busy", "Equipo is on it", "Checking repository abc", "Opening the repo now", "Opening your repos", "Running the checks", "One check left", "Sending it for review", "Deploying your site", "Asking a specialist", "Looking at 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b", "Looking at abc1234 now", "Opening deadbeefcafe0", "Opening https://tito.io/admin", "Reading src/main.go", "Opening www.tito.io", "Looking at C:\\work", "Supercalifragilisticexpialidociousandmoreandmoreandmoreandmorewords"} {
+ for _, in := range []string{"", " \n ", "**", "Asking the team now", "Starting a TASK for you", "Creating a branch", "Merge coming up", "Handing it to the coordinator", "Your runner is busy", "Equipo is on it", "Checking repository abc", "Opening the repo now", "Opening your repos", "Running the checks", "One check left", "Sending it for review", "Deploying your site", "Asking a specialist", "Looking at 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b", "Looking at abc1234 now", "Opening deadbeefcafe0", "Opening https://tito.io/admin", "Reading src/main.go", "Opening www.tito.io", "Looking at C:\\work", "Running pre-checks now", "Opening repo:example", "Looking at deadbeef", "Starting the re-review", "Opening the repo's page", "Sending it_for_review", "Supercalifragilisticexpialidociousandmoreandmoreandmoreandmorewords"} {
if got, ok := wire.GlanceText(in); ok {
t.Fatalf("GlanceText(%q) kept %q", in, got)
}