diff --git a/.gitignore b/.gitignore
index 1210cc70c..eb58f6ac8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,7 @@ pipeline_build_logs/*
.vscode/*
# Bazel symlinks — point into the local cache, machine-specific
-/bazel-*
\ No newline at end of file
+/bazel-*
+
+# Protobuf generated files
+**/definiton/gen/
diff --git a/Dockerfile b/Dockerfile
index d774eafef..969363a90 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,10 +1,11 @@
#
# Build stage
#
-FROM maven:3.8.3-openjdk-17 AS build
+FROM maven:3.9.6-eclipse-temurin-17 AS build
WORKDIR /home/app
COPY pipeline/pom.xml .
COPY pipeline/src ./src
+COPY apis/protobuf /home/apis/protobuf
RUN mvn clean package -DskipTests -Pmonitoring
#
diff --git a/apis/openapi-spec/pipeline-service.yaml b/apis/openapi-spec/pipeline-service.yaml
index 886fa1cab..fbfdff565 100644
--- a/apis/openapi-spec/pipeline-service.yaml
+++ b/apis/openapi-spec/pipeline-service.yaml
@@ -249,35 +249,32 @@ components:
properties:
id:
type: string
- format: uuid
name:
type: string
stages:
type: array
items:
$ref: "#/components/schemas/Stage"
- required:
- - name
- - stages
- Stage:
+ PipelineBuild:
type: object
properties:
- id:
+ currentState:
type: string
- format: uuid
- name:
+ enum:
+ - WAITING
+ - RUNNING
+ - SUCCESS
+ - FAILED
+ id:
type: string
- scriptType:
+ pipelineId:
type: string
- command:
+ pipelineName:
type: string
- stageOrder:
- type: integer
- format: int32
- required:
- - command
- - name
- - scriptType
+ stageBuilds:
+ type: array
+ items:
+ $ref: "#/components/schemas/StageBuild"
PipelineExecuteRequest:
type: object
properties:
@@ -286,17 +283,23 @@ components:
format: uuid
required:
- pipelineId
- PipelineBuild:
+ Stage:
type: object
properties:
+ command:
+ type: string
id:
type: string
- format: uuid
- pipelineId:
+ name:
type: string
- format: uuid
- pipelineName:
+ scriptType:
type: string
+ stageOrder:
+ type: integer
+ format: int32
+ StageBuild:
+ type: object
+ properties:
currentState:
type: string
enum:
@@ -304,35 +307,16 @@ components:
- RUNNING
- SUCCESS
- FAILED
- startedAt:
- type: string
- format: date-time
- stageBuilds:
- type: array
- items:
- $ref: "#/components/schemas/StageBuild"
- StageBuild:
- type: object
- properties:
+ - STOPPED
id:
type: string
- format: uuid
stageId:
type: string
- format: uuid
stageName:
type: string
stageOrder:
type: integer
format: int32
- currentState:
- type: string
- enum:
- - WAITING
- - RUNNING
- - SUCCESS
- - FAILED
- - STOPPED
securitySchemes:
bearerAuth:
type: http
diff --git a/apis/protobuf/BUILD.bazel b/apis/protobuf/BUILD.bazel
new file mode 100644
index 000000000..07a3840f1
--- /dev/null
+++ b/apis/protobuf/BUILD.bazel
@@ -0,0 +1,5 @@
+filegroup(
+ name = "protobuf_files",
+ srcs = glob(["**/*.proto"]),
+ visibility = ["//visibility:public"],
+)
\ No newline at end of file
diff --git a/apis/protobuf/buf.yaml b/apis/protobuf/buf.yaml
new file mode 100644
index 000000000..31ebbb9a2
--- /dev/null
+++ b/apis/protobuf/buf.yaml
@@ -0,0 +1 @@
+version: v2
\ No newline at end of file
diff --git a/apis/protobuf/definition/v1/pipeline_definition.proto b/apis/protobuf/definition/v1/pipeline_definition.proto
new file mode 100644
index 000000000..91d4c1c73
--- /dev/null
+++ b/apis/protobuf/definition/v1/pipeline_definition.proto
@@ -0,0 +1,23 @@
+syntax = "proto3";
+
+package definition.v1;
+
+option java_package = "com.autobuild.pipeline.definiton.gen.dto";
+option java_multiple_files = true;
+
+// option go_package = "";
+// go_multiple_files doesn't exist - Go always generates one file per proto file.
+
+message Stage {
+ string id = 1;
+ string name = 2;
+ string script_type = 3;
+ string command = 4;
+ int32 stage_order = 5;
+}
+
+message Pipeline {
+ string id = 1;
+ string name = 2;
+ repeated Stage stages = 3;
+}
\ No newline at end of file
diff --git a/apis/protobuf/execution/v1/pipeline_execution.proto b/apis/protobuf/execution/v1/pipeline_execution.proto
new file mode 100644
index 000000000..fe5b7d7bd
--- /dev/null
+++ b/apis/protobuf/execution/v1/pipeline_execution.proto
@@ -0,0 +1,49 @@
+syntax = "proto3";
+
+package execution.v1;
+
+import "google/protobuf/timestamp.proto";
+
+option java_package = "com.autobuild.pipeline.executor.gen.dto";
+option java_multiple_files = true;
+
+// option go_package = "";
+// go_multiple_files doesn't exist - Go always generates one file per proto file.
+
+enum PipelineExecutionState {
+ PIPELINE_WAITING = 0; // Pipeline is waiting to be executed.
+ PIPELINE_RUNNING = 1; // Pipeline execution has started.
+ PIPELINE_SUCCESS = 2; // Pipeline execution has finished and it succeeded.
+ PIPELINE_FAILED = 3; // Pipeline execution has finished and it failed.
+}
+
+enum StageExecutionState {
+ STAGE_WAITING = 0; // Stage is waiting to be executed.
+ STAGE_RUNNING = 1; // Stage execution has started.
+ STAGE_SUCCESS = 2; // Stage execution has finished and it succeeded.
+ STAGE_FAILED = 3; // Stage execution has finished and it failed.
+ STAGE_STOPPED = 4; // Stage execution stopped.
+}
+
+message StageBuild {
+ string id = 1;
+ string stage_id = 2;
+ string stage_name = 3;
+ StageExecutionState current_state = 4;
+ int32 stage_order = 5;
+}
+
+message PipelineBuild {
+ string id = 1;
+ string pipeline_id = 2;
+ string pipeline_name = 3;
+ PipelineExecutionState current_state = 4;
+ repeated StageBuild stage_builds = 5;
+ google.protobuf.Timestamp started_at = 6;
+}
+
+// A single line of output from a running stage, streamed back as it is produced.
+message StageLog {
+ string stage_build_id = 1;
+ string line = 2;
+}
diff --git a/autobuild-docs/setup/backend/local-backend-execution.md b/autobuild-docs/setup/backend/local-backend-execution.md
index 6982fdaac..32df47aef 100644
--- a/autobuild-docs/setup/backend/local-backend-execution.md
+++ b/autobuild-docs/setup/backend/local-backend-execution.md
@@ -4,4 +4,15 @@
1. Locate [backend launch.json](https://github.com/SuvabrataChowdhury/AutoBuild/blob/launch-json-template/pipeline/.vscode/launch.json.template) and rename it to just `launch.json`.
2. From VS Code `Run and Debug` (keybind SHIFT+CMD+D for Mac) select `AutoBuild: Local` and run the backend service in debug mode.

- Ensure the application is running fine by hitting the endpoints through bruno.
\ No newline at end of file
+ Ensure the application is running fine by hitting the endpoints through bruno.
+
+
+3. [Optional] To generate Protobuf classes locally:
+ From the `pipeline/` directory, run: `mvn compile -s maven-settings.xml`
+ Without `-s maven-settings.xml`, Maven falls back to repository mentioned at `~/.m2/repository/settings.xml` and might fail if it does not have the necessary dependencies. Mentioning it like that ensures the dependencies are pulled from open maven repository.
+ (The files are generated at the `generate-sources` and writes the Java files into target/generated-sources/. Then compile picks them up alongside your hand-written code and compiles everything together.)
+4. Recommended VS Code extension for .proto files:
+ **Buf** (`bufbuild.vscode-buf`) — syntax highlighting and linting
+ https://marketplace.visualstudio.com/items?itemName=bufbuild.vscode-buf
+5. To understand Protocol Buffers (the format used for DTO generation):
+ Protocol Buffers Crash Course — https://youtu.be/46O73On0gyI
diff --git a/autobuild-docs/setup/backend/running-backend-containers.md b/autobuild-docs/setup/backend/running-backend-containers.md
index 2d73167a3..1e529dc9a 100644
--- a/autobuild-docs/setup/backend/running-backend-containers.md
+++ b/autobuild-docs/setup/backend/running-backend-containers.md
@@ -51,3 +51,7 @@ docker compose -p autobuild down
docker compose down -v
```
> Note: this will delete all persisted volumes including database data, Grafana dashboards, Loki logs, and Prometheus metrics.
+
+## Protobuf
+
+Proto classes are auto-generated during `docker build` — Maven runs the protobuf compiler as part of the build, so no separate step is needed.
diff --git a/pipeline/BUILD.bazel b/pipeline/BUILD.bazel
index c2f613b42..427ad06d5 100644
--- a/pipeline/BUILD.bazel
+++ b/pipeline/BUILD.bazel
@@ -3,9 +3,9 @@ load("@rules_shell//shell:sh_test.bzl", "sh_test")
# Inputs Bazel tracks for cache invalidation — if none of these change,
# both targets below are skipped entirely (cache hit).
_SRCS = glob(
- ["src/**", "pom.xml", "checkstyle.xml"],
+ ["src/**", "pom.xml", "checkstyle.xml", "maven-settings.xml"],
exclude = ["target/**"],
-)
+) + ["//apis/protobuf:protobuf_files"]
# Runs the full Maven test suite.
# Run with: bazel test //pipeline:test
@@ -13,7 +13,7 @@ sh_test(
name = "test",
srcs = ["run_tests.sh"],
data = _SRCS,
- tags = [],
+ tags = ["local"],
)
# Generates the OpenAPI spec by starting the app and hitting /v3/api-docs.yaml.
diff --git a/pipeline/maven-settings.xml b/pipeline/maven-settings.xml
new file mode 100644
index 000000000..5d17a89b4
--- /dev/null
+++ b/pipeline/maven-settings.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/pipeline/pom.xml b/pipeline/pom.xml
index 933f89e08..b6abdaf00 100644
--- a/pipeline/pom.xml
+++ b/pipeline/pom.xml
@@ -28,6 +28,7 @@
17
+ 4.29.3
@@ -156,6 +157,18 @@
spring-boot-starter-graphql
+
+ com.google.protobuf
+ protobuf-java
+ ${protobuf.version}
+
+
+
+ com.google.protobuf
+ protobuf-java-util
+ ${protobuf.version}
+
+
@@ -202,6 +215,7 @@
UTF-8
true
true
+ true
@@ -224,6 +238,9 @@
0.8.15
+
+ com/autobuild/pipeline/**/gen/**
+
BUNDLE
@@ -261,8 +278,31 @@
check
+
+ ${skipTests}
+
+
+
+ io.github.ascopes
+ protobuf-maven-plugin
+ 5.1.11
+
+
+ ${protobuf.version}
+
+
+ ${project.basedir}/../apis/protobuf
+
+
+
+
+
+ generate
+
+
+
diff --git a/pipeline/run_generate_openapi.sh b/pipeline/run_generate_openapi.sh
index 3ebf78d79..f76c203b5 100755
--- a/pipeline/run_generate_openapi.sh
+++ b/pipeline/run_generate_openapi.sh
@@ -2,4 +2,4 @@
set -euo pipefail
cd "./pipeline/"
-mvn --batch-mode verify -P integration-test -DskipTests
+mvn --batch-mode -s maven-settings.xml verify -P integration-test -DskipTests
diff --git a/pipeline/run_tests.sh b/pipeline/run_tests.sh
index ef8f9120f..05a3b474e 100755
--- a/pipeline/run_tests.sh
+++ b/pipeline/run_tests.sh
@@ -2,4 +2,4 @@
set -euo pipefail
cd "./pipeline/"
-mvn --batch-mode clean verify
+mvn --batch-mode -s maven-settings.xml clean verify
diff --git a/pipeline/src/main/java/com/autobuild/pipeline/configuration/MapperConfig.java b/pipeline/src/main/java/com/autobuild/pipeline/configuration/MapperConfig.java
deleted file mode 100644
index 87588b57d..000000000
--- a/pipeline/src/main/java/com/autobuild/pipeline/configuration/MapperConfig.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.autobuild.pipeline.configuration;
-
-import org.modelmapper.ModelMapper;
-import org.modelmapper.TypeMap;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import com.autobuild.pipeline.definiton.dto.PipelineDTO;
-import com.autobuild.pipeline.definiton.dto.StageDTO;
-import com.autobuild.pipeline.definiton.entity.Pipeline;
-import com.autobuild.pipeline.definiton.entity.Stage;
-import com.autobuild.pipeline.executor.dto.PipelineBuildDTO;
-import com.autobuild.pipeline.executor.dto.StageBuildDTO;
-import com.autobuild.pipeline.executor.entity.PipelineBuild;
-import com.autobuild.pipeline.executor.entity.StageBuild;
-
-/**
- * Bean Configurations for the application.
- *
- * @author Suvabrata Chowdhury
- */
-
-@Configuration
-public class MapperConfig {
- @Bean
- public ModelMapper getModelMapper() {
- ModelMapper mapper = new ModelMapper();
-
- setStageMappings(mapper);
- setPipelineMapping(mapper);
-
- setStageBuildMappings(mapper);
- setPipelineBuildMappings(mapper);
-
- return mapper;
- }
-
- private void setStageMappings(ModelMapper mapper) {
- setStageDTOEntityMapping(mapper);
- setStageEntityDTOMapping(mapper);
- }
-
- private void setStageDTOEntityMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(StageDTO.class, Stage.class);
- typeMapper.addMapping(StageDTO::getId, Stage::setId);
- typeMapper.addMapping(StageDTO::getName, Stage::setName);
- typeMapper.addMapping(StageDTO::getScriptType, Stage::setScriptType);
- }
-
- private void setStageEntityDTOMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(Stage.class, StageDTO.class);
- typeMapper.addMapping(Stage::getId, StageDTO::setId);
- typeMapper.addMapping(Stage::getName, StageDTO::setName);
- typeMapper.addMapping(Stage::getScriptType, StageDTO::setScriptType);
- }
-
- private void setPipelineMapping(ModelMapper mapper) {
- setPipelineDTOEntityMapping(mapper);
- setPipelineEntityDTOMapping(mapper);
- }
-
- private void setPipelineDTOEntityMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(PipelineDTO.class, Pipeline.class);
- typeMapper.addMapping(PipelineDTO::getId, Pipeline::setId);
- typeMapper.addMapping(PipelineDTO::getName, Pipeline::setName);
- }
-
- private void setPipelineEntityDTOMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(Pipeline.class, PipelineDTO.class);
- typeMapper.addMapping(Pipeline::getName, PipelineDTO::setName);
- typeMapper.addMapping(Pipeline::getId, PipelineDTO::setId);
- }
-
- private void setStageBuildMappings(ModelMapper mapper) {
- setStageBuildEntityDTOMapping(mapper);
- setStageBuildDTOEntityMapping(mapper);
- }
-
- private void setStageBuildEntityDTOMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(StageBuild.class, StageBuildDTO.class);
- typeMapper.addMapping(StageBuild::getId, StageBuildDTO::setId);
- typeMapper.addMapping(stageBuild -> stageBuild.getStage().getId(), StageBuildDTO::setStageId);
- typeMapper.addMapping(stageBuild -> stageBuild.getStage().getName(), StageBuildDTO::setStageName);
- typeMapper.addMapping(stageBuild -> stageBuild.getStage().getStageOrder(), StageBuildDTO::setStageOrder);
- typeMapper.addMapping(StageBuild::getCurrentState, StageBuildDTO::setCurrentState);
- }
-
- private void setStageBuildDTOEntityMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(StageBuildDTO.class, StageBuild.class);
- typeMapper.addMapping(StageBuildDTO::getId, StageBuild::setId);
- typeMapper.addMapping(StageBuildDTO::getCurrentState, StageBuild::setCurrentState);
- }
-
- private void setPipelineBuildMappings(ModelMapper mapper) {
- setPipelineBuildEntityDTOMapping(mapper);
- setPipelineBuildDTOEntityMapping(mapper);
- }
-
- private void setPipelineBuildEntityDTOMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(PipelineBuild.class,
- PipelineBuildDTO.class);
- typeMapper.addMapping(PipelineBuild::getId, PipelineBuildDTO::setId);
- typeMapper.addMapping(pipelineBuild -> pipelineBuild.getPipeline().getId(), PipelineBuildDTO::setPipelineId);
- typeMapper.addMapping(pipelineBuild -> pipelineBuild.getPipeline().getName(),
- PipelineBuildDTO::setPipelineName);
- typeMapper.addMapping(PipelineBuild::getCurrentState, PipelineBuildDTO::setCurrentState);
- typeMapper.addMapping(PipelineBuild::getStartedAt, PipelineBuildDTO::setStartedAt);
- }
-
- private void setPipelineBuildDTOEntityMapping(ModelMapper mapper) {
- TypeMap typeMapper = mapper.createTypeMap(PipelineBuildDTO.class,
- PipelineBuild.class);
- typeMapper.addMapping(PipelineBuildDTO::getId, PipelineBuild::setId);
- typeMapper.addMapping(PipelineBuildDTO::getCurrentState, PipelineBuild::setCurrentState);
- }
-}
diff --git a/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufConfig.java b/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufConfig.java
new file mode 100644
index 000000000..f595228b2
--- /dev/null
+++ b/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufConfig.java
@@ -0,0 +1,54 @@
+package com.autobuild.pipeline.configuration;
+
+import java.io.IOException;
+
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.protobuf.ProtobufJsonFormatHttpMessageConverter;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.google.protobuf.Message;
+import com.google.protobuf.util.JsonFormat;
+
+/**
+ * Configures protobuf serialization and deserialization for Spring MVC.
+ *
+ * {@link org.springframework.http.converter.protobuf.ProtobufJsonFormatHttpMessageConverter}
+ * is registered read-only so Jackson handles all serialization. The Jackson customizer
+ * strips proto enum prefixes (PIPELINE_RUNNING → RUNNING) to match the OpenAPI spec.
+ */
+@Configuration
+public class ProtobufConfig {
+
+ // Read-only: handles JSON deserialization of proto request bodies.
+ // canWrite is disabled so Jackson handles all serialization — this allows
+ // the Jackson customizer below to strip enum prefixes (PIPELINE_RUNNING → RUNNING).
+ @Bean
+ public ProtobufJsonFormatHttpMessageConverter protobufJsonFormatHttpMessageConverter() {
+ return new ProtobufJsonFormatHttpMessageConverter() {
+ @Override
+ public boolean canWrite(Class> clazz, MediaType mediaType) {
+ return false;
+ }
+ };
+ }
+
+ @Bean
+ public Jackson2ObjectMapperBuilderCustomizer protobufJacksonCustomizer() {
+ return builder -> builder.serializerByType(Message.class, new JsonSerializer() {
+ @Override
+ public void serialize(Message message, JsonGenerator gen, SerializerProvider serializers)
+ throws IOException {
+ String json = JsonFormat.printer().omittingInsignificantWhitespace().print(message);
+ // Strip enum prefixes so the JSON matches the OpenAPI spec:
+ // PIPELINE_RUNNING → RUNNING, STAGE_RUNNING → RUNNING
+ json = json.replaceAll("\"(PIPELINE_|STAGE_)([A-Z_]+)\"", "\"$2\"");
+ gen.writeRawValue(json);
+ }
+ });
+ }
+}
diff --git a/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java b/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java
new file mode 100644
index 000000000..b74106272
--- /dev/null
+++ b/pipeline/src/main/java/com/autobuild/pipeline/configuration/ProtobufOpenApiCustomizer.java
@@ -0,0 +1,119 @@
+package com.autobuild.pipeline.configuration;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.springdoc.core.customizers.OpenApiCustomizer;
+import org.springframework.stereotype.Component;
+
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.media.Schema;
+
+/**
+ * Cleans up the generated OpenAPI spec from proto internals.
+ *
+ * Proto-generated classes expose many framework internals (Descriptor, ByteString, Parser, etc.)
+ * via reflection. Springdoc picks these up and adds them to the spec. Problems caused:
+ * 1. Non-determinism: HashMap iteration order changes each JVM run → CI "spec out of sync" fails.
+ * 2. Wrong field names: proto uses getStageBuildsList() → "stageBuildsList"; frontend expects "stageBuilds".
+ * 3. Prefixed enum values: proto uses PIPELINE_SUCCESS, STAGE_SUCCESS; frontend expects SUCCESS.
+ *
+ * This customizer runs after spec generation and fixes all three.
+ */
+@Component
+public class ProtobufOpenApiCustomizer implements OpenApiCustomizer {
+
+ private static final Set KEEP_SCHEMAS = Set.of(
+ "Pipeline",
+ "PipelineBuild",
+ "PipelineExecuteRequest",
+ "Stage",
+ "StageBuild"
+ );
+
+ // Only the business fields from the .proto definitions (proto snake_case → Java camelCase).
+ private static final Map> SCHEMA_ALLOWED_PROPERTIES = Map.of(
+ "Pipeline", Set.of("id", "name", "stagesList"),
+ "Stage", Set.of("id", "name", "scriptType", "stageOrder", "command"),
+ "PipelineBuild", Set.of("id", "pipelineId", "pipelineName", "currentState", "stageBuildsList"),
+ "StageBuild", Set.of("id", "stageId", "stageName", "stageOrder", "currentState")
+ );
+
+ // Proto list accessors use a "List" suffix — rename them to clean API names for the frontend.
+ private static final Map> PROPERTY_RENAMES = Map.of(
+ "Pipeline", Map.of("stagesList", "stages"),
+ "PipelineBuild", Map.of("stageBuildsList", "stageBuilds")
+ );
+
+ // Proto enums include a package prefix (PIPELINE_, STAGE_) and an UNRECOGNIZED catch-all.
+ // Strip the prefix and remove UNRECOGNIZED so the frontend sees SUCCESS not PIPELINE_SUCCESS.
+ private static final Map> ENUM_PREFIXES = Map.of(
+ "PipelineBuild", Map.of("currentState", "PIPELINE_"),
+ "StageBuild", Map.of("currentState", "STAGE_")
+ );
+
+ @Override
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public void customise(OpenAPI openApi) {
+ if (openApi.getComponents() == null || openApi.getComponents().getSchemas() == null) {
+ return;
+ }
+
+ Map schemas = openApi.getComponents().getSchemas();
+
+ // Step 1: remove all proto internal top-level schemas
+ schemas.entrySet().removeIf(entry -> !KEEP_SCHEMAS.contains(entry.getKey()));
+
+ // Step 2: strip proto-internal properties, keep only declared business fields
+ schemas.forEach((name, schema) -> {
+ Set allowedProps = SCHEMA_ALLOWED_PROPERTIES.get(name);
+ if (allowedProps != null && schema.getProperties() != null) {
+ Map props = (Map) schema.getProperties();
+ props.entrySet().removeIf(e -> !allowedProps.contains(e.getKey()));
+ }
+ });
+
+ // Step 3: rename proto list accessor names to clean frontend-facing names
+ schemas.forEach((schemaName, schema) -> {
+ Map renames = PROPERTY_RENAMES.get(schemaName);
+ if (renames != null && schema.getProperties() != null) {
+ Map props = (Map) schema.getProperties();
+ renames.forEach((oldName, newName) -> {
+ Object val = props.remove(oldName);
+ if (val != null) {
+ props.put(newName, val);
+ }
+ });
+ }
+ });
+
+ // Step 4: strip proto enum prefixes and remove UNRECOGNIZED catch-all value
+ schemas.forEach((schemaName, schema) -> {
+ Map enumPrefixes = ENUM_PREFIXES.get(schemaName);
+ if (enumPrefixes != null && schema.getProperties() != null) {
+ Map props = (Map) schema.getProperties();
+ enumPrefixes.forEach((fieldName, prefix) -> {
+ Schema> fieldSchema = props.get(fieldName);
+ if (fieldSchema != null && fieldSchema.getEnum() != null) {
+ List