docs: fix bugs/gaps in agent-compliance roadmap (12 issues)

Systematic review surfaced 12 issues. All addressed:

Bugs fixed:
- Status table said 10/19 hex-clean; actually 13/19 (line count vs list mismatch)
- Progress log had two '(this commit)' placeholders never resolved to SHAs
- Pattern D showed deprecated 'assert { type: json }' import syntax
- Pattern E described wrong heuristic ('line ends with ;') vs actual scanner
  logic ('file declares the type literal anywhere')

Gaps filled:
- Added 'Quick start for the next agent' entry-point block at the top
- Added \u00a77 scanner-exclusions cheat-sheet (15+ patterns) so future agents
  don't have to read the script to know what's excluded
- Added \u00a78 maintainer gotchas:
  - macOS bash 3.2 lacks 'declare -A' (recurring trap)
  - heredoc + process-substitution + 2>/dev/null parse bug
  - dated reports gitignored, baseline.md committed
  - claw-code-oss exclusion rationale
  - noisy baseline diffs
- T2.4 clarified: scanner-cleared, not source-fixed (the 8 SVG fill= lines
  were never edited; only the scanner exception was added)
- Q1 decision reworded in past tense (Tier 2 now complete)
- Q4 added: mac_tooling hex-exemption rationale
- Pattern D split into D1/D2/D3 with the three actual approaches used
  (consuming @bytelyst/config, Next.js JSON import, Node script readFileSync)
- Execution protocol step 1 fixed: 'Set cwd to <repo>' not 'cd <repo>'
  (matches the workflow rule against cd commands)
- Execution protocol expanded with 'Why --no-verify' rationale
- Progress log: column renamed Hex \u0394 \u2192 \u0394 findings; new Type column
  (scanner|fix) to distinguish refinement commits from source-edit commits
- Progress log: missing commits added (f1ebff55, 421a7cc7, f7a70f16)
- Progress log: footer with cumulative session impact

No semantic changes to the campaign plan; tier checklists unchanged.
This commit is contained in:
saravanakumardb1 2026-05-23 14:56:50 -07:00
parent f7a70f16ed
commit 83118c3f35

View File

@ -12,6 +12,25 @@
---
## Quick start for the next agent
1. Read §0 **Status snapshot** — know what's already done.
2. Read §1 **Priority order** — find the next unchecked `- [ ]` item.
3. Read §2 **Fix patterns** — the next finding likely matches Pattern AF.
4. Read §3 **Execution protocol** — the exact step sequence to follow.
5. Re-run the scanner once at the start to confirm current state:
```bash
cd learning_ai_common_plat && bash scripts/check-rule-violations.sh
```
6. The full per-repo · per-finding report is at
[`reports/rule-violations-baseline.md`](../reports/rule-violations-baseline.md)
(committed snapshot — dated runs are gitignored).
> **Suggested next action:** Tier 4 (mindlyst, fastgap, flowmonk). See §1 for details.
> Tiers 13 are ✓ complete. Tier 5 (non-hex rules) is the long tail.
---
## 0. Status snapshot
_Last regenerated_: 2026-05-23 (during the session that authored this doc)
@ -26,12 +45,16 @@ _Last regenerated_: 2026-05-23 (during the session that authored this doc)
| `b4-console-log` | 93 | 93 |
| `b5-hardcoded-product-id` | 13 | **0** ✓ |
| `b4-swift-print` | 7 | 7 |
| Repos with **0 hex** findings | 2 | **10 / 19** |
| Repos with **0 hex** findings | 2 | **13 / 19** |
Hex-clean repos (13): `smart_auth`, `auth_app`, `talk2obsidian`, `local_memory_gpt`, `trails`,
`local_llms`, `jarvis_jr`, `productivity_web`, `voice_ai_agent`, `claw-cowork`,
`common_plat`, **`efforise`**, **`mac_tooling`** (exempt as standalone toolkit).
Repos still carrying hex (6): `multimodal_memory_agents` (70), `fastgap` (46),
`flowmonk` (107). The other three (`notes`, `clock`, `peakpulse`) sit at
0 hex but have non-hex findings deferred to Tier 5.
---
## 1. Priority order (execute strictly top-to-bottom)
@ -54,11 +77,9 @@ then non-hex rules.
### Tier 2 — Shared platform hex (59 → 0) — ✓ COMPLETE
Note: most of the 59 findings were false positives (Button.tsx etc. use the
`var(--bl-token, #fallback)` defensive pattern, already excluded by scanner).
The scanner refinement for `/services/`, `/packages/config/`, `/packages/devops/`,
`*.storybook/`, `/api/themes/`, and SVG `fill=` attribute brand colors cleared
most. Only 16 real findings required fixes:
Of the 59 findings, **16 were source-fixed** and **43 were scanner-cleared**
as legitimate non-styling hex (services/, config/, devops/, storybook/,
theme APIs, SVG brand `fill=` attributes). Source fixes:
- [x] **T2.1** `packages/auth-ui/src/{Verify,Mfa,Forgot,Login,Register,Reset,Onboarding}*.tsx` (7)
- All identical: `color: '#fff'``color: 'var(--bl-accent-foreground, #fff)'`
@ -69,8 +90,9 @@ most. Only 16 real findings required fixes:
`--bl-text-secondary`, `--bl-success`, `--bl-border` (with `var(token, #hex)`
defensive fallback for boot-order safety)
- [x] **T2.4** Google Sign-In SVG buttons in admin-web + tracker-web login pages (8)
- `fill="#4285F4"` etc. — brand-mandated colors per Google guidelines.
Scanner exception added (SVG fill/stroke attributes).
- `fill="#4285F4"` etc. — brand-mandated by Google. **Scanner-cleared,
no source edits** — SVG `fill=`/`stroke=` attribute hex now skipped
universally because brand identity colors cannot be themed via `var()`.
### Tier 3 — Medium product repos (57 → 0) — ✓ COMPLETE
@ -162,18 +184,38 @@ Match the hex to the closest existing semantic token (`border-default`, `border-
### Pattern D — Hardcoded product ID
Three variants, depending on the file's runtime context:
**D1.** Repos consuming `@bytelyst/config`:
```diff
- const PRODUCT_ID = "lysnrai";
+ import { getProductId } from '@bytelyst/config';
+ const PRODUCT_ID = getProductId();
```
Or for repos without `@bytelyst/config`:
**D2.** Next.js / bundler context (TS+ESM, supports JSON imports):
```diff
+ import productJson from '../shared/product.json' assert { type: 'json' };
+ import productJson from "../../../../shared/product.json";
+ export const PRODUCT_ID =
+ process.env.NEXT_PUBLIC_PRODUCT_ID ?? productJson.productId;
```
_Used in `mindlyst-native/web/src/lib/cosmos.ts` (commit `7d61713`)._
**D3.** Node.js scripts (tsx / plain Node), no bundler available:
```diff
+ import { readFileSync } from "node:fs";
+ import { fileURLToPath } from "node:url";
+ import { dirname, join } from "node:path";
+
+ const __dirname = dirname(fileURLToPath(import.meta.url));
+ const productJson = JSON.parse(
+ readFileSync(join(__dirname, "..", "shared", "product.json"), "utf-8"),
+ ) as { productId: string };
+ const PRODUCT_ID = productJson.productId;
```
_Used in `learning_voice_ai_agent/scripts/churn-alert.ts` (commit `2281b4b`).
This avoids the `assert { type: 'json' }` syntax (deprecated as of Node 22
in favor of `with { type: 'json' }`) and works across all current LTS versions._
### Pattern E — TS literal type vs object value (product ID)
@ -181,14 +223,20 @@ Or for repos without `@bytelyst/config`:
// Type literal — KEEP (good Cosmos discipline):
interface MyDoc { productId: "mindlyst"; ... }
// Object value — REPLACE:
const doc = { productId: "mindlyst" };
// becomes:
const doc = { productId: PRODUCT_ID };
// Object value — typically also KEEP when the same file's type forces it.
// The TS type system rejects any value other than "mindlyst" here, so the
// hardcode is type-system-required (not a violation):
const doc: MyDoc = { productId: "mindlyst", ... };
```
Distinguishing rule: line ends with `;` after the literal → type definition (keep).
Line ends with `,` or `}` → object literal (replace).
**Actual scanner heuristic** (encoded in `scan_b5_hardcoded_product_id`):
if a TS/TSX file declares `productId: "<id>";` anywhere as a type literal,
any matching value-site `productId: "<id>",` in the same file is skipped.
This recognises the discriminated-union/Cosmos discipline pattern in
`mindlyst-native/web/src/lib/ecosystem-phase{1,3}.ts`.
Only replace with `PRODUCT_ID` when the value-site does **NOT** have a
literal-type constraint in scope (rare in practice). Otherwise: leave it.
### Pattern F — `console.log(...)` in non-CLI code
@ -206,23 +254,30 @@ unless it's a genuine `console.error` for an unrecoverable client error.
## 3. Execution protocol (per repo, per rule)
```
1. cd <repo>
2. bash <common_plat>/scripts/check-rule-violations.sh <repo>
3. Group findings by file (sort -u by file in JSON)
4. For each file:
a. Read the file
b. Apply the matching pattern from §2
c. If no pattern fits → STOP, propose options
5. Re-run scanner — must show 0 for the targeted rule
6. Typecheck (pnpm run typecheck OR tsc --noEmit)
7. git add -A <touched paths>
8. git commit --no-verify -m "fix(<scope>): <one-line summary>
1. Set cwd to <repo> (use the run_command Cwd parameter; do NOT use `cd`)
2. bash <common_plat>/scripts/check-rule-violations.sh <repo>
3. Group findings by file (sort -u by file in JSON)
4. For each file:
a. Read the file
b. Apply the matching pattern from §2
c. If no pattern fits → STOP, propose options
5. Re-run scanner — must show 0 for the targeted rule
6. Typecheck (pnpm run typecheck OR tsc --noEmit)
7. git add -A <touched paths>
8. git commit --no-verify -m "fix(<scope>): <one-line summary>
<body explaining what & why, referencing the scanner verdict>"
9. git push --no-verify
<body explaining what & why, referencing the scanner verdict>"
9. git push --no-verify
10. Update §0 status table and check off the tier item above
```
**Why `--no-verify`:** the repos have husky pre-commit / pre-push hooks that
run typecheck / test / lint on every commit. For a precision-tuned compliance
campaign the agent has already verified the surgical change with the scanner
and a targeted typecheck; running the full hook suite per commit would block
on unrelated pre-existing warnings (e.g., missing `@types/node` in some
scripts). Use full hooks at PR review time, not per atomic commit.
### Stop conditions
The agent **MUST stop** and ask the user when any of these occur:
@ -261,24 +316,31 @@ The agent **MUST stop** and ask the user when any of these occur:
## 5. Progress log
| Date | Tier | Action | Commit | Hex Δ | Total Δ |
|---|---|---|---|---:|---:|
| 2026-05-23 | 0 | Scanner build + initial scan | `4967b125` | 0 | baseline 2548 |
| 2026-05-23 | 0 | Scanner precision (var fallback, themeColor) | `14ab38e4`, `616e9738` | 564 false-positives | 905 |
| 2026-05-23 | 2a | talk2obsidian hex → token | `d20848a` | 1 | 1 |
| 2026-05-23 | 2a | local_memory_gpt hex → token | `a5def1c` | 1 | 1 |
| 2026-05-23 | 2a | trails hex → token | `10549e6` | 1 | 1 |
| 2026-05-23 | 2a | local_llms hex → token | `ca853f1` | 1 | 1 |
| 2026-05-23 | 2b | Scanner: backend/, tailwind, HTML entity exceptions | `d5d30ed9` | 47 false-positives | 47 |
| 2026-05-23 | 2b | jarvis_jr hex → token | `bf9e1c7` | 1 | 1 |
| 2026-05-23 | 2b | claw-cowork hex → tokens | `9017dd8` | 2 | 2 |
| 2026-05-23 | 1 | voice_ai_agent churn-alert PRODUCT_ID from product.json | `2281b4b` | 2 critical | 2 |
| 2026-05-23 | 1 | multimodal cosmos.ts fallback from product.json | `7d61713` | 1 critical | 1 |
| 2026-05-23 | 1 | Scanner: recognize TS literal-type constraints (ecosystem-phase\*) | `c3362051` | 10 critical | 10 |
| 2026-05-23 | 2 | Scanner: exclude services/, packages/config, devops, SVG fill, ThemeEditor | (this commit) | 29 false-positives | 29 |
| 2026-05-23 | 2 | auth-ui (7) + dashboard-shell (3) + tracker-web/health (6) hex → var() | `f1ebff55` | 16 | 16 |
| 2026-05-23 | 3 | Scanner: exempt mac_tooling + skip /theme/colors.ts + CSS prop defs + recharts selectors | (this commit) | 66 false-positives | 66 |
| 2026-05-23 | 3 | efforise theme/colors.ts + components | `ddbd2e7` | 19 | 19 |
`Δ findings` reflects the net change in **total scanner findings** after the
step. Negative means findings cleared. Source fixes and scanner refinements
are interleaved chronologically; the `Type` column distinguishes them.
| Date | Tier | Type | Action | Commit | Δ findings |
|---|---|---|---|---|---:|
| 2026-05-23 | 0 | scanner | Build + initial ecosystem scan | `4967b125` | baseline 15,004 → 2,681 |
| 2026-05-23 | 0 | scanner | Var-fallback / themeColor precision | `14ab38e4`, `616e9738` | 905 |
| 2026-05-23 | 2a | fix | talk2obsidian hex → `--t2o-text-on-accent` | `d20848a` | 1 |
| 2026-05-23 | 2a | fix | local_memory_gpt hex → `--lmg-text-on-accent` | `a5def1c` | 1 |
| 2026-05-23 | 2a | fix | trails hex → `--at-text-on-accent` | `10549e6` | 1 |
| 2026-05-23 | 2a | fix | local_llms hex → `--llm-text-on-accent` | `ca853f1` | 1 |
| 2026-05-23 | 2b | scanner | backend/, tailwind, HTML-entity exceptions | `d5d30ed9` | 47 |
| 2026-05-23 | 2b | fix | jarvis_jr hex → `--jj-text-on-accent` | `bf9e1c7` | 1 |
| 2026-05-23 | 2b | fix | claw-cowork hex → `--cw-*` tokens | `9017dd8` | 2 |
| 2026-05-23 | 1 | fix | voice_ai_agent: PRODUCT_ID from product.json | `2281b4b` | 2 critical |
| 2026-05-23 | 1 | fix | multimodal cosmos.ts: fallback from product.json | `7d61713` | 1 critical |
| 2026-05-23 | 1 | scanner | Recognise TS literal-type constraints (ecosystem-phase\*) | `c3362051` | 10 critical |
| 2026-05-23 | 2 | scanner | Exclude services/, packages/config, devops, SVG fill, ThemeEditor | `f1ebff55` | 29 |
| 2026-05-23 | 2 | fix | auth-ui (7) + dashboard-shell (3) + tracker-web/health (6) → var() | `f1ebff55` | 16 |
| 2026-05-23 | 3 | scanner | Exempt mac_tooling + skip /theme/colors.ts + CSS prop defs + recharts selectors | `421a7cc7` | 66 |
| 2026-05-23 | 3 | fix | efforise: `client/src/theme/colors.ts` + 5 components | `ddbd2e7` | 19 |
| 2026-05-23 | (3.5) | scanner | Broaden /theme/, /app/api/, -data.ts, -flows.ts exclusions | `f7a70f16` | 53 |
Total session impact: **2,548 → 1,388** (46%). Critical findings: **13 → 0**.
---
@ -286,9 +348,12 @@ The agent **MUST stop** and ask the user when any of these occur:
- **Q1:** Should we touch `@bytelyst/ui` / `@bytelyst/auth-ui` / `@bytelyst/dashboard-shell`
in this campaign, given they're shared across all products?
- **Decision:** Yes (Tier 2). Their existing `var(--bl-token, #fallback)` pattern
will likely make most findings false positives (already handled by scanner).
Real findings will be targeted, small, and high-leverage.
- **Decision (Tier 2, resolved):** Yes. Of 59 findings in `common_plat`,
16 needed source edits and 43 were scanner-cleared as defensive
`var(--bl-token, #fallback)` patterns or schema/config files. Source
edits used the same `var(--bl-accent-foreground, #fff)` defensive
pattern (matches the existing `packages/ui/src/components/Button.tsx`
convention) so consumer products can still override per-product theme.
- **Q2:** Should `mac_tooling` Python `print()` statements be flagged?
- **Decision:** It depends on file role. CLI tools (`tools/cli.py`, `__main__.py`)
@ -300,3 +365,83 @@ The agent **MUST stop** and ask the user when any of these occur:
asked"). However, `scripts/` are excluded from the scanner since they target
terminal output where emojis are conventional in some teams. For UI emojis
(📊 📝 📄 etc. in dashboards), replace with `lucide-react` icons.
- **Q4:** Should `mac_tooling`'s hex exemption be reversed in a future cleanup?
- **Decision (Tier 3, resolved):** Keep exempt. Per the repo's own
`AGENTS.md §8` ("Differences from ByteLyst Product Repos") it has no
`@bytelyst/*` packages, no design-token system, and no `productId`. Its
DataFlowMap risk colors are categorical data viz. Reversing the
exemption would require introducing an entire design-token system to
a personal forensics toolkit — not worth the cost.
---
## 7. Scanner exclusions cheat-sheet
Accumulated through 4 precision rounds. Each line below corresponds to a
`continue` branch in `scripts/check-rule-violations.sh` §`scan_web_hardcoded_hex`
(plus rules in `scan_b5_hardcoded_product_id`). Reading this saves a trip into
the script.
**File-path exclusions (hex rule):**
| Pattern | Reason |
|---|---|
| `globals.css`, `tokens.css`, `tailwind.config.*`, `*.tokens.*`, `*Theme.{ts,swift,kt}` | Token definitions |
| `/generated/`, `/design-tokens/`, `/design-system/` | Generated artifacts |
| `/theme/*.{ts,tsx,js}` | Theme source modules |
| `(^|/)backend/` | Backend layer (data, not UI) |
| `/services/<svc>/src/` | Fastify backends in `common_plat` |
| `/packages/config/` | Schema / product manifest defaults |
| `/packages/devops/` | Internal dev tooling |
| `/packages/create-app/src/lib/templates` | Scaffolder templates |
| `/app/api/*.{ts,tsx}` | Next.js API routes (server-side) |
| `/src/lib/*-(data|flows|palette).{ts,tsx}` | Domain visualization data |
| `.storybook/`, `/stories/`, `*.stories.{ts,tsx}` | Docs/demos |
| `/tools/{color-picker,markdown-preview,qr-code,image-to-base64,regex-tester}/` | productivity_web tool demos |
| `/ThemeEditor.{ts,tsx}`, `/theme-defaults.*`, `/api/themes/` | Theme editor / theme-defaults |
| **Repo-level: `learning_ai_mac_tooling`** | Exempt by design (see Q4) |
**Line-content exclusions (hex rule):**
| Pattern | Reason |
|---|---|
| `^\s*--[a-zA-Z0-9-]+:` | CSS custom property DEFINITIONS (incl. gradients) |
| `var(--[a-zA-Z0-9_-]+` | Defensive `var(--token, #fallback)` pattern |
| `^\s*(//|*|/*)` | Comment lines |
| `themeColor:` | Next.js PWA metadata (must be literal) |
| `(fill|stroke)="#hex"` | SVG attribute (brand logos) |
| `[(stroke|fill|color)="#hex"]` | CSS attribute SELECTORS (recharts) |
| `&#[0-9]+;` | HTML numeric character references |
**Product-ID rule extras:** files at `shared/product.json`, `product-config.*`,
`product.manifest.json`; JSDoc/`//`/`#` comment lines; `SelectItem|option|productId:|product:` enumeration patterns; files where a TS literal type
`productId: "<id>";` is declared (treats matching value-sites as type-required);
files inside `common_plat`'s `dashboards/{admin-web,tracker-web,ux-lab}/`
(cross-product UI).
---
## 8. Maintainer gotchas
- **macOS bash 3.2 vs bash 5.x.** The system `/bin/bash` on macOS is 3.2 and
does **NOT** support associative arrays (`declare -A`). The scanner was
originally written assuming bash 4+ and failed with `declare: -A: invalid option`.
It now uses parallel scalar counters + a temp file for per-rule rollups.
When extending the script, never reintroduce associative arrays — the
script's shebang is `#!/usr/bin/env bash` and must work under the system
bash because corp-network laptops sometimes lack Homebrew bash.
- **Heredoc + process-substitution + `2>/dev/null`** combinations cause
bash to misparse the heredoc terminator as a redirect target (`line N: 0:
ambiguous redirect`). The emoji scanner avoids this by writing its Python
helper to a `mktemp` file instead of inlining it in `<(python3 - <<'PYEOF' ...)`.
- **Scanner output files are dated and gitignored.** Only
`reports/rule-violations-baseline.md` is committed. Re-running the
scanner overwrites `reports/rule-violations-YYYY-MM-DD.{md,json}` for the
current date. To refresh the baseline: `cp reports/rule-violations-<date>.md
reports/rule-violations-baseline.md` then commit.
- **The `repos.txt` list excludes `learning_ai_claw-code-oss`** (upstream
Anthropic repo with its own conventions). Do not re-add it.
- **`reports/rule-violations-baseline.md` diffs are noisy** because findings
re-order between runs. Compare the summary table at the bottom of the
markdown report instead of doing line-by-line diffs.