Skip to content

feat(symbols): add visibility column derived from JSDoc tags (B.7)#28

Merged
SutuSebastian merged 1 commit intomainfrom
feat/symbols-visibility-column
Apr 30, 2026
Merged

feat(symbols): add visibility column derived from JSDoc tags (B.7)#28
SutuSebastian merged 1 commit intomainfrom
feat/symbols-visibility-column

Conversation

@SutuSebastian
Copy link
Copy Markdown
Contributor

Summary

Implements B.7 from docs/research/fallow.md § Tier B: promote JSDoc visibility tags from a LIKE '%@beta%' regex inside the visibility-tags recipe to a real symbols.visibility TEXT column.

SCHEMA_VERSION 3 → 4. .codemap.db rebuilds automatically on next index via the existing createSchema() mismatch-detection path — no manual intervention.

What's new

Surface Change
Schema New symbols.visibility TEXT column. Partial index idx_symbols_visibility(visibility, file_path, name, line_start) WHERE visibility IS NOT NULL covers WHERE visibility = ? queries.
Parser New exported helper extractVisibility(doc): string | null. Anchored on line-start (after the JSDoc * prefix), so backticked references inside prose ("matches @public, @private") intentionally don't match — those are descriptions, not declarations. First match in document order wins when multiple line-leading tags are present.
Recipe visibility-tags SQL switches to WHERE visibility IS NOT NULL and returns the visibility value as a column so agents can filter / group without re-parsing the doc_comment.
Tests Parser unit tests cover null/empty doc, each canonical tag, in-prose false negatives, ordering, look-alike rejection (@betaTwo, @publicly), and per-method override on classes. DB test inserts three symbols with mixed visibility and asserts the partial-index round-trip. Golden visibility-tags.json regenerated with the new column.

Why a minor changeset

Per .agents/lessons.md "changesets bump policy (pre-v1)" — schema bumps that force a .codemap.db rebuild are minor, even in 0.x. Same precedent as 0.2.0.

What's not in this PR

  • --group-by visibility shortcut — no special-casing; agents already get it via SQL GROUP BY visibility or --group-by directory against the visibility-tags recipe rows.
  • Visibility on exports (vs symbols) — re-exports inherit the source symbol's tag; no separate column needed today.
  • @deprecated promotion — orthogonal to visibility (a deprecation is a lifecycle signal, not a visibility level). Stays on the doc_comment LIKE '%@deprecated%' path until a separate PR justifies its own column.

Test plan

  • bun run check passes locally (build, format:check, lint:ci, test, typecheck, test:golden — all 19 golden scenarios green).
  • Smoke tests against this clone:
    • bun src/index.ts --full succeeds and reports the schema-version-mismatch rebuild path.
    • bun src/index.ts query --json -r visibility-tags returns rows with visibility: "internal" (and similar) instead of just doc_comment regex matches.
    • bun src/index.ts query --json "SELECT visibility, COUNT(*) FROM symbols WHERE visibility IS NOT NULL GROUP BY visibility" works (uses the new partial index).
    • The earlier false positive (extractVisibility's own docstring matching @public because of backticked references) is gone.
  • Minor changeset added per pre-v1 "schema bump = minor" rule.
  • CI green.

Promotes JSDoc `@public` / `@private` / `@internal` / `@alpha` / `@beta`
from a `LIKE '%@beta%'` regex inside the `visibility-tags` recipe to a
real `symbols.visibility` TEXT column. SCHEMA_VERSION 3 → 4
(.codemap.db rebuilds automatically on mismatch via the existing
createSchema flow).

Parser:
- New `extractVisibility(doc)` helper exported from parser.ts
- Tag must start its own line (anchored on \n + optional whitespace) so
  backticked references inside prose like "matches @public, @Private"
  are correctly ignored — those are descriptions of tags, not
  declarations of one
- First match in document order wins when multiple line-leading tags
  are present
- Single post-processing pass on extractFileData populates
  symbols[].visibility from doc_comment — keeps the 8 push sites in
  parser.ts free of derivation logic

DB:
- New partial index idx_symbols_visibility(visibility, file_path, name,
  line_start) WHERE visibility IS NOT NULL — the common query shape is
  WHERE visibility = ? or WHERE visibility IN (...)
- insertSymbols extends the column list + binding tuple

Recipe:
- `visibility-tags` SQL now `WHERE visibility IS NOT NULL`. Returns the
  visibility value as a column so agents can filter / group without
  re-parsing the doc_comment

Tests:
- Parser tests cover null/empty doc, each canonical tag, in-prose false
  negatives, ordering, look-alike rejection (@Betatwo, @publicly), and
  per-method override on classes
- DB test inserts three symbols with mixed visibility and asserts the
  partial-index round-trip
- Golden visibility-tags.json regenerated with the new column

Adopted from docs/research/fallow.md B.7. Schema bumps justify a minor
release per .agents/lessons.md "changesets bump policy (pre-v1)".
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: cfbc9c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stainless-code/codemap Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@SutuSebastian has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 16 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7bdbe1d-7114-4144-b669-e119e5589fe3

📥 Commits

Reviewing files that changed from the base of the PR and between c32f052 and cfbc9c8.

📒 Files selected for processing (9)
  • .changeset/symbols-visibility-column.md
  • docs/architecture.md
  • docs/glossary.md
  • fixtures/golden/minimal/visibility-tags.json
  • src/cli/query-recipes.ts
  • src/db.test.ts
  • src/db.ts
  • src/parser.test.ts
  • src/parser.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/symbols-visibility-column

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 23 minutes and 16 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@SutuSebastian SutuSebastian merged commit 91598bc into main Apr 30, 2026
9 checks passed
@SutuSebastian SutuSebastian deleted the feat/symbols-visibility-column branch April 30, 2026 18:54
@github-actions github-actions Bot mentioned this pull request Apr 30, 2026
SutuSebastian added a commit that referenced this pull request Apr 30, 2026
…ty column (#29)

## Summary

The recent merges to `main` shipped:

- **Tier A query flags** (PR #26): `--summary`, `--changed-since <ref>`, `--group-by owner|directory|package`, plus per-row recipe `actions`.
- **B.7 — `symbols.visibility` column** (PR #28).

But the bundled `templates/agents/` rule + skill (the surface installed by `codemap agents init`) didn't reference any of them. Agents installed downstream would have a stale view of the CLI surface and miss the structured-column path for visibility queries. This PR aligns four files in lockstep:

| File | Audience |
| --- | --- |
| `templates/agents/rules/codemap.md` | **Ships to npm** — installed by `codemap agents init` |
| `templates/agents/skills/codemap/SKILL.md` | **Ships to npm** |
| `.agents/rules/codemap.md` | This repo's dev mirror (so my own session view stays accurate) |
| `.agents/skills/codemap/SKILL.md` | Same |

## Per-rule edits

- New CLI table rows for `--summary`, `--changed-since`, `--group-by` (with example commands).
- One-liner about per-row recipe `actions` (json + recipe only; ad-hoc SQL never carries them).
- New trigger pattern row: questions about `@internal` / `@beta` / `@alpha` / `@private` route to **`symbols.visibility`** (the parsed JSDoc tag) rather than `doc_comment LIKE '%@beta%'`.
- New quick-reference query for visibility.

## Per-skill edits

- New `symbols.visibility` row in the schema table.
- Two new query examples in the **Basic lookups** block: `WHERE visibility IS NOT NULL` and `WHERE visibility = 'beta'`.
- New **Output flags** subsection covering `--summary` / `--changed-since` / `--group-by` / per-row `actions`.
- Recipe id list extended with `deprecated-symbols`, `visibility-tags`, `barrel-files`, `files-hashes` (already shipped via earlier PRs but never enumerated in the skill).

## Why patch (not minor)

`templates/agents/` is the only ship-affecting surface here. The column + flags themselves were released by their respective minor / patch changesets earlier on main. Per `.agents/lessons.md` "changesets bump policy (pre-v1)", docs / template churn defaults to patch.

## Test plan

- [x] `bun run check` passes locally (build, format:check, lint:ci, test, typecheck, test:golden — 19/19 golden scenarios green).
- [x] Diff between dev mirror (`.agents/`) and shipped templates (`templates/agents/`) confirmed to differ only on the CLI-prefix prose (`bun src/index.ts` vs `codemap`) — same content otherwise.
- [ ] CI green.
SutuSebastian added a commit that referenced this pull request May 1, 2026
…chitecture skills (#32)

Two unrelated docs changes batched:

## 1. Plan: `codemap audit --base <ref>` (B.5)

Per `docs/README.md` Rule 3 (plans live in `plans/<feature-name>.md`, link from `roadmap.md`), drafts the design for **B.5** before writing any code. The research note explicitly calls this "the single highest-leverage candidate this refresh."

| Decision | v1 |
| --- | --- |
| **Snapshot strategy** | Temp worktree + full reindex under `.codemap.audit-<sha>/` (gitignored by the existing `.codemap.*` glob). Defers caching / perf-tuning until a real consumer hits the wall. |
| **Built-in deltas** | `files`, `dependencies`, `deprecated`, `visibility`, `barrels`, `hot_files`. Each wraps an existing recipe — no new analysis layer. |
| **Verdict** | `pass` / `warn` / `fail` with thresholds **opt-in via `codemap.config.audit`**. v1 emits raw deltas only (default `pass`). |
| **Exit codes** | `0` / `1` / `2` — mirrors `git diff --exit-code`. |
| **Composition** | `--json` / `--summary` work; `--changed-since` / `--group-by` / `--save-baseline` / `--baseline` are mutex (different shapes / semantics). |
| **Tracer-bullet sequence** | 7 commits: scaffold → worktree → first delta → remaining deltas → threshold config → docs+agents (Rule 10) → changeset. |

Both prerequisites just merged on `main`: B.6 (PR #30) proves the snapshot-in-DB primitive; B.7 (PR #28) provides the `symbols.visibility` column the `visibility` delta needs.

## 2. Adopt two Tier 3 skills from [`mattpocock/skills`](https://github.com/mattpocock/skills)

Sourced after evaluating three skills mid-thread; the two adopted ones earn their always-zero-cost slot:

| Skill | What |
| --- | --- |
| **`grill-me`** | 8-line interview-pattern skill. Walk a design tree branch by branch, recommend an answer per question, ask one at a time. Filled the gap visible in commit 1's plan: I made many decisions by myself; `grill-me` would have surfaced them for second opinion before they crystallised. |
| **`improve-codebase-architecture`** | Ousterhout-style deepening vocabulary (`module / interface / seam / adapter / depth / leverage / locality`), the deletion test, "one adapter = hypothetical seam, two = real," dependency categories (`DEEPENING.md`), and parallel-sub-agent "Design It Twice" interface exploration (`INTERFACE-DESIGN.md`). |

Both are maintainer-only (under `.agents/skills/` + `.cursor/skills/` symlinks per `agents-first-convention`). **Not added to `templates/agents/`** — same precedent as PR #25 (consumer surface ships only the codemap rule + skill).

### Translation notes

`improve-codebase-architecture/SKILL.md` adapted at three points to fit codemap's docs framework (the upstream version assumes `CONTEXT.md` + `docs/adr/`; we have neither):

- `CONTEXT.md` references → `docs/glossary.md` (Rule 9 already enforces glossary updates per PR).
- `docs/adr/` references → `docs/plans/<topic>.md` (Rule 3 — but plans are mortal; decisions of record lift to `architecture.md` per Rule 2 then the plan is deleted).
- "Offer ADR on rejection" step → dropped. Codemap doesn't keep decision records; the closest is "lift to architecture.md."

Companion files (`LANGUAGE.md`, `DEEPENING.md`, `INTERFACE-DESIGN.md`) ship **verbatim** — none reference `CONTEXT.md` or ADRs.

`grill-me/SKILL.md` extended with two short codemap-specific notes: prefer `codemap` over `Grep` when exploring (per the `codemap` rule), and write crystallised answers into the in-flight `docs/plans/<name>.md` inline (Rule 3).

### Skipped

- **`grill-with-docs`** (the third skill in the upstream "grill" family) — requires standing up CONTEXT.md / `docs/adr/` infrastructure that conflicts with the lift-to-architecture-then-delete-the-plan lifecycle codemap already runs. The salvageable ADR 3-criteria gate is recorded in this conversation; lift if codemap ever needs ADRs.

### Tier 3 list updated

`.agents/rules/agents-tier-system.md` Tier 3 list extended with both new skills, and the previously-missing `docs-governance` + `docs-lifecycle-sweep` entries from PR #25.

## Test plan

- [x] `bun run check` green (no behavior changed; pure docs + skills).
- [x] All cross-references resolve (plan → research → architecture / lessons; skill files → glossary.md / architecture.md / codemap rule / each other).
- [x] `.cursor/skills/{grill-me,improve-codebase-architecture}` symlinks resolve.
- [x] Plan calls itself out as **Plan** type per `docs/README.md § Document Lifecycle` — delete on ship, lift to `architecture.md`.
- [ ] CI green.
SutuSebastian added a commit that referenced this pull request May 1, 2026
)

* docs(research): refresh fallow.md + scan against current ship state

fallow.md gains a "Status snapshot (as of 2026-05-01)" section that
tabulates every adoption candidate's ship status — single source of
truth for "what's open" without munging the original tier tables.

Captures:
- Tier A all shipped (PR #26)
- B.5 partial (v1 in PR #33; --base <ref> + verdict deferred to v1.x)
- B.6 shipped (PR #30) — table-in-DB, not parallel JSON files
- B.7 shipped (PR #28) — landed on `symbols`, not `exports`
- B.8 / C.9 / C.10 / C.11 / D.* still as-was
- MCP server (agent-transports v1) shipped in PR #35 (adjacent —
  not a numbered fallow candidate but worth surfacing here)

§ 6 open questions: marks the 2 settled ones (actions ownership,
audit verdict default) with their resolution PRs; preserves the 2
still-open ones (coverage column shape, plugin layer scope).

§ 3 already-shipped block: updates the visibility-tags note to
acknowledge B.7 promoted it from regex to structured column instead
of saying "B.7 proposes promoting" (which it doesn't anymore).

competitive-scan-2026-04.md § 4: marks MCP server wrapping `query`
as ✅ shipped via PR #35 with a cross-link to fallow.md's status
snapshot. Other items still tracked there.

No behavior change; pure docs refresh to match current reality.

* docs(research): fix MD056 — D row in fallow.md status snapshot was 4 cells, header was 5

CodeRabbit caught: status-snapshot table header has 5 columns (Tier / # / Item / Status / Where) but the D.12-D.16 row only had 4 (collapsed Status + Where into one cell). Markdown parses that as a malformed table; renderers either drop the row or misalign neighbouring rows. Added the missing 5th cell pointing back at § 1's Defer / skip table for the per-row reasoning.

* docs(research): align B.7 row title to shipped column name (symbols.visibility)

CodeRabbit caught: Tier B table B.7 row title still said 'exports.visibility column' despite the body hedging '(or symbols)' AND the shipped column landing on symbols. Status snapshot row at L22 already says symbols. Updated the title to match shipped reality + added an explicit nod to the original hedge so the historical-record property survives.
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