Skip to content

feat(adr): convert agent-memory patterns into enforced ADR rules#376

Merged
rhuanbarreto merged 6 commits into
mainfrom
claude/reverent-mendel-cb8c8d
May 29, 2026
Merged

feat(adr): convert agent-memory patterns into enforced ADR rules#376
rhuanbarreto merged 6 commits into
mainfrom
claude/reverent-mendel-cb8c8d

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

Consolidates the archgate-developer agent memory and converts its enforceable "Patterns & Fixes" entries into machine-checkable ADR rules, so conventions previously living only in memory are now enforced by archgate check.

Memory consolidation (.claude/agent-memory/archgate-developer/MEMORY.md):

  • Fixed stale pinned Bun version (1.3.81.3.14)
  • Removed a broken pointer to a non-existent project_telemetry_strategy.md
  • Corrected mandatory-workflow skill names (@architect/@quality-manager@reviewer/@lessons-learned)
  • Annotated entries now backed by rules with (ENFORCED: <rule>)

Existing ADRs upgraded to enforced rules:

  • GEN-003 rules:false→true — bans bunx/npx of lint/format tools (prettier, oxfmt, oxlint, eslint, biome) and bare bun test in CI workflows. Fixed the one real violation in smoke-test-windows.yml (bun testbun run test).
  • ARCH-001 — added no-top-level-await-in-entry (scans src/cli.ts; build:check remains authoritative).
  • ARCH-017 rules:false→trueno-npm-main-field keeps the thin npm shim from bundling the CLI entry point.

New ADRs (+ companion rules):

  • ARCH-018 — lazy-load heavy deps (inquirer, @sentry/*, posthog-node); import type is exempt.
  • ARCH-019 — every inquirer.prompt() must be wrapped in withPromptFix() (Windows newline corruption).
  • ARCH-020Bun.Glob.scan() must pass { dot: true } (dotfile/cross-platform correctness, ctx.glob() in .rules.ts does not match dot-prefixed directories (e.g. .github/) on Windows #222).
  • ARCH-021.ps1 files must be ASCII-only (Windows PowerShell 5.1 mis-decodes BOM-less UTF-8).

Tooling consistency:

  • Routed the format-on-save hook in .claude/settings.json through a new format:file package.json script (bun run format:file) instead of bunx oxfmt.
  • CLAUDE.md: bun testbun run test to match GEN-003.

All new rules were verified against the real codebase first (no false positives — bunx --bun astro stays legal, import type exempt), then hardened with try/catch per the ARCH-013 convention after self-review.

Test plan

  • bun run cli check39/39 rules pass, 0 rule errors
  • bun run lint — 0 warnings, 0 errors
  • bun run typecheck — clean
  • bun run format:check — clean
  • bun test — 1231 tests pass (0 fail)
  • bun run format:file <file> verified on a single file
  • Note: knip reports pre-existing unused-devDependency warnings (oxfmt/oxlint/czg/conventional-changelog) unrelated to this PR (reproduces on unmodified package.json; proto-managed binaries knip can't resolve locally)

Consolidate the archgate-developer agent memory (fix stale Bun version,
remove a dead pointer, correct skill names) and codify enforceable
"Patterns & Fixes" entries as machine-checkable ADR rules.

- GEN-003: enable rules - ban bunx/npx of lint/format tools and bare
  `bun test` in CI; fix smoke-test-windows.yml accordingly
- ARCH-001: add no-top-level-await-in-entry rule for src/cli.ts
- ARCH-017: enable rules - forbid an npm `main` field on the thin shim
- ARCH-018: new ADR - lazy-load heavy deps (inquirer, @sentry, posthog)
- ARCH-019: new ADR - wrap inquirer prompts in withPromptFix()
- ARCH-020: new ADR - Bun.Glob.scan must pass { dot: true }
- ARCH-021: new ADR - PowerShell scripts must be ASCII-only
- Route the format-on-save hook through `bun run format:file` (no bunx)

archgate check: 39/39 rules pass.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 29, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: cd92699
Status: ✅  Deploy successful!
Preview URL: https://63045a87.archgate-cli.pages.dev
Branch Preview URL: https://claude-reverent-mendel-cb8c8.archgate-cli.pages.dev

View logs

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.2% (6575 / 7289)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.0% 2082 / 2365
src/engine/ 92.9% 1219 / 1312
src/formats/ 100.0% 141 / 141
src/helpers/ 90.3% 3133 / 3471

The enforced "Patterns & Fixes" entries duplicated the rationale now
owned by their ADRs. Replace ~9 verbose bullets with a one-line
"Enforced by ADRs" map and keep only the non-enforceable env/CI/platform
lessons in "Patterns & Fixes". Net: 22.4KB -> 17.7KB.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Drop the "Enforced by ADRs" pointer map entirely — enforced conventions
live in their ADRs (which the agent reads before coding), so duplicating
even a one-liner is redundant. Memory now keeps only non-enforceable
lessons. 22.4KB -> 16.7KB.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Remove entries that no longer earn their place: git-identity-in-tests
and mock.module/fetch (fully covered in ARCH-005 Do's/Don'ts/examples),
SLSA tag-pin (stale line/version; owned by an in-repo comment + CI-001
carve-out), telemetry eager/lazy init (derivable from cli.ts comments),
smoke-test asset finding and CodeQL setup (settled one-time CI changes;
codeql.yml now exists). Trim the GITHUB_TOKEN entry to its generalizable
lesson, dropping the PR-history narrative.

Memory now keeps only recurring, non-enforceable hazards. 22.4KB -> 12.1KB.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Resolve MEMORY.md conflict in "Patterns & Fixes": keep main's new
non-enforceable lessons (custom oxlint plugins, unicorn/no-array-callback-
reference, require-unicode-regexp, oxfmt-formats-markdown) and our pruned
structure. Drop main's three bullets that are already captured in ARCH-005
(assert-does-not-throw, injectable thresholds, per-test timeout), keeping
memory free of ADR duplication.

Post-merge validation: lint 0/0, typecheck clean, archgate check 39/39,
1218 tests pass.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Replace the process-global mock.module() on the first-party registry
module with per-test spyOn (ARCH-005): mock.module leaks across files in
the same Bun process and risked contaminating registry.test.ts. Fakes are
typed as `typeof registryMod.fn` so they check against the real signatures,
and are restored via mock.restore() in afterEach. All 20 tests pass; full
suite green (1218 pass) with no cross-file leakage.

Memory slimming:
- Remove the "mock.module + require macOS" entry — obsolete now that the
  one file using it is migrated, and superseded by ARCH-005's spyOn guidance.
- Trim project_shim_publishing.md to the durable, non-enforceable gotchas;
  drop ephemeral incident details (run IDs, deploymentId, v0.40.0 narrative).

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@rhuanbarreto rhuanbarreto merged commit 267e7e4 into main May 29, 2026
19 checks passed
@rhuanbarreto rhuanbarreto deleted the claude/reverent-mendel-cb8c8d branch May 29, 2026 00:32
@archgatebot archgatebot Bot mentioned this pull request May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant