Skip to content

Merge the nine audit fix branches - #10

Merged
KARLalpha4768 merged 20 commits into
mainfrom
fix/audit-remediation
Nov 17, 2026
Merged

KARLalpha4768 merged 20 commits into
mainfrom
fix/audit-remediation

Conversation

@KARLalpha4768

@KARLalpha4768 KARLalpha4768 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

What this is

One branch that merges the nine fix branches behind PRs #1 to #9 (open since Oct 25), so they can be reviewed and merged together, plus two fixes found in review.

Branch What it changes
fix/secrets-env Cesium token, API key and database DSN read from environment variables; new /api/config function
fix/api-nlp-lockdown /api/nlp requires an API key, limits origins, rate-limits and validates input
fix/docker-build Digital-twin container start command, C++ sources, no Docker socket mount
fix/infra-hardening Kubernetes secrets and Terraform networking
fix/correctness-high CORR-01 to CORR-05 in the conjunction screener, ASCOM HAL and science modules
fix/orbit-propagator RA wrap, cos(dec) in angular rate, Kepler solver (CORR-07, CORR-08)
fix/twin-ws One shared broadcaster task; ECI to Earth-fixed longitude (PERF-01, CORR-06)
fix/db Commit, rollback and close handling; parameterized updates (CORR-10)
chore/build-test-hygiene .dockerignore, pytest in CI, deduplicated photometry source

No file is touched by more than one branch, and all nine merged without conflicts.

Added in review

fed8226 Consistent frames in non_gaussian_pc.py. fix/correctness-high made the STM an ECI matrix, while the second-order tensor, the input covariances and the miss vector are in RTN.

  • Symptom: the propagated covariance landed on the wrong axes once the object moved along its orbit. On the module's own example, Pc shifted 1.3× at 1 hour and 3× at 1 day from the frame mismatch alone. The "propagated mean" was the STM applied to the absolute state, 11.7 million km from Earth.
  • Fix:
    • The ECI STM is mapped into the object's RTN frame at epoch and at t.
    • Both objects are combined in ECI, then rotated into the primary's RTN frame before projection.
    • The relative third moment is secondary minus primary; it was added.
    • Monte Carlo samples deviations instead of absolute states and counts hits on the same encounter plane as the analytic path.
  • Tests (5 new):
    • The RTN STM matches Clohessy-Wiltshire for a circular orbit without J2.
    • Pc is unchanged when both orbits are rotated about the polar axis.
    • The propagated mean stays on the orbit.
    • Monte Carlo matches the projected Gaussian.

33c378e Gemini models in /api/nlp. gemini-2.0-flash-lite shut down June 1, 2026 and gemini-2.5-flash shuts down December 1. Now gemini-3.5-flash-lite with gemini-3.1-flash-lite as fallback. The temperature setting is dropped (Gemini 3 ignores it), the output cap is raised to 1024 because it includes thinking tokens, and the reply parser skips thought parts.

How it was checked

Run locally on Python 3.13 with the CI install step (pip install -r requirements.txt):

  • ruff check . --select=E9,F63,F7,F82: passes.
  • pytest -q: 41 passed.
  • python end_to_end_test.py: 6 of 6. The science module self-tests and python main.py exit 0.
  • api/nlp.js and api/config.js through a local harness:
    • /api/nlp returns 503 when NLP_API_KEY is unset, 401 without a key or with a wrong one, 403 from another origin, and 429 after 20 requests a minute.
    • With Gemini stubbed, it calls gemini-3.5-flash-lite with the key in a header, falls back on 503, and returns 502 when both models fail.
    • /api/config returns the token from the environment.
  • The digital-twin start command from the Dockerfile loads the app and serves /docs; the command on main fails with ModuleNotFoundError: No module named 'src'. The image itself was not built.
  • No Cesium token, demo API key or other credential pattern remains in the tree.

Before merging: this changes the live demo

  1. Set CESIUM_ION_TOKEN in Vercel and restrict the token to your site's URLs in Cesium ion. /api/config gives it to anyone who asks, as any browser-side token is. Without the variable, the globes fall back to Cesium's built-in demo token.
  2. The terminal's Gemini fallback will stop answering for visitors. /api/nlp now requires an X-API-Key header, and frontend/sentinel_terminal.js does not send one. Free-text input the built-in parser does not recognise will show "I didn't understand that"; built-in commands are unaffected.
  3. Set NLP_API_KEY and, if the site is served from another domain, ALLOWED_ORIGINS. Both functions default to allowing only https://sentinelforge.vercel.app.
  4. Rotate the Cesium token. It is removed from the files but remains in git history.

Not covered

  • non_gaussian_pc.py builds its encounter plane perpendicular to the miss vector rather than the relative velocity, so the miss distance always projects to zero and Pc ignores it. This is the same on main. Fixing it needs the relative-velocity direction, which EncounterGeometry only has as a scalar speed.
  • Both Cesium pages pass imageryProvider, which CesiumJS removed in 1.107, so they load Cesium ion imagery instead of the intended local texture.
  • alembic.ini cannot read DATABASE_URL from the environment (there are no migrations yet), health_check.py always reports healthy, and .vercel/project.json is still tracked.
  • CI lint now checks only syntax errors and undefined names. The stricter rules it replaced already failed on main.

Merging this PR lands the same commits as #1 to #9, so GitHub will mark those nine as merged and their branches can be deleted.

https://claude.ai/code/session_01GQ1LmN35bvwVLnZ9PiewFe


Generated by Claude Code

KARLalpha4768 and others added 20 commits October 25, 2026 10:16
… test production orbit code (ARCH-01, DEPLOY-04, CI-01, TEST-01)
The STM became an ECI matrix in fix/correctness-high, while the
second-order tensor, the input covariances and the miss vector stay in
RTN. The propagated covariance was therefore reported on the wrong axes
once the object moved along its orbit, and Pc depended on where the
objects happened to be.

- Map the ECI STM into the object's RTN frame at epoch and at t
  (StateTransitionTensor.local_stm), so it composes with the RTN tensor.
- propagate_moments returns ECI moments: the mean is the propagated
  state plus the second-order shift (it was Phi applied to the absolute
  state, millions of km off); covariance and skewness are rotated to ECI.
- screen combines both objects in ECI and rotates the result into the
  primary's RTN frame before projecting with the RTN miss vector. The
  relative third moment is secondary minus primary (it was added).
- Monte Carlo samples deviations rather than absolute states, propagates
  them through the same second-order flow, and counts hits on the same
  encounter plane as the analytic path.
- Tests: RTN STM equals Clohessy-Wiltshire for a circular orbit without
  J2; Pc is unchanged when both orbits are rotated about the polar axis;
  the propagated mean stays on the orbit; Monte Carlo matches the
  projected Gaussian.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQ1LmN35bvwVLnZ9PiewFe
gemini-2.0-flash-lite shut down on June 1, 2026 and gemini-2.5-flash
shuts down on December 1, 2026. Use gemini-3.5-flash-lite (Google's
named replacement) with gemini-3.1-flash-lite as the fallback.

Gemini 3 ignores temperature and counts thinking tokens against
maxOutputTokens, so drop temperature and raise the cap to 1024. Read the
first non-thought text part of the reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQ1LmN35bvwVLnZ9PiewFe
@KARLalpha4768
KARLalpha4768 merged commit 8ee9f2f into main Nov 17, 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.

2 participants