Skip to content
Merged

Enc #28

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0aeccda
feat(Sa.Configuration): add encrypted secrets layer and .env support
Oct 23, 2026
4413037
feat(Sa.Configuration): normalize `__` keys to `:` and add explicit k…
Oct 23, 2026
2233e97
docs(Sa.Configuration): rework readmes — plainer wording, tighter str…
Oct 23, 2026
74d183e
fix(Sa.Utils.WorkQueue): DI call order, shutdown awaitability, slot a…
dundich Oct 26, 2026
6fdfb8d
Merge branch 'wq' into enc
dundich Oct 26, 2026
5ad028c
fix(Sa.Schedule): error policy, concurrency slots, fault handling; bu…
dundich Oct 26, 2026
244e219
fix(Sa.Schedule): keep the RunOnce budget on faults; document fault t…
dundich Oct 26, 2026
84865f1
perf(Sa.Schedule): lazy reader pool, isolated restarts, early job-id …
dundich Oct 26, 2026
7e10746
fix(Sa.Schedule): strict cron validation in config, pin day specials,…
dundich Oct 27, 2026
5d99b45
fix(Sa.Schedule): stop the cron search at the end of the date range; …
dundich Oct 27, 2026
f82f8b3
refactor(Sa.Schedule)!: rename CronTiming.Every to CronTiming.For; bu…
dundich Oct 27, 2026
84ba6e4
feat(Sa.Schedule): optional leading seconds field (6-field cron, dete…
dundich Oct 27, 2026
27af052
docs(Sa.Schedule): next-occurrence table for the seconds field
dundich Oct 27, 2026
014c9f2
perf(Sa.Schedule): wait on the injected TimeProvider, open the slot s…
dundich Oct 27, 2026
f135e00
chore(build): track the empty local Sa.* feed folder
dundich Oct 27, 2026
bd9185d
fix(Sa.Outbox): publisher batch slice, reentrant Apply, listener snap…
dundich Oct 27, 2026
8a49ef9
fix(Sa.Outbox.PostgreSql): bigint COUNT, type-cache reset, per-tenant…
dundich Oct 27, 2026
65c91d7
chore: ignore local opencode config and .secrets
dundich Oct 27, 2026
e70d2e9
fix(Sa.Media.FFmpeg): link the linux-x64 payload statically
dundich Oct 27, 2026
d3cc87e
chore(Sa.Media.FFmpeg): bump 0.17.0
dundich Oct 27, 2026
a8eb275
test(Sa.Data.S3.Fixture): run S3 suites on SeaweedFS instead of MinIO
dundich Oct 27, 2026
14e788b
chore(build): add docker image and registry-routing helpers for test …
dundich Oct 27, 2026
9cb6a45
fix(Sa.Partitional.PostgreSql): month/year strategy, re-quoted cache …
dundich Oct 27, 2026
b4dd788
fix(Sa.Outbox.PostgreSql): PostgreSQL quote escaping, partition-name …
dundich Oct 27, 2026
bc97740
fix(Sa.Schedule): reflect a cancelled caller token when no slot ever …
dundich Oct 27, 2026
dc9abd7
refactor(Sa.Configuration)!: rename encrypted secrets files to secret…
dundich Oct 28, 2026
1bd32e0
refactor(Sa.Partitional.PostgreSql)!: strict partition columns and pa…
dundich Oct 28, 2026
0dc2b61
fix(Sa.Utils.WorkQueue): gate the force-cancel drain, keep the limit …
dundich Oct 28, 2026
214e86b
feat(Sa.Configuration): accumulate key aliases in one final pass; bum…
dundich Oct 28, 2026
dd57a5d
fix(Sa.Data.TempFolder): refuse symlinked paths on read, delete and e…
dundich Oct 28, 2026
8361ba3
fix(Sa.Data.TempFolder): own the per-pass budget in the instance, ali…
dundich Oct 28, 2026
78351cd
feat(Sa.Data.TempFolder): measure the volume with cleanup off, write …
dundich Oct 28, 2026
d3b3b71
chore(Sa.Data.TempFolder): dispose the pass interrupt, bound the reso…
dundich Oct 28, 2026
d4aa374
fix(Sa.HybridFileStorage.FileSystem): secure path ownership, portable…
dundich Oct 28, 2026
65a9c20
fix(Sa.HybridFileStorage.Postgres): await the download callback, stor…
dundich Oct 28, 2026
07be7f5
fix(Sa.Media)!: correct sample conversion and streamed WAV sizing, ha…
dundich Oct 28, 2026
6c64968
feat(Sa.Utils.WorkQueue): add detached producer cancellation, cut hot…
dundich Oct 29, 2026
a1f6bc2
perf(Sa.Outbox.PostgreSql): capture result-set ordinals once in comma…
dundich Oct 29, 2026
97d00a7
perf(Sa.Outbox.PostgreSql): dedupe parts before the repository and ca…
dundich Oct 29, 2026
52e8705
perf(Sa.Data.PostgreSql): bind value-type parameters without boxing
dundich Oct 29, 2026
927c01d
perf(Sa.Outbox.PostgreSql): serve the type cache from a synchronous s…
dundich Oct 29, 2026
a73f177
perf(Sa.Outbox): share part info, add a single-publish path, skip nee…
dundich Oct 29, 2026
cb92c5d
feat(Sa.Outbox)!: wrapper-free publish batches, struct PartInfo, pool…
dundich Oct 29, 2026
913d510
perf(Sa.Partitional.PostgreSql): one table lookup and no cache-hit ta…
dundich Oct 29, 2026
e438cad
perf(Sa.Schedule): cache the fallback job name and skip the pause loc…
dundich Oct 29, 2026
214fae0
perf(Sa.Data.PostgreSql): reuse commands and cache scalar type dispatch
dundich Oct 29, 2026
6ee13a4
feat(Sa.Outbox)!: make delivery message records value types
dundich Oct 29, 2026
185031e
test: clear the remaining xUnit analyzer warnings
dundich Oct 29, 2026
c85d643
docs(Sa.Outbox): show how to keep a payload without keeping the context
dundich Oct 29, 2026
a403457
perf(Sa.Outbox)!: make OutboxMessage a struct, add an outbox benchmark
dundich Oct 29, 2026
b3f5efc
perf(Sa.Outbox): stop boxing value payloads in metadata; benchmark la…
dundich Oct 29, 2026
1e19d27
feat(Sa.Outbox): support value-type publishable payloads
dundich Oct 29, 2026
000c6c3
chore: align every package version at 0.17.0
dundich Oct 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -803,14 +803,27 @@ src/.vscode/

*.lscache

# local secrets
.env
!.env.example
.secrets/

# ai
.qwen/
.agents/
/.github/skills
# Local opencode config: may reference machine-specific paths and secrets (.secrets/).
/opencode.jsonc
/opencode.json
/src/Sa.Media.FFmpeg/sa/native/
/src/Tests/Sa.MediaTests/data/pcm_s16le.wav
/src/Sa.Media/Echo/output.wav
src/Sa.Media/Echo/data/pcm_s16le.wav
/src/.nuget
# ... except the folder itself: Directory.Build.props points RestoreFallbackFolders at
# src/.nuget/fallback and NuGet requires it to exist, so a fresh clone must carry it.
!/src/.nuget/
!/src/.nuget/fallback/
!/src/.nuget/fallback/.gitkeep
/src/.localpilot
/.opencode/**
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ Dependency graph (who references whom): `Sa.Utils.WorkQueue` → `Sa.Schedule`
## Tests
- **xUnit v3** on Microsoft.Testing.Platform (test projects are executables). Not classic xUnit — see the `xunit3` skill (`.opencode/skills/xunit3/`) for the v3 API, and `.github/skills/migrate-xunit-to-xunit-v3/` for the migration patterns.
- Cancellation token comes from **`TestContext.Current.CancellationToken`** (house pattern: a static `TestToken` property on the test class).
- Integration tests use **Testcontainers** (PostgreSQL + Minio) via fixtures in `src/Tests/Fixtures/` — **Docker must be running** for those suites. One container per test class, so concurrency is deliberately throttled — see *Test load is capped on purpose* above.
- Integration tests use **Testcontainers** (PostgreSQL + SeaweedFS) via fixtures in `src/Tests/Fixtures/` — **Docker must be running** for those suites. One container per test class, so concurrency is deliberately throttled — see *Test load is capped on purpose* above.
- Images are pulled **once** and then reused from the local daemon; after that the suites need no registry. `./build-sh/do-docker-images.sh {status|pull|save|load}` warms a machine up, and `save`/`load` moves the tars to one without registry access.
- The S3 server image is **SeaweedFS** (`chrislusf/seaweedfs`), **not** MinIO: `minio/minio` no longer answers anonymous pulls on Docker Hub, and `quay.io/minio/minio` rejects them too. The fixture runs `mini` (master+volume+filer+S3 in one process) on port 8333 with `-s3.autoCreateBucket=false`, so a missing bucket fails like it did on MinIO — see `S3Fixture.CreateBuilder`.
- If a VPN tunnel owns the default route, pulls crawl. `sudo ./build-sh/do-docker-bypass.sh {on|off|status}` routes the registry and its CDN around the tunnel; see `build-sh/readme.md`.
- `TestCi` / CI run `dotnet test ... --filter "Category!=Local"` to skip local-infra tests. As of now **no test carries a `Category` trait** (grep-verified), so this filter currently excludes nothing — it's a placeholder for future `Category=Local` tests.
- Each lib declares `<InternalsVisibleTo Include="<Name>.Tests" />`, so tests can touch `internal` members.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Declarative PostgreSQL table partitioning (range by day/month/year and list) wit

### [Sa.Schedule](src/Sa.Schedule) — Scheduled Task Executor

Configurable scheduled tasks supporting cron expressions, fixed intervals, and one-shot delays, with per-job failure strategies, retries, concurrency limits, interceptors, and runtime start/stop/restart. ([Cron docs EN](src/Sa.Schedule/CRON.md), [Cron docs RU](src/Sa.Schedule/CRON-ru.md))
Configurable scheduled tasks supporting cron expressions, fixed intervals, and one-shot delays, with per-job failure strategies, retries, concurrency limits, interceptors, and runtime start/stop/restart. ([Cron docs EN](src/Sa.Schedule/Cron/CRON.md), [Cron docs RU](src/Sa.Schedule/Cron/CRON-ru.md))

---

Expand Down
28 changes: 28 additions & 0 deletions build-sh/do-docker-bypass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# Route Docker Hub (registry, auth and its blob CDN) around a VPN tunnel, through the physical
# interface. Only those hosts bypass the tunnel; everything else keeps using it.
#
# Why this exists: when a tunnel owns the default route, a `docker pull` is pushed through it too.
# On a throttled tunnel a 150 MB image can take hours, while the same pull over the physical link
# finishes in seconds. The images are pulled once (./do-docker-images.sh pull), so this is a one-off.
#
# Requires root (it edits the routing tables).
#
# Usage:
# sudo ./build-sh/do-docker-bypass.sh status # which path a pull would take right now
# sudo ./build-sh/do-docker-bypass.sh on # add the bypass routes
# sudo ./build-sh/do-docker-bypass.sh off # remove them
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/tasks.sh"

case "${1:-status}" in
status) docker_bypass_status ;;
on) docker_bypass_on ;;
off) docker_bypass_off ;;
*)
echo "usage: $0 {status|on|off}" >&2
exit 2
;;
esac
29 changes: 29 additions & 0 deletions build-sh/do-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
#
# Fetch the container images the integration test suites start (PostgreSQL, SeaweedFS, Ryuk), so a
# machine without registry access can still run them.
#
# The suites start one container per test class, but the image is pulled once and then reused from
# the local daemon — after `pull` (or `load`) they need no registry at all.
#
# Usage:
# ./build-sh/do-docker-images.sh status # what is present locally
# ./build-sh/do-docker-images.sh pull # pull everything (needs registry access)
# ./build-sh/do-docker-images.sh save [dir] # write *.tar into dir (default dist/docker-images)
# ./build-sh/do-docker-images.sh load [dir] # docker load *.tar from dir
#
# Offline transfer: `save` on a machine with registry access, copy the directory over, `load` here.
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/tasks.sh"

case "${1:-status}" in
status) docker_images_status ;;
pull) docker_images_pull ;;
save) docker_images_save "${2:-}" ;;
load) docker_images_load "${2:-}" ;;
*)
echo "usage: $0 {status|pull|save [dir]|load [dir]}" >&2
exit 2
;;
esac
14 changes: 14 additions & 0 deletions build-sh/do-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#
# Encrypt, decrypt and check Sa.Configuration secrets files.
# Thin wrapper around build-sh/tools/secrets.cs (a .NET 10 file-based app).
#
# Usage:
# ./build-sh/do-secrets.sh encrypt secrets.txt --client lsr --env dev -o secrets.lsr.dev.pub
# ./build-sh/do-secrets.sh decrypt secrets.lsr.dev.pub
# ./build-sh/do-secrets.sh check
#
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/tasks.sh"

exec dotnet run --file "$ROOT/build-sh/tools/secrets.cs" -- "$@"
73 changes: 73 additions & 0 deletions build-sh/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,81 @@ Alternative to PowerShell `build/` — these scripts work on Linux/macOS.

# Enable long paths on Linux (create /sa symlink)
sudo ./do-fix-max-path-linux.sh

# Encrypt, decrypt and check Sa.Configuration secrets files
./do-secrets.sh encrypt secrets.txt --client lsr --env dev -o secrets.lsr.dev.pub
./do-secrets.sh decrypt secrets.lsr.dev.pub
./do-secrets.sh check

# Container images the integration suites need (PostgreSQL, SeaweedFS, Ryuk)
./do-docker-images.sh status
./do-docker-images.sh pull
./do-docker-images.sh save ./docker-images # then copy the folder to the offline machine
./do-docker-images.sh load ./docker-images

# Route Docker Hub around a VPN tunnel (needs root; only those hosts are affected)
sudo ./do-docker-bypass.sh status
sudo ./do-docker-bypass.sh on
sudo ./do-docker-bypass.sh off
```

## Test container images

Every integration test class starts its own container, but the image is pulled **once** and then
reused from the local daemon — after that the suites need no registry at all. So a machine without
registry access (or behind a tunnel slow enough to make pulls impractical) can still run them.

- `./do-docker-images.sh pull` — pull the three images into the local daemon.
- `./do-docker-images.sh save` / `load` — offline transfer: save on a connected machine, copy the
`*.tar` files, load on the isolated one.
- The image list lives in `tasks.sh` (`DOCKER_TEST_IMAGES`) and mirrors the fixture defaults in
`src/Tests/Fixtures/Sa.Data.PostgreSql.Fixture/PostgreSqlFixtureSettings.cs` and
`src/Tests/Fixtures/Sa.Data.S3.Fixture/S3FixtureSettings.cs`. Update both when bumping a tag.

### S3 server image

The S3 suites run against **SeaweedFS** (`chrislusf/seaweedfs`), not MinIO. `minio/minio` no longer
answers anonymous pulls on Docker Hub (`denied: requested access to the resource is denied`), and
`quay.io/minio/minio` — MinIO's own registry — rejects anonymous pulls too.

The fixture starts `mini`, which runs master, volume, filer and the S3 gateway in one process, and
relies on three of its properties:

- the S3 gateway listens on **8333** (`mini` default; not MinIO's 9000);
- credentials come from `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` — with no config file present
the gateway turns them into an admin identity, so requests must be signed;
- `-s3.autoCreateBucket=false`, otherwise writing to a missing bucket silently creates it and
`ThrowIfBucketNotExists` stops throwing.

Both S3 suites pass on it: `Sa.Data.S3Tests` (78) and `Sa.HybridFileStorage.S3Tests` (48).

### When Docker Hub is unreachable or slow

If a VPN tunnel owns the default route, `docker pull` goes through the tunnel as well. That can turn
a 150 MB image into an hours-long download while the physical link is fast.

`./do-docker-bypass.sh on` adds host routes for the registry, its auth endpoint and the blob CDN
into the tunnel's policy-routing table, pointing at the physical gateway. Only those hosts are
affected; everything else keeps using the tunnel. `off` removes the routes.

- Route by IP, so run `on`, then `pull`, then `off` in one go — CDN addresses rotate between
lookups.
- If `status` still shows `tun0` after `on`, the tunnel has a kill switch in nftables and routing
alone is not enough; pausing the VPN for the duration of the pull is then the reliable option.

## Secrets tooling

`do-secrets.sh` wraps `tools/secrets.cs` — a .NET 10 file-based app that references
`src/Sa.Configuration/Sa.Configuration.csproj`, so it always uses the in-repo format.

- The key is read from `SA_SECRETS_DECRYPTION_KEY` (or `SA_SECRETS_DECRYPTION_KEY_<CLIENT>`),
from `--key-file`, from `.env`, or typed interactively. `--key` is rejected on purpose:
a command-line key leaks through process listings and shell history.
- `check` infers the client/environment from each file header, verifies decryption and exits
non-zero on the first failure — suitable for CI.
- `encrypt` takes a plaintext `key=value` file and writes `ENC1:` values; comments and blank
lines are preserved. Use it to re-encrypt after editing the plaintext source.

## Notes

- All scripts use `set -euo pipefail` for strict error handling.
Expand Down
Loading
Loading