Skip to content

Commit 7588068

Browse files
committed
fix(odp-rs): restore 2026-07-02 data-loss fixes over stale iii-integration versions
The iii-integration merge resolved 14 conflicted files to the branch side, which predates (2026-06-19) the odp data-loss trapdoor / DLQ / stale-consumer fixes already on main (2026-07-02). Restore the main-side versions; keep the branch's net-new files.
1 parent 8b97e07 commit 7588068

14 files changed

Lines changed: 705 additions & 28 deletions

File tree

‎iii/scripts/Import-IiiEnv.ps1‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ function Import-IiiEnv {
1010
$RepoRoot = Split-Path -Parent $IiiRoot
1111
}
1212

13-
$env:III_URL = if ($env:III_URL) { $env:III_URL } else { "ws://127.0.0.1:49134" }
14-
$env:ODP_INGEST_URL = if ($env:ODP_INGEST_URL) { $env:ODP_INGEST_URL } else { "http://127.0.0.1:8040" }
13+
$nasHost = if ($env:III_NAS_HOST) { $env:III_NAS_HOST } else { "192.168.50.130" }
14+
$nasMode = $env:III_DEPLOY_MODE -eq "nas-edge"
15+
if (-not $env:III_URL) {
16+
$env:III_URL = if ($nasMode) { "ws://${nasHost}:49134" } else { "ws://127.0.0.1:49134" }
17+
}
18+
if (-not $env:ODP_INGEST_URL) {
19+
$env:ODP_INGEST_URL = if ($nasMode) { "http://${nasHost}:8040" } else { "http://127.0.0.1:8040" }
20+
}
1521
if (-not $env:DISCORD_CLI_BIN) { $env:DISCORD_CLI_BIN = "discord" }
1622

1723
$loaded = $null
@@ -40,7 +46,38 @@ function Import-IiiEnv {
4046
RepoRoot = $RepoRoot
4147
EnvFile = $loaded
4248
DiscordTokenSet = [bool]$env:DISCORD_TOKEN
49+
NasEdge = $nasMode
50+
EngineHost = Get-IiiEngineHost
51+
}
52+
}
53+
54+
function Get-IiiEngineHost {
55+
$nasHost = if ($env:III_NAS_HOST) { $env:III_NAS_HOST } else { "192.168.50.130" }
56+
$url = $env:III_URL
57+
if ($url -match '^wss?://([^:/]+)') {
58+
return $matches[1]
59+
}
60+
if ($env:III_DEPLOY_MODE -eq "nas-edge") {
61+
return $nasHost
4362
}
63+
return "127.0.0.1"
64+
}
65+
66+
function Get-IiiExe {
67+
Join-Path $env:USERPROFILE ".local\iii\iii.exe"
68+
}
69+
70+
function Invoke-IiiEngineTrigger {
71+
param(
72+
[Parameter(Mandatory)][string]$FunctionPath,
73+
[string[]]$ExtraArgs = @(),
74+
[int]$TimeoutMs = 30000
75+
)
76+
$iii = Get-IiiExe
77+
if (-not (Test-Path $iii)) { throw "iii CLI not found: $iii" }
78+
$engineHost = Get-IiiEngineHost
79+
$triggerArgs = @("trigger", "--address", $engineHost, "--timeout-ms", $TimeoutMs, $FunctionPath) + $ExtraArgs
80+
& $iii @triggerArgs
4481
}
4582

4683
function Get-IiiWorkerEnvironment {
@@ -57,6 +94,7 @@ function Start-IiiPythonWorker {
5794
$script = Join-Path $IiiRoot "workers\$WorkerName\src\main.py"
5895
if (-not (Test-Path $script)) { throw "Worker script not found: $script" }
5996
$py = (Get-Command python -ErrorAction Stop).Source
97+
$env:PYTHONPATH = $IiiRoot
6098
$envBlock = Get-IiiWorkerEnvironment
6199
$params = @{
62100
FilePath = $py

‎iii/scripts/restart-workers.ps1‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
# Restart III Python workers with full env (DISCORD_TOKEN, ODP_INGEST_URL, …).
2-
# Usage: .\scripts\restart-workers.ps1 [-ReloadSchedules]
2+
# Usage:
3+
# .\scripts\restart-workers.ps1 # local full stack (dev)
4+
# .\scripts\restart-workers.ps1 -NasEdge # PC edge only → NAS engine (production)
5+
# .\scripts\restart-workers.ps1 -ReloadSchedules
36

4-
param([switch]$ReloadSchedules)
7+
param(
8+
[switch]$ReloadSchedules,
9+
[switch]$NasEdge
10+
)
511

612
$ErrorActionPreference = "Stop"
7-
. (Join-Path $PSScriptRoot "Import-IiiEnv.ps1")
813

14+
. (Join-Path $PSScriptRoot "Import-IiiEnv.ps1")
915
$ctx = Import-IiiEnv
10-
Write-Host "III workers restart (env: $($ctx.EnvFile))"
16+
17+
if ($NasEdge -or $ctx.NasEdge) {
18+
if (-not $NasEdge) {
19+
Write-Host "III_DEPLOY_MODE=nas-edge — edge workers only (collector-discord → $($ctx.EngineHost))"
20+
}
21+
& (Join-Path $PSScriptRoot "start-edge-workers.ps1") @PSBoundParameters
22+
return
23+
}
24+
25+
Write-Host "III workers restart (local stack, env: $($ctx.EnvFile))"
1126

1227
Stop-IiiPythonWorkers
1328
Start-Sleep -Seconds 2
@@ -19,12 +34,11 @@ foreach ($w in @("odp-ingest-bridge", "collector-discord", "collector-opencli",
1934

2035
Start-Sleep -Seconds 3
2136

22-
$IiiExe = Join-Path $env:USERPROFILE ".local\iii\iii.exe"
23-
& $IiiExe trigger odp.ingest::health | Out-Host
24-
& $IiiExe trigger discord::status | Out-Host
37+
Invoke-IiiEngineTrigger "odp.ingest::health" | Out-Host
38+
Invoke-IiiEngineTrigger "discord::status" | Out-Host
2539

2640
if ($ReloadSchedules) {
27-
& $IiiExe trigger odp.schedule::reload | Out-Host
41+
Invoke-IiiEngineTrigger "odp.schedule::reload" | Out-Host
2842
}
2943

3044
Write-Host "Done. Workers run on THIS machine until stop-workers.ps1 or reboot."

‎iii/workers/collector-opencli/Dockerfile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ RUN apt-get update \
66
&& rm -rf /var/lib/apt/lists/* \
77
&& npm install -g @jackwener/opencli
88

9-
COPY workers/collector-opencli/pyproject.toml workers/collector-opencli/src ./worker/
9+
COPY workers/collector-opencli/pyproject.toml ./worker/
10+
COPY workers/collector-opencli/src ./worker/src/
1011
COPY lib ./lib
1112
RUN pip install --no-cache-dir -e ./worker
1213

1314
ENV PYTHONUNBUFFERED=1
15+
ENV PYTHONPATH=/app
1416
ENV OPENCLI_BIN=opencli
1517
ENV OPENCLI_MODE=bridge
1618
ENV OPENCLI_DAEMON_HOST=agent-1
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM python:3.12-slim-bookworm
22
WORKDIR /app
3-
COPY workers/odp-ingest-bridge/pyproject.toml workers/odp-ingest-bridge/src ./worker/
3+
COPY workers/odp-ingest-bridge/pyproject.toml ./worker/
4+
COPY workers/odp-ingest-bridge/src ./worker/src/
45
COPY lib ./lib
56
RUN pip install --no-cache-dir -e ./worker
67
ENV PYTHONUNBUFFERED=1
8+
ENV PYTHONPATH=/app
79
CMD ["python", "worker/src/main.py"]

‎iii/workers/schedule-bootstrap/Dockerfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM python:3.13-slim
22
WORKDIR /app
33
COPY lib /app/lib
44
COPY schedules /app/schedules
5-
COPY workers/schedule-bootstrap/pyproject.toml workers/schedule-bootstrap/src /app/workers/schedule-bootstrap/
5+
COPY workers/schedule-bootstrap/pyproject.toml /app/workers/schedule-bootstrap/
6+
COPY workers/schedule-bootstrap/src /app/workers/schedule-bootstrap/src/
67
RUN pip install --no-cache-dir -e ./workers/schedule-bootstrap
78
ENV DISCORD_SCHEDULES_PATH=/app/schedules/discord.yaml
89
ENV OPENCLI_SCHEDULES_PATH=/app/schedules/opencli.yaml

‎odp-rs/Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎odp-rs/Dockerfile.ingest‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ COPY crates ./crates
55
RUN cargo build --release -p odp-ingest
66

77
FROM debian:bookworm-slim
8-
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
8+
# curl is required for the docker-compose healthcheck (curl -f localhost:8040/health).
9+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/*
910
COPY --from=builder /app/target/release/odp-ingest /usr/local/bin/odp-ingest
1011
EXPOSE 8040
1112
CMD ["odp-ingest"]

‎odp-rs/Dockerfile.store‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ COPY crates ./crates
55
RUN cargo build --release -p odp-store
66

77
FROM debian:bookworm-slim
8-
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
8+
# procps provides pgrep, used by the docker-compose healthcheck below: odp-store
9+
# has no HTTP/TCP listener (it's a pure Redis-stream consumer loop), so the best
10+
# available liveness probe is "is the process still running" rather than a
11+
# network check.
12+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates procps && rm -rf /var/lib/apt/lists/*
913
COPY --from=builder /app/target/release/odp-store /usr/local/bin/odp-store
1014
CMD ["odp-store"]

0 commit comments

Comments
 (0)