Skip to content

feat: Noise Generation Wrapper Service - #20

Merged
plc-dev merged 64 commits into
masterfrom
codex/noise-generation-wrapper-service
Jul 26, 2026
Merged

feat: Noise Generation Wrapper Service#20
plc-dev merged 64 commits into
masterfrom
codex/noise-generation-wrapper-service

Conversation

@synapp009

Copy link
Copy Markdown
Collaborator

Adds noise-generation-wrapper-service for issue #9.

The service wraps the fastnoise-lite and noise_rs Rust libraries into a unified REST API and exposes OpenAPI, CLI, Docker, tests, and CI support. It runs fully self-contained — no external credentials, API keys, or cloud dependencies required.

synapp009 added 30 commits July 14, 2026 10:07
…oml, implement CLI for noise generation, and enhance main application structure
…d linting, implement Perlin noise generation, and create README and Docker Compose files
…rithms, update OpenAPI specification, and implement integration tests
…ithms, update Dockerfile dependencies, and implement integration tests
…algorithms support, usage examples, and deployment instructions
…ng to 8000, add development and production Docker Compose files, and streamline test command.
…ture, add tests for CLI parsing, and implement CI workflow for build and testing
…service and update port mapping in development setup
- Upgraded `clap` from version 3.2 to 4.5 in `Cargo.toml` for improved CLI functionality.
- Added `Debug` trait to `Cli` and `Commands` structs for better debugging output.
- Introduced new noise generation algorithms: `OpenSimplex` and `Worley`.
- Refactored `generate_noise` function to streamline algorithm matching and response creation.
- Updated `generate_cellular_noise` and `generate_opensimplex2_noise` functions to utilize new noise algorithms.
- Adjusted tests to reflect changes in CLI structure and functionality.
…rvice

- Updated `axum` to version 0.7.5 and `tokio` to version 1.36 in Cargo.toml.
- Changed `clap` version to 4 and updated `fastnoise-lite` to 1.1.1.
- Upgraded Rust base image in Dockerfile to 1.85-slim-bookworm.
- Adjusted port mapping in docker-compose files for development (8000:8000) and production (8000:3000).
…nagement

- Added UUID dependency to Cargo.toml for unique field identification.
- Introduced AppState struct to manage shared state using Arc and Mutex.
- Modified generate_noise function to create and store noise fields with unique IDs.
- Updated get_noise function to retrieve noise fields by their unique IDs.
- Enhanced integration tests to validate noise field generation and retrieval.
@plc-dev plc-dev linked an issue Jul 20, 2026 that may be closed by this pull request
5 tasks
Comment thread test_all_algorithms.sh Outdated
Comment thread services/noise-generation-service/README.md Outdated
Comment thread services/noise-generation-service/README.md
Comment thread services/noise-generation-service/README.md Outdated
…tate management, and enhance response validation

- Removed unused CLI commands for retrieving noise fields and points.
- Simplified state management by eliminating unnecessary AppState structure.
- Updated noise generation logic to directly return results without state dependencies.
- Enhanced integration tests to validate the new response structure, including id, status, algorithm, and data.
- Added performance tests for medium and large grid generation.
- Updated smoke tests to validate the complete response format for all algorithms.
Comment thread services/noise-generation-service/src/lib.rs Outdated
Comment thread services/noise-generation-service/src/lib.rs Outdated
Comment thread services/noise-generation-service/src/lib.rs Outdated
Comment thread services/noise-generation-service/README.md
Comment thread services/noise-generation-service/README.md Outdated

@plc-dev plc-dev left a comment

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.

After a closer look at the code, there's still a lot of structural issues, esp. regarding code quality and interface- as well as documentation-mismatches.

Comment thread services/noise-generation-service/src/cli.rs Outdated
Comment thread services/noise-generation-service/src/cli.rs Outdated
Comment thread services/noise-generation-service/src/cli.rs
Comment thread services/noise-generation-service/src/cli.rs Outdated
Comment thread services/noise-generation-service/src/cli.rs Outdated
Comment thread services/noise-generation-service/src/lib.rs Outdated
Comment thread services/noise-generation-service/src/lib.rs Outdated
Comment thread services/noise-generation-service/src/lib.rs Outdated
Comment thread services/noise-generation-service/src/lib.rs
Comment thread services/noise-generation-service/src/lib.rs Outdated
…cation

- Replace algorithm/format String types with clap::ValueEnum enums
- Align CLI with OpenAPI: --size, --params JSON, remove stale Png
- Reduce duplication: fill_2d helpers, shared algorithm_name/size methods
- Fix: random seed, normalize wired up, RidgedMultiParams persistence
- No subcommand shows help (no implicit server start)
- README: 14→15 algorithms, tests updated
…s via /v1/algorithms

Three core changes to make noise field generation fully reproducible:

### 1. params_used in POST /v1/noise response (critical bug fix)

- Add  field to
- Create  enum resolved exactly once per request,
  used for BOTH generation and the response echo
- Fix critical seed-mismatch bug: previously  was called
  independently in  AND , producing
  different random seeds when none was provided by the caller
- Add default constants for jitter, strength, amplitude, blend_factor,
  utility_value (were previously hardcoded at multiple sites)

### 2. Default metadata via GET /v1/algorithms

- Add  struct with  +
- Return structured objects instead of plain string array
- Add  function using centralized DEFAULT_* constants
- Proper OpenAPI schema: register  in components(schemas)

### 3. Documentation and tests

- README.md: document params_used, expanded /v1/algorithms response,
  explanation why parameters stay optional despite full traceability
- CLI: update JSON/CSV output for new list format
- 36 integration tests covering response structure, params_used per
  algorithm family, seed consistency, dimension support (1D/2D/3D),
  error cases, normalization, and rectangular grids
- Implement 4D loops in fill_noise_rs_4d, fill_cell_loops!, shape_data
- Add white_noise_4d native hash function
- Reject 4D for FNL-based algorithms, DomainWarp, and SuperSimplex
- Reject 5D+ early in generate_noise
- Update CLI to accept 4 values for --size
- Fix README Algorithms Reference (remove stale sub-field docs)
- Deduplicate resolve_params via resolve_seed_only/resolve_fractal helpers
- Add comment explaining default 64x64 fallback
…rse Fixes

- CLI-Flags auf API-JSON-Pfad gemappt: --sampling-size, --output-format, --output-normalize, --output-file (alte Aliase --size/--format/--normalize/--output bleiben als visible_alias erhalten)
- Redundantes `Sampling.mode`-Feld entfernt (Dimensionalität wird aus size.len() abgeleitet)
- YAML-Output via serde_yaml statt JSON (openapi --format yaml liefert nun echtes YAML)
- CSV-Export lehnt 3D/4D-Daten explizit ab (Fehlermeldung + Exit-Code 1)
- Code-Duplikation in generate_flat reduziert: fill_fnl_seed_only() + fill_fractal!-Makro
- Manuelle Default-Impls durch #[derive(Default)] + #[default] ersetzt (CombinatorOp, UtilityKind, OutputFormat)
- Clippy-Warnings gefixt (map_or → is_some_and, manual_range_contains)
- Tests an neue Feldnamen angepasst, README aktualisiert
…utput from every enum variant

Break GenerateNoiseRequest from a 15-arm tagged enum into a struct
with #[serde(flatten)] algorithm: AlgorithmParams, plus top-level
sampling and output fields. AlgorithmParams uses #[serde(tag =
"algorithm", content = "params")] to preserve the exact same
adjacently-tagged JSON wire format.

Benefits:
- sampling_size() and should_normalize() drop from 17 lines each
  (15-arm or-pattern match) to trivial 1-line field access
- algorithm_name() and check_dimension_support() now match over
  AlgorithmParams instead of GenerateNoiseRequest — same logic,
  cleaner base
- handle_generate_command() in main.rs builds 'output' once instead
  of cloning it in all 15 match arms
- 46 lines of net code removed

Verification:
- cargo build + cargo clippy: clean
- cargo test: all 60 tests pass (unit, CLI, integration)
- Serialization tests confirm the wire format is byte-identical:
  { "algorithm": "perlin", "params": {...}, "sampling": {...},
    "output": {...} }
- All 15 algorithms produce identical numerical results for the same
  seed/params
@plc-dev
plc-dev added this pull request to the merge queue Jul 26, 2026
Merged via the queue into master with commit 529522a Jul 26, 2026
4 checks passed
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.

Integration of a noise-generation library

2 participants