Skip to content

Run VSUM builds asynchronously and cache artifacts per input fingerprint (#334) - #338

Merged
C0dE-l3eAkeR merged 4 commits into
developfrom
334-async-vsum-builds
Oct 5, 2026
Merged

C0dE-l3eAkeR merged 4 commits into
developfrom
334-async-vsum-builds

Conversation

@C0dE-l3eAkeR

@C0dE-l3eAkeR C0dE-l3eAkeR commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #334

Builds are now background jobs with a fingerprint cache, so downloading the same VSUM twice no longer rebuilds it, and the request that starts a build returns immediately.

API

Endpoint What it does
POST /api/v1/vsums/{id}/builds?force=false Starts a build → 202, or returns an up-to-date / already running build of the same inputs → 200
GET /api/v1/vsums/{id}/builds History, newest first (pageNumber, pageSize)
GET /api/v1/vsums/{id}/builds/{buildId} QUEUED / RUNNING / SUCCEEDED / FAILED, timestamps, setup-service error
GET /api/v1/vsums/{id}/builds/{buildId}/artifact The JAR
GET /api/v1/vsums/{id}/builds/{buildId}/bundle The deployment bundle (JAR + launchers + Dockerfile + compose)

All require VSUM membership, same as getJarfat today. The existing GET /build/check, /build/artifact and /build/bundle still work unchanged for the frontend — they're now blocking wrappers over the same pipeline, so they get the cache too — and are marked deprecated.

  • Frontend: it still uses the blocking endpoints. Showing build status/history needs a Vitruv-UI-Methodologist issue.
  • Multiple backend instances: the restart hook would fail builds another instance is running. Fine for the current single-instance deployment.
  • Pre-existing leak: every other FileStorage deletion also leaves its large object behind (12 orphans in my local DB before this work). Worth its own issue — e.g. the lo extension's lo_manage trigger would cover all of them.

Every download used to rebuild the VSUM in the setup-service inside the HTTP
request: no caching since the fingerprint cache was dropped in 5e7b241, a
300 s blocking call, and the whole artifact buffered per request.

Builds are now jobs:

- POST /api/v1/vsums/{id}/builds starts one (202) or returns an up-to-date
  or in-flight build of the same inputs (200); force=true always builds.
- GET .../builds, .../builds/{buildId}, .../builds/{buildId}/artifact and
  .../builds/{buildId}/bundle expose history, status and downloads.
- Inputs are fingerprinted (SHA-256 over role, name and bytes of every
  ecore, genmodel and reaction file, independent of relation order).
- Builds run on a bounded executor (vsum.build.pool-size/queue-capacity),
  one per VSUM at a time; a full queue fails the build instead of piling up.
  A build whose twin succeeded while it was queued adopts that artifact, so
  concurrent requests for the same inputs cost one setup-service call.
- Artifacts are FileStorage rows of the new type VSUM_JAR, referenced from
  the new vsum_build table (V16). Only the newest vsum.build.retention-keep
  artifacts per VSUM are kept; their PostgreSQL large objects are unlinked
  on deletion, otherwise every dropped JAR would stay in pg_largeobject.
- Builds left QUEUED/RUNNING by a shutdown are failed on startup.
- The existing GET /build/check, /build/artifact and /build/bundle keep
  working as blocking wrappers over the same pipeline (so they are cached
  too) and are marked deprecated.

Input collection moved from VsumService into VsumBuildInputCollector
unchanged; its tests moved along. Builds are removed with their VSUM by the
existing 30-day purge.

Closes #334
Use hasToString for media types (S5838), chain assertions on one subject
(S5853), and resolve build ids before assertThatThrownBy so each lambda
holds a single call that can throw (S5778).
@C0dE-l3eAkeR C0dE-l3eAkeR self-assigned this Sep 24, 2026
Add the missing Javadoc to VsumBuildMapper, VsumBuildRepository and the
VsumBuildService constructor (MissingJavadocType/MissingJavadocMethod), and
fix VariableDeclarationUsageDistance in two tests: declare the VSUM where it
is used, and mark the arranged builds final where they must exist before the
call under test.
@uiysg

uiysg commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Is this PR ready to review?

@C0dE-l3eAkeR

Copy link
Copy Markdown
Contributor Author

Is this PR ready to review?

yes

@uiysg
uiysg self-requested a review September 28, 2026 08:52
@uiysg

uiysg commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Is this Pr ready to merge?

@C0dE-l3eAkeR
C0dE-l3eAkeR merged commit f5adc66 into develop Oct 5, 2026
3 checks passed
@C0dE-l3eAkeR
C0dE-l3eAkeR deleted the 334-async-vsum-builds branch October 5, 2026 05:53
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.

2 participants