Skip to content

feat: integrate SIDC Kit feature stack - #22

Merged
the-Drunken-coder merged 30 commits into
mainfrom
codex/integrate-feature-docs
Jun 26, 2026
Merged

the-Drunken-coder merged 30 commits into
mainfrom
codex/integrate-feature-docs

Conversation

@the-Drunken-coder

@the-Drunken-coder the-Drunken-coder commented Jun 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Integrates the feature work from PRs feat: verify browser bundle consumption #15-feat: add partial SIDC decomposition #21 into one stack PR
  • Adds browser bundle validation, expanded split catalog data, reverse lookup v0, improved search ranking, fixture generation, CLI support, and richer SIDC decomposition
  • Resolves the cross-PR integration issues by keeping the split catalog as the source shape, retargeting fixture generation to src/data/catalog/land-units.ts, preserving browser smoke + fixture checks in package scripts, and making reverse lookup results curated-only
  • Streamlines README coverage so the docs describe the combined behavior instead of seven conflicting feature slices

Integrated PRs

Validation

  • npm test
  • npm pack --dry-run

Notes

This PR supersedes the seven separate feature PRs once reviewers are comfortable with the combined stack. The original PRs are still open and were not closed by this update.

Summary by CodeRabbit

  • New Features
    • Added identifySymbol to recognize curated symbols from clean SVG/SVG data-URLs with confidence + evidence.
    • Expanded deterministic search/explain with curated vs partial coverage (typed fields + unknown tracking).
    • Added browser bundle support and published sidc-kit CLI binary, with new commands/options.
  • Bug Fixes
    • Improved validation and typed error/usage messages, including safer render sizing and oversized/invalid inputs.
  • Tests
    • Added browser smoke testing and broadened CLI/API tests for curated/partial/identification and JSON/error behavior.
  • Documentation
    • Expanded README (fixture generation, browser usage, and richer API docs/examples).

Greptile Summary

This PR integrates the SIDC Kit feature stack into one package update. The main changes are:

  • Browser bundle metadata and smoke validation.
  • A new sidc-kit CLI entrypoint.
  • Expanded curated symbol catalogs and fixture generation.
  • Split API modules for build, explain, render, search, and identify.
  • Partial SIDC decomposition and clean-SVG reverse lookup.

Confidence Score: 5/5

The integrated package behavior is runnable across the API, CLI, fixture, browser-smoke, and packaging paths without identified merge-blocking issues.

  • No code issues were identified in the finalized review.
  • Focused execution covered package tests, fixture checks, browser smoke validation, pack dry-run, CLI workflows, and public API behavior for search, render, explain, and identify.
  • The observed behavior matches the feature-stack contract described for this change.

None.

T-Rex T-Rex Logs

What T-Rex did

  • The baseline contract probes were executed against base main from a safe git archive to establish the before state, confirming the before-state lacked the new dist CLI module and identifySymbol export while older base package tests still passed.
  • The PR-head package was validated end-to-end, including npm test returning exit code 0, browser smoke passing, and npm pack --dry-run returning exit code 0 with the dist CLI/API files included, along with CLI search/build/explain outputs.
  • A concise contract probe was run against the built integration, validating browser-smoke, API search results, render/identify round trip with curated SVG and data URL, and that CLI render emits a real SVG.

View all artifacts

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (2)

  1. General comment

    P1 Partial Explain Prints Undefined

    • Bug
      • For SIDC 030310001412110000000000000000, node dist/cli.js explain <sidc> --json returns a valid partial decomposition without a name, but the plain-text CLI path prints the missing result.name directly. The first stdout line is the literal text undefined, followed by otherwise useful partial SIDC details.
    • Cause
      • src/cli.ts writes ${result.name} unconditionally in the plain-text runExplain branch even though partial explainSidc results do not include a name property.
    • Fix
      • Use a safe fallback heading for partial results, for example result.name ?? "Partial SIDC decomposition", or branch on result.coverage before rendering the heading.

    T-Rex Ran code and verified through T-Rex

  2. General comment

    P1 Partial Entity Lookup Misses Domains

    • Bug
      • explainSidc fails on renderable, non-curated variants of curated domain-level symbols. A neutral variant of the curated air fighter SIDC (130401000011010400000000000000) is renderable and preserves function ID 1101040000, but before the fix the partial explanation omitted the catalog-backed entity metadata and marked entity unknown despite the curated air catalog containing the same function ID.
    • Cause
      • buildPartialParts looked up functionEntityParts using getSymbolSetLabel(domain, metadata). For domain-level air symbols, getSymbolSetLabel returned undefined unless the metadata was unit/installation/activity, so the lookup key never matched catalog keys such as air:1101040000.
    • Fix
      • Return the normalized domain label from getSymbolSetLabel when the metadata is not a unit, installation, or activity. This allows partial lookups to use keys like air:1101040000 and resolve catalog-backed entity metadata for domain-level symbols.

    T-Rex Ran code and verified through T-Rex

