Skip to content

feat(calm-hub): add versioned document endpoints (Issue #2982) - #3002

Draft
101Steeps wants to merge 4 commits into
finos:mainfrom
101Steeps:feat/calm-hub-document-endpoint-2982
Draft

feat(calm-hub): add versioned document endpoints (Issue #2982)#3002
101Steeps wants to merge 4 commits into
finos:mainfrom
101Steeps:feat/calm-hub-document-endpoint-2982

Conversation

@101Steeps

@101Steeps 101Steeps commented Aug 19, 2026

Copy link
Copy Markdown

Description

Implements the spec described in Issue #2982 as a part of Issue #2981

Excerpt from Issue #2982:
Add a first-class Document resource to CALM Hub so a document (Markdown + structured frontmatter) can be created, retrieved, and updated by document type. This is the storage/API foundation for the Documents PoC and implements the decision in #2791 (documents are first-class, not decorators) using the document shape agreed in #2866.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🎨 Code style/formatting changes
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Test additions or updates
  • 🔧 Chore (maintenance, dependencies, CI, etc.)

Affected Components

  • CLI (cli/)
  • Schema (calm/)
  • CALM AI (calm-ai/)
  • CALM Hub (calm-hub/)
  • CALM Hub UI (calm-hub-ui/)
  • CALM Server (calm-server/)
  • CALM Widgets (calm-widgets/)
  • Documentation (docs/)
  • Shared (shared/)
  • VS Code Extension (calm-plugins/vscode/)
  • Dependencies
  • CI/CD

Commit Message Format ✅

Testing

  • I have tested my changes locally

  • I have added/updated unit tests

  • All existing tests pass

  • npm run build passed.

  • npm test -- --coverage passed.

  • npm run lint passed with 0 errors. The command reported 11 warnings.

  • ./mvnw clean install -Ddependency-check.skip=true passed.

  • calm-hub unit tests passed: 2,772 tests.

  • calm-hub integration tests passed: 537 tests.

  • JaCoCo coverage checks passed for calm-hub.

  • Swagger testing passed. The document create endpoint returned 201 Created.

  • The Swagger response included the versioned Location header.

  • Swagger testing confirmed a successful document create request.

  • The endpoint returned 201 Created.

  • The response included a versioned Location header.

  • The audit log recorded CREATE, DOCUMENT, swaggeraudit, document ID 1, version 1.0.0, and SUCCESS.

Swagger / Quarkus Testing
Swagger endpoint discovery: Document endpoints for listing, creating, retrieving, and versioning narrative documents.
image

Swagger manual test: Creating a knowledge document returned 201 Created with a versioned Location header.
image

Checklist

  • My commits follow the conventional commit format
  • I have updated documentation if necessary
  • I have added tests for my changes (if applicable)
  • My changes follow the project's coding standards

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 19, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: 101Steeps / name: 101Steeps (9d3e9c1)

@github-actions github-actions Bot added the calm-hub Affects `calm-hub` label Aug 19, 2026
@101Steeps
101Steeps marked this pull request as ready for review August 19, 2026 13:42
@101Steeps
101Steeps marked this pull request as draft August 19, 2026 13:42
@101Steeps
101Steeps force-pushed the feat/calm-hub-document-endpoint-2982 branch from 9d3e9c1 to d1ce321 Compare August 19, 2026 14:17
/** Temporary Java-side POC contract pending a published shared contract. */
private final DocumentService documentService;
public DocumentResource(DocumentService documentService) { this.documentService = documentService; }
@GET @Path("{namespace}/documents/{documentType}") @PermissionsAllowed(CalmHubScopes.READ)

@LeighFinegold LeighFinegold Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The formatting here is very dense compared to the rest of the codebase. Here's the style to follow -PatternResource.java L55–76 shows a single endpoint with:

  • Each annotation (@GET, @Path, @Produces, @Operation, @PermissionsAllowed) on its own line
  • @Operation with both summary and description fields
  • Method params on separate lines
  • Try/catch bodies expanded, not single-line
  • Logger field (L44) and logging in each catch block (L73)

Could you reformat the new resource to match?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated 'DocumentResource' to follow style in PatternResource

}
private boolean hasMappingFrontmatter(String markdown) {
if (markdown == null) return false;
java.util.regex.Matcher frontmatter = java.util.regex.Pattern

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The frontmatter regex is compiled on every call - Pattern.compile() is relatively expensive and the compiled Pattern is thread-safe and immutable, so it only needs to happen once.

I noticed VERSION_PATTERN in MongoDocumentStore and NitriteDocumentStore are already done correctly as static fields - same approach should be applied here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved the frontmatter regex to the static fields so 'DocumentResource' only compiles the pattern once and resuses for each request

@@ -0,0 +1,3 @@
package org.finos.calm.store.producer;

@LeighFinegold LeighFinegold Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@101Steeps - per ask, did a first scan through before making PR beyond draft.

Think you need to do run the file formatter :)

Have you had a chance to read through calm-hub/AGENTS.md? It covers the codebase conventions we follow. Might be worth checking your agent has this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed the files to match the repo and calm hub formatting conventions. I've read through the Agents.md for Calm-hub now and made sure its now included in the review step.

public static final String VERSION_REGEX = "^(0|[1-9][0-9]*)[-.]?(0|[1-9][0-9]*)[-.]?(0|[1-9][0-9]*)$";
public static final String VERSION_MESSAGE = "version must match pattern '^(0|[1-9][0-9]*)[-.]?(0|[1-9][0-9]*)[-.]?(0|[1-9][0-9]*)$'";
/** Temporary POC types pending a shared Java-consumable document contract. */
public static final Set<String> DOCUMENT_TYPES = Set.of("pattern", "architecture", "interface", "flow", "control", "schema", "timeline", "adr");

@LeighFinegold LeighFinegold Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the allow-list for /documents/{documentType} - I don't think this is the right list. These are the existing CALM resource types which already have their own dedicated endpoints (/patterns, /architectures, etc.). This should be narrative document types like knowledge, sad — no?

Probably worth calling it NARRATIVE_DOCUMENT_TYPES although variable naming was never my forte

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added 'NARRATIVE_DOCUMENT_TYPES' (happy to use this variable name), with supported values 'knowledge' and 'sad'. Document endpoints reject unsupported narrative document types. I've added additional test evidence to the PR description to show Swagger and the Quarkus audit log for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calm-hub Affects `calm-hub`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants