finos / finos/architecture-as-code

calm-hub: extract a shared base for the read-only GitHub stores

Open
#3,079 0 comments 0 reactions 0 assignees View on GitHub
calm-hub
Dominant language
TypeScript
Stars
399
Forks
138
Avg merge
2d 14h
Merged PRs (30d)
37

Description

`verifyNamespace`, `findEntryById`, the `WRITE_UNSUPPORTED` constant, and the SHA-vs-local-file read block are copy-pasted across 8-12 GitHub store classes (Adr, Architecture, BuildingBlock, Control, Decorator, Flow, Interface, Pattern, Standard, Timeline). Already drifted — `GitHubPatternStore` inlines two error strings its siblings hoisted into constants.

Same duplicated `findEntryById` lookup derives its public ID as `uniqueId().hashCode() & 0x7FFFFFFF` at ~21 sites. `uniqueId` is content-controlled — a crafted filename in a synced repo can collide a resource ID — and `.filter(...).findFirst()` has no collision detection.

**Fix**: extract a shared base (or helper class, following `GitHubFileReader`'s pattern) that each store delegates to, with a collision-safe ID scheme in the shared lookup. Land before the pattern spreads to another store.

(jpgough-ms review thread on GitHubAdrStore.java:87, #3066.)

Contributor guide

Open the contributing guide

Research direction

Start with GitHubAdrStore.java:87 and compare the listed GitHub store classes, especially GitHubPatternStore. Read GitHubFileReader for the existing helper pattern, then trace the duplicated findEntryById lookup and its uniqueId().hashCode() ID derivation. Done means the stores delegate shared read behavior, constants and errors no longer drift, and lookup handles ID collisions safely.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.