Reviews (9): Last reviewed commit: "fix: clarify ambiguous build suggestions" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds curated symbol catalogs and land-unit fixture generation, moves the public SIDC API into dedicated modules, expands browser and CLI packaging, and updates tests and documentation for the new search, explain, render, build, and identify behavior.

Changes

Curated SIDC catalog and runtime updates

Layer / File(s) Summary
Catalog types and curated symbol sets
README.md, src/data/catalog/types.ts, src/data/catalog/air.ts, src/data/catalog/control-measures.ts, src/data/catalog/index.ts, src/data/catalog/land-equipment.ts, src/data/catalog/land-installations.ts, src/data/catalog/sea-subsurface.ts, src/data/catalog/sea-surface.ts, src/data/symbols.ts
Introduces shared catalog types, curated air/sea/land/control-measure symbol arrays, the combined curated export, and overview README wording.
Land-unit fixture generation
README.md, fixtures/curated-land-units.json, scripts/generate-curated-fixtures.mjs, src/data/catalog/land-units.ts
Adds the land-unit fixture source, generator, generated catalog module, and README fixture-generation guidance.
Public API types and normalization
README.md, src/types.ts, src/sidc.ts, src/milsymbol.ts, src/index.ts
Defines the exported SIDC, rendering, explanation, search, identification, and build types, plus SIDC normalization, metadata helpers, barrel re-exports, and API/browser usage documentation.
Build, explain, render, search, and identify logic
src/build.ts, src/explain.ts, src/render.ts, src/search.ts, src/identify.ts
Implements SIDC construction, curated and partial explanation, SVG rendering, symbol search, and SVG-based identification over the curated catalog.
Browser bundle packaging
package.json, scripts/browser-smoke.mjs
Adds browser smoke bundling, package metadata, and scripts for browser verification.
CLI command runner
src/cli.ts, test/cli.test.mjs
Adds the CLI entrypoint, command parsing, output and error handling, and CLI tests for search, explain, render, build, and error cases.
Core API behavior tests
test/sidc-kit.test.mjs
Expands the API test coverage for curated catalog round-trips, partial explanation output, symbol search ranking, SVG identification, and SIDC construction cases.
Tooling configuration
tsconfig.json
Removes declaration map output from the TypeScript configuration.

Sequence Diagram(s)

sequenceDiagram
  participant run
  participant parseArgs
  participant searchSymbols
  participant explainSidc
  participant renderSymbol
  participant buildSidc
  run->>parseArgs: parse argv
  alt search
    run->>searchSymbols: query terms and limit
  else explain
    run->>explainSidc: SIDC
  else render
    run->>renderSymbol: SIDC and render options
  else build
    run->>buildSidc: structured parts
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • the-Drunken-coder/sidc-kit#1 — Also evolves the core curated-SIDC API surface in src/index.ts, including renderSymbol, explainSidc, searchSymbols, and buildSidc.
  • the-Drunken-coder/sidc-kit#4 — Also changes renderSymbol() handling for curated versus non-curated 30-digit SIDCs and the related error flow.

I hopped through catalogs, neat and bright,
Curated symbols now dance just right.
I sniffed the CLI, the browser breeze,
And tucked my carrots into sidc leaves. 🐇
Hooray for neat new trails tonight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the PR’s main goal of integrating the SIDC Kit feature stack.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/integrate-feature-docs

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

…to codex/integrate-feature-docs

# Conflicts:
#	README.md
…dex/integrate-feature-docs

# Conflicts:
#	README.md
#	test/sidc-kit.test.mjs
…to codex/integrate-feature-docs

# Conflicts:
#	src/data/symbols.ts
#	test/sidc-kit.test.mjs
…o codex/integrate-feature-docs

# Conflicts:
#	README.md
#	package.json
#	src/data/symbols.ts
…ate-feature-docs

# Conflicts:
#	package-lock.json
#	package.json
… into codex/integrate-feature-docs

# Conflicts:
#	README.md
#	src/index.ts
#	test/sidc-kit.test.mjs
@the-Drunken-coder the-Drunken-coder changed the title docs: integrate feature README updates feat: integrate SIDC Kit feature stack Jun 25, 2026
@the-Drunken-coder

Copy link
Copy Markdown
Owner Author

@greptileai review

@the-Drunken-coder

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa6960f33b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts Outdated
Comment thread src/cli.ts
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/index.ts (1)

232-243: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

identifySymbol re-renders the full curated catalog on every call.

Each invocation calls renderSymbol(symbol.sidc, ...) for every curated symbol and then runs an O(L²) Levenshtein over SVG strings up to maxIdentifySvgInputLength (10k). The length-similarity gate helps, but rendering is repeated work that doesn't depend on the input. Consider memoizing normalized candidate SVGs per renderOptions to avoid re-rendering on each call.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/index.ts` around lines 232 - 243, `identifySymbol` is re-rendering every
curated symbol on each call, which repeats expensive work that only depends on
`renderOptions`. Cache or memoize the normalized SVG candidate for each
`symbol.sidc` within the `identifySymbol` flow (or a helper it uses) so repeated
invocations reuse precomputed `renderSymbol(...).svg` output instead of
recalculating it. Keep the existing `normalizeSvgInput`, `svgSimilarity`, and
threshold filtering logic intact, and make the cache key include the relevant
`renderOptions` state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 138-140: Remove the duplicated Coverage paragraph in README so the
section appears only once; keep the single paragraph about partial
decomposition, entity labels from curated function IDs, and status handling via
unknownFields, and delete the repeated copy of that text.

In `@src/cli.ts`:
- Around line 126-138: The text output path in the CLI currently assumes
explainSidc always returns a name, but partial results can have name undefined
and end up printing undefined. Update the explain command flow in the cli.ts
logic around explainSidc and writeOutput so the name line is only emitted when
result.name is present, and otherwise skip or substitute a clean fallback for
partial non-curated SIDCs. Add or update a CLI test for text mode on a
renderable non-curated SIDC to verify the output does not include undefined.

---

Nitpick comments:
In `@src/index.ts`:
- Around line 232-243: `identifySymbol` is re-rendering every curated symbol on
each call, which repeats expensive work that only depends on `renderOptions`.
Cache or memoize the normalized SVG candidate for each `symbol.sidc` within the
`identifySymbol` flow (or a helper it uses) so repeated invocations reuse
precomputed `renderSymbol(...).svg` output instead of recalculating it. Keep the
existing `normalizeSvgInput`, `svgSimilarity`, and threshold filtering logic
intact, and make the cache key include the relevant `renderOptions` state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7ee7d164-5add-4c9b-abe1-0ac48eb66731

📥 Commits

Reviewing files that changed from the base of the PR and between 3b6285b and fa6960f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (19)
  • README.md
  • fixtures/curated-land-units.json
  • package.json
  • scripts/browser-smoke.mjs
  • scripts/generate-curated-fixtures.mjs
  • src/cli.ts
  • src/data/catalog/air.ts
  • src/data/catalog/control-measures.ts
  • src/data/catalog/index.ts
  • src/data/catalog/land-equipment.ts
  • src/data/catalog/land-installations.ts
  • src/data/catalog/land-units.ts
  • src/data/catalog/sea-subsurface.ts
  • src/data/catalog/sea-surface.ts
  • src/data/catalog/types.ts
  • src/data/symbols.ts
  • src/index.ts
  • test/cli.test.mjs
  • test/sidc-kit.test.mjs

Comment thread README.md Outdated
Comment thread src/cli.ts
@the-Drunken-coder
the-Drunken-coder marked this pull request as ready for review June 26, 2026 08:41
@the-Drunken-coder

Copy link
Copy Markdown
Owner Author

@codex review

@the-Drunken-coder

Copy link
Copy Markdown
Owner Author

@greptile review

Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 408e1f9a6f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/identify.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/search.ts (1)

57-71: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Defer explainSymbol() until after filtering and limiting.

The current search path builds full explain results for every curated symbol, including zero-score entries and matches beyond limit. Score first, then materialize only returned results.

Proposed refactor
   return curatedSymbols
     .map((symbol, index) => {
       const score = scoreSymbol(symbol, terms, normalizedQuery);
       return {
         index,
-        result: {
-          ...explainSymbol(symbol),
-          score
-        }
+        score,
+        symbol
       };
     })
-    .filter(({ result }) => result.score > 0)
-    .sort((left, right) => right.result.score - left.result.score || left.index - right.index)
-    .map(({ result }) => result)
-    .slice(0, limit);
+    .filter(({ score }) => score > 0)
+    .sort((left, right) => right.score - left.score || left.index - right.index)
+    .slice(0, limit)
+    .map(({ score, symbol }) => ({
+      ...explainSymbol(symbol),
+      score
+    }));
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/search.ts` around lines 57 - 71, The search pipeline in `search` eagerly
calls `explainSymbol()` for every curated symbol before filtering and slicing,
which materializes unnecessary results. Update the flow so `scoreSymbol()` is
applied first, then filter and sort by score, apply the `limit`, and only then
call `explainSymbol()` on the final returned items. Keep the existing ordering
logic in `search` intact while moving the expensive materialization step to the
end.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/build.ts`:
- Around line 38-60: The ambiguity suggestion in buildAmbiguitySuggestion() is
too strong because formatPartList() can imply that any single missing key will
resolve the match. Update the wording so it clearly allows multiple required
discriminators, using the helpfulKeys list from hasVariation() without
suggesting one field is sufficient; keep the fallback message for cases where no
helpful keys exist and adjust the returned message text to be more conditional.

In `@src/identify.ts`:
- Around line 97-108: The SVG data URL decoding in decodeInlineSvgDataUrl
currently assumes every data:image/svg+xml payload is URI-encoded, so
base64-encoded SVGs are never normalized and identifySymbol() misses them.
Update decodeInlineSvgDataUrl to detect ;base64 payloads in addition to plain
encoded SVG data URLs, decode the payload appropriately before returning, and
keep the existing normalization path in normalizeSvgInput() working for both
formats.

---

Nitpick comments:
In `@src/search.ts`:
- Around line 57-71: The search pipeline in `search` eagerly calls
`explainSymbol()` for every curated symbol before filtering and slicing, which
materializes unnecessary results. Update the flow so `scoreSymbol()` is applied
first, then filter and sort by score, apply the `limit`, and only then call
`explainSymbol()` on the final returned items. Keep the existing ordering logic
in `search` intact while moving the expensive materialization step to the end.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc65ca0f-710e-42cb-b3c4-64b55b212087

📥 Commits

Reviewing files that changed from the base of the PR and between 2124ebf and 01e2ebe.

📒 Files selected for processing (12)
  • package.json
  • src/build.ts
  • src/explain.ts
  • src/identify.ts
  • src/index.ts
  • src/milsymbol.ts
  • src/render.ts
  • src/search.ts
  • src/sidc.ts
  • src/types.ts
  • test/sidc-kit.test.mjs
  • tsconfig.json
💤 Files with no reviewable changes (1)
  • tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/sidc-kit.test.mjs
  • package.json

Comment thread src/build.ts Outdated
Comment thread src/identify.ts
@the-Drunken-coder
the-Drunken-coder merged commit 7106767 into main Jun 26, 2026
3 checks passed
@the-Drunken-coder
the-Drunken-coder deleted the codex/integrate-feature-docs branch June 26, 2026 19:31
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