Skip to content

Dev - #34

Merged
zlovtnik merged 4 commits into
mainfrom
dev
Jul 14, 2026
Merged

Dev#34
zlovtnik merged 4 commits into
mainfrom
dev

Conversation

@zlovtnik

@zlovtnik zlovtnik commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Added dedicated iPhone WireGuard setup with direct profile import and QR-code guidance.
    • Added batch scan request recording with deduplication and last-input-wins behavior.
    • Improved frontdoor routing by probing and pinning clients to the responding backend during rotation.
  • Bug Fixes
    • Corrected iPhone/direct profile obfuscation handling and credential handoff to include only direct profile details.
    • Improved WireGuard packet forwarding efficiency (less unnecessary data movement) and clarified shim vs direct endpoint behavior.
    • Standardized Oracle ledger timestamps to UTC-compatible behavior.
  • Documentation
    • Added WireGuard throughput acceptance validation guidance and updated configuration/operational notes (including frontdoor rate-limiting defaults).

zlovtnik added 3 commits July 13, 2026 14:30
- Document iPhone direct profiles using `make up-ready PROFILE_MODE=iphone`.
- Update port table and environment variables to distinguish obfuscation vs plain modes.
- Add WG_FRONTDOOR_RATE_LIMIT_PPS and clarify WG_FRONTDOOR_DISPATCH_TASK_LIMIT.
- Remove incomplete comment in peer.conf and fix whitespace in Makefile.
… non-direct modes

- Add `ensure_private_config_mode()` to gracefully handle chmod permission errors
- Only generate direct peer config when profile mode is iphone/linux-direct
- Prevent overwriting resolved config files in shim modes
- Refactor Rust SessionKey to use Arc<str> to reduce cloning
- Change `WIRELESS_ALERTS_LEDGER` to store timestamps in UTC by
  using `CAST(SYS_EXTRACT_UTC(:NEW.DETECTED_AT) AS TIMESTAMP)`.
- Make `WIRELESS_CHANNELS` primary key RELY to support reliable
  foreign keys.
- Add deduplication logic in `record_scan_request_batch` to avoid
  conflicts before upsert.
- Update documentation with required Oracle grants for fine-grained
  audit and VPD policies, noting that the baseline fails without them.
- Add `.metals/` to `.gitignore`.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 52f0d322-c232-4b10-86d9-30b08944f988

📥 Commits

Reviewing files that changed from the base of the PR and between 31b45a8 and bbc6416.

📒 Files selected for processing (4)
  • apps/wg-key-rotator
  • docs/secret-management.md
  • ops/src/sslproxy_ops/commands/up_ready/peers.py
  • ops/tests/test_up_ready_helpers.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • ops/tests/test_up_ready_helpers.py

📝 Walkthrough

Walkthrough

Changes

WireGuard profile handling

Layer / File(s) Summary
Profile modes and generated credentials
ops/src/sslproxy_ops/commands/...
iPhone and direct profiles now use plain configurations, while shim profiles retain obfuscation and peer files are validated and protected.
Profile behavior tests
ops/tests/test_up_ready_helpers.py, tests/wireguard_template.rs
Tests cover runtime settings, config discovery, handoffs, permissions, peer repair, and template output.
Profile operations
README.md, ops-memory.md, docs/secret-management.md
Setup, ports, environment variables, remediation guidance, and secret-repair behavior were updated.

WireGuard packet datapath

Layer / File(s) Summary
Headroom-aware packet encoding and decoding
src/wg_packet_obfuscation_sections/*, src/wg_packet_obfuscation_tests.rs
Encoding and decoding now preserve payload ranges and reserved buffer headroom.
Relay and shim range propagation
src/wg_relay_sections/*, src/wg_shim_sections/*
Relay and shim paths forward explicit buffer ranges instead of assuming packets begin at offset zero.
Frontdoor worker dispatch and pinned routes
src/bin/wg-udp-frontdoor.rs, docker-compose.yaml
The frontdoor uses pooled buffers, bounded worker queues, queue metrics, pinned backend routes, and disabled rate limiting by default.

PostgreSQL batch ingestion

Layer / File(s) Summary
Deduplicated batch upsert function
sql/functions/054_...sql
A coordinator function validates batch inputs, deduplicates by latest input order, upserts events, and updates wireless frames.
Batch SQL bootstrap and contract validation
sql/postgres.source.sql, sql/postgres.sql, services/zig-coordinator/src/test/...
Generated SQL and bootstrap inclusion were updated with corresponding contract tests.

Oracle schema contracts

Layer / File(s) Summary
Oracle timestamp and constraint definitions
sql/oracle.sql, sql/oracle/tables/*, sql/oracle/triggers/*
Ledger timestamps now store UTC values without timezone types, and the wireless channel key uses RELY.
Oracle grants and contract tests
docs/runbook.md, services/zig-coordinator/src/test/...
Required direct grants and generated SQL assertions were added.

Repository support

Layer / File(s) Summary
Build and workspace support
.gitignore, Makefile, docker-compose.yaml
Metals artifacts are ignored, schema-migrator tests are wired into Make targets, and the frontdoor rate-limit default is disabled.
WireGuard performance validation
docs/runbook.md
Throughput acceptance procedures and thresholds were documented.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too generic and does not describe the actual changes in the pull request. Rename the PR with a concise summary of the main change, such as WireGuard iPhone/direct-mode and packet-handling updates.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31b45a891d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

tokio::select! {
_ = context.shutdown.cancelled() => break,
recv = context.listen_socket.recv_from(&mut lease) => {
recv = context.listen_socket.recv_from(&mut lease[packet_start..]) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid truncating shim datagrams before encoding

When obfuscation reserves any headroom (packet_start > 0, e.g. magic-byte or framed mode), this receives into a buffer that is shorter than max_datagram_bytes. A local WireGuard datagram whose size is between max_datagram_bytes - packet_start + 1 and max_datagram_bytes will be truncated by UDP receive and then encoded/forwarded as if it were complete; the old path read the full configured buffer and would reject oversized encoded packets instead of corrupting them. Use a backing buffer large enough for headroom plus the configured plaintext receive size, or read the full datagram before deciding whether to drop it.

Useful? React with 👍 / 👎.

_ = shutdown.cancelled() => break,
_ = session.shutdown.cancelled() => break,
recv = session.upstream_socket.recv(&mut buf) => {
recv = session.upstream_socket.recv(&mut buf[packet_start..]) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid truncating relay replies before encoding

For obfuscated relay replies, packet_start is nonzero, so this shrinks the receive buffer used for the internal WireGuard socket. Any kernel reply that fits the configured max_datagram_bytes but not max_datagram_bytes - packet_start is truncated by UDP receive and then sent onward as a valid encoded packet; previously it was read into the full buffer and could fail the encode size check rather than forwarding corrupted bytes. Keep the receive capacity at the plaintext maximum and reserve extra headroom in the backing storage.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/wg_shim_sections/sessions.rs (1)

380-433: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Keep obfuscation headroom consistent for live sessions
run_shim sizes packet_start from the reloaded config, while existing sessions keep their original session.config. If a SIGHUP changes obfuscation in a way that reduces headroom, those sessions can start dropping packets with PacketTooLarge. Either keep obfuscation out of live reloads or close/recreate sessions when that setting changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/wg_shim_sections/sessions.rs` around lines 380 - 433, Update run_shim and
the live configuration/session lifecycle so obfuscation headroom remains
consistent for existing sessions: either exclude obfuscation from reloadable
configuration, or detect an obfuscation change and close/recreate affected
sessions before packet processing. Ensure packet_start and each
session.config.obfuscation cannot diverge after SIGHUP, preventing
PacketTooLarge drops.
🧹 Nitpick comments (3)
ops/src/sslproxy_ops/commands/up_ready/model.py (1)

51-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

desired_obfuscation_value is duplicated across two files with no single source of truth. Both copies were updated consistently in this PR, but future changes risk silent divergence.

  • ops/src/sslproxy_ops/commands/up_ready/model.py#L51-L52: Keep this as the canonical definition (it is the model module for the up_ready package and is already imported by checks.py and __init__.py).
  • ops/src/sslproxy_ops/commands/diagnose.py#L33-L34: Remove the local definition and import from up_ready.model instead.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ops/src/sslproxy_ops/commands/up_ready/model.py` around lines 51 - 52, The
duplicate desired_obfuscation_value definitions must have a single source of
truth. Keep desired_obfuscation_value in
ops/src/sslproxy_ops/commands/up_ready/model.py unchanged as the canonical
implementation; in ops/src/sslproxy_ops/commands/diagnose.py, remove the local
definition and import desired_obfuscation_value from up_ready.model, preserving
all existing call sites and behavior.
ops/tests/test_up_ready_helpers.py (1)

220-237: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Combine nested with statements (Ruff SIM117).

🧹 Proposed fix
-            with unittest.mock.patch(
-                "sslproxy_ops.commands.up_ready.checks.repo_root", return_value=root
-            ):
-                with self.assertRaises(UpReadyError):
-                    discover_peer_configs(ctx)
+            with (
+                unittest.mock.patch(
+                    "sslproxy_ops.commands.up_ready.checks.repo_root", return_value=root
+                ),
+                self.assertRaises(UpReadyError),
+            ):
+                discover_peer_configs(ctx)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ops/tests/test_up_ready_helpers.py` around lines 220 - 237, Combine the
nested context managers in
test_iphone_config_discovery_refuses_obfuscated_fallback into a single with
statement while preserving the temporary-directory setup, repo_root patch, and
expected UpReadyError assertion.

Source: Linters/SAST tools

ops/src/sslproxy_ops/commands/up_ready/__init__.py (1)

46-53: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

iphone and linux-shim branches are now byte-for-byte identical.

Both cases set WG_OBFUSCATION_ENABLED="true", WG_PORT="443", WG_INTERNAL_PORT="51820", and call activate_obfuscation_key_env_fallback(). If a future change adjusts ports/obfuscation for one profile, it's easy to forget the other since nothing ties them together syntactically.

♻️ Merge the duplicate match arms
-        case "iphone":
-            # Preserve the established shim endpoint while exposing the
-            # boringtun listener on the separate direct-client port.
-            os.environ["WG_OBFUSCATION_ENABLED"] = "true"
-            os.environ["WG_PORT"] = "443"
-            os.environ["WG_INTERNAL_PORT"] = "51820"
-            activate_obfuscation_key_env_fallback()
-        case "linux-direct":
-            os.environ["WG_OBFUSCATION_ENABLED"] = "false"
-            os.environ["WG_PORT"] = "443"
-            os.environ["WG_INTERNAL_PORT"] = "51820"
-        case "linux-shim":
-            os.environ["WG_OBFUSCATION_ENABLED"] = "true"
-            os.environ["WG_PORT"] = "443"
-            os.environ["WG_INTERNAL_PORT"] = "51820"
-            activate_obfuscation_key_env_fallback()
+        case "iphone" | "linux-shim":
+            # iPhone keeps server-side obfuscation on the shim endpoint while
+            # also exposing the boringtun listener on the direct-client port.
+            os.environ["WG_OBFUSCATION_ENABLED"] = "true"
+            os.environ["WG_PORT"] = "443"
+            os.environ["WG_INTERNAL_PORT"] = "51820"
+            activate_obfuscation_key_env_fallback()
+        case "linux-direct":
+            os.environ["WG_OBFUSCATION_ENABLED"] = "false"
+            os.environ["WG_PORT"] = "443"
+            os.environ["WG_INTERNAL_PORT"] = "51820"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ops/src/sslproxy_ops/commands/up_ready/__init__.py` around lines 46 - 53,
Merge the identical "iphone" and "linux-shim" match arms in the command dispatch
so both profiles share one branch containing the existing environment
assignments and activate_obfuscation_key_env_fallback() call. Preserve the
current behavior for each profile while removing the duplicated implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql`:
- Around line 92-181: Consolidate the duplicate deduplication pipeline by making
the wireless-frame upsert consume the existing deduplicated CTE from the shared
WITH statement, using a frame_upserts CTE or equivalent and forcing its
execution from the final SELECT. Apply this restructuring in
sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql lines
92-181 and mirror the identical change in sql/postgres.source.sql lines
6147-6329; both sites must have the wireless upsert reference deduplicated
rather than independently unnesting and filtering requests.

In `@sql/oracle.sql`:
- Line 607: Update CAPTURED_AT in sql/oracle.sql at lines 607-607 to default to
UTC using SYS_EXTRACT_UTC, matching DETECTED_AT normalization; apply the same
change to sql/oracle/tables/022_wireless_alerts_ledger.sql at lines 27-27 so
both DDL definitions remain consistent.

In `@src/bin/wg-udp-frontdoor.rs`:
- Around line 1006-1012: Update the receive loop in run_listener so
socket.recv_from(&mut buf).await errors are handled locally instead of
propagated with ?. Log the receive error using the same approach as the shim
receive loop, then continue listening for subsequent packets while preserving
the existing rate-limiting and packet-processing flow.

---

Outside diff comments:
In `@src/wg_shim_sections/sessions.rs`:
- Around line 380-433: Update run_shim and the live configuration/session
lifecycle so obfuscation headroom remains consistent for existing sessions:
either exclude obfuscation from reloadable configuration, or detect an
obfuscation change and close/recreate affected sessions before packet
processing. Ensure packet_start and each session.config.obfuscation cannot
diverge after SIGHUP, preventing PacketTooLarge drops.

---

Nitpick comments:
In `@ops/src/sslproxy_ops/commands/up_ready/__init__.py`:
- Around line 46-53: Merge the identical "iphone" and "linux-shim" match arms in
the command dispatch so both profiles share one branch containing the existing
environment assignments and activate_obfuscation_key_env_fallback() call.
Preserve the current behavior for each profile while removing the duplicated
implementation.

In `@ops/src/sslproxy_ops/commands/up_ready/model.py`:
- Around line 51-52: The duplicate desired_obfuscation_value definitions must
have a single source of truth. Keep desired_obfuscation_value in
ops/src/sslproxy_ops/commands/up_ready/model.py unchanged as the canonical
implementation; in ops/src/sslproxy_ops/commands/diagnose.py, remove the local
definition and import desired_obfuscation_value from up_ready.model, preserving
all existing call sites and behavior.

In `@ops/tests/test_up_ready_helpers.py`:
- Around line 220-237: Combine the nested context managers in
test_iphone_config_discovery_refuses_obfuscated_fallback into a single with
statement while preserving the temporary-directory setup, repo_root patch, and
expected UpReadyError assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9cc4d292-fcc9-4fcb-8d93-cc42f37b855f

📥 Commits

Reviewing files that changed from the base of the PR and between b7f4e6c and 31b45a8.

📒 Files selected for processing (33)
  • .gitignore
  • Makefile
  • README.md
  • config/templates/peer.conf
  • docker-compose.yaml
  • docs/runbook.md
  • ops-memory.md
  • ops/src/sslproxy_ops/commands/diagnose.py
  • ops/src/sslproxy_ops/commands/up_ready/__init__.py
  • ops/src/sslproxy_ops/commands/up_ready/checks.py
  • ops/src/sslproxy_ops/commands/up_ready/model.py
  • ops/src/sslproxy_ops/commands/up_ready/peers.py
  • ops/tests/test_up_ready_helpers.py
  • services/zig-coordinator/src/test/java/com/sslproxy/coordinator/oracle/OracleSchemaContractTest.java
  • services/zig-coordinator/src/test/java/com/sslproxy/coordinator/service/SqlFunctionContractTest.java
  • sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql
  • sql/oracle.sql
  • sql/oracle/tables/018_wireless_channels.sql
  • sql/oracle/tables/022_wireless_alerts_ledger.sql
  • sql/oracle/triggers/001_wireless_alerts_ledger_trg.sql
  • sql/postgres.source.sql
  • sql/postgres.sql
  • src/bin/wg-udp-frontdoor.rs
  • src/wg_packet_obfuscation_sections/encode_decode.rs
  • src/wg_packet_obfuscation_sections/types.rs
  • src/wg_packet_obfuscation_tests.rs
  • src/wg_relay_sections/runtime.rs
  • src/wg_relay_sections/session_io.rs
  • src/wg_shim_sections/config_metrics.rs
  • src/wg_shim_sections/runtime.rs
  • src/wg_shim_sections/sessions.rs
  • src/wg_shim_test_sections/unit.rs
  • tests/wireguard_template.rs
💤 Files with no reviewable changes (2)
  • config/templates/peer.conf
  • Makefile

Comment on lines +92 to +181
deduplicated as (
select distinct on (valid.dedupe_key) valid.*
from valid
order by valid.dedupe_key, valid.input_ordinality desc
),
upserted as (
insert into sync_events (
dedupe_key,
stream_name,
observed_at,
payload_ref,
payload,
payload_sha256,
status,
attempt_count,
last_error,
producer,
event_kind,
created_at,
updated_at
)
select dedupe_key,
stream_name,
observed_at,
payload_ref,
payload,
payload_sha256,
'pending',
0,
null,
'ssl-proxy',
nullif(payload->>'type', ''),
now(),
now()
from deduplicated
on conflict (dedupe_key)
do update set
observed_at = excluded.observed_at,
payload_ref = excluded.payload_ref,
payload = coalesce(excluded.payload, sync_events.payload),
payload_sha256 = excluded.payload_sha256,
producer = excluded.producer,
event_kind = coalesce(excluded.event_kind, sync_events.event_kind),
status = case
when sync_events.status in ('pending', 'failed') then 'pending'
else sync_events.status
end,
last_error = case
when sync_events.status in ('pending', 'failed') then null
else sync_events.last_error
end,
updated_at = now()
returning 1
)
select count(*) into v_recorded_count from upserted;

perform coordinator.upsert_wireless_frame_from_payload(
deduplicated.dedupe_key,
deduplicated.stream_name,
deduplicated.payload
)
from (
select distinct on (raw.dedupe_key)
raw.dedupe_key,
raw.stream_name,
raw.payload
from (
select raw.request,
raw.payload,
raw.input_ordinality,
raw.request->>'stream_name' as stream_name,
raw.request->>'dedupe_key' as dedupe_key
from unnest(p_requests, p_payloads, p_payload_sha256s)
with ordinality as raw(request, payload, payload_sha256, input_ordinality)
) raw
join (
select distinct btrim(configured.stream_name) as stream_name
from unnest(p_stream_names) as configured(stream_name)
where btrim(configured.stream_name) <> ''
) configured_streams on configured_streams.stream_name = raw.stream_name
left join sync_event_tombstones tombstone
on tombstone.dedupe_key = raw.dedupe_key
and tombstone.stream_name = raw.stream_name
and tombstone.expires_at > now()
where raw.dedupe_key is not null
and tombstone.dedupe_key is null
and coordinator.safe_timestamptz(raw.request->>'observed_at') is not null
order by raw.dedupe_key, raw.input_ordinality desc
) deduplicated
where deduplicated.stream_name = 'wireless.audit';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Deduplication pipeline is implemented twice within the same function, and duplicated again in the aggregate file. The sync_events dedup (deduplicated CTE) and the wireless-frame dedup (independent subquery) recompute the identical unnest/ordinality → configured_streams → tombstone-join → safe_timestamptz pipeline separately; a future edit to one path without the other will silently desync sync_events from wireless_frames.

  • sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql#L92-L181: fold the wireless-frame upsert into the same with statement as deduplicated/upserted (e.g. via a frame_upserts CTE referencing deduplicated directly, forced to execute via the final select), so both actions consume one dedup pass.
  • sql/postgres.source.sql#L6147-L6329: apply the identical restructuring here to keep the aggregate reference in sync with the split file, per the repo's alignment requirement for sql/postgres.sql/sql/postgres.source.sql.
📍 Affects 2 files
  • sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql#L92-L181 (this comment)
  • sql/postgres.source.sql#L6147-L6329
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql`
around lines 92 - 181, Consolidate the duplicate deduplication pipeline by
making the wireless-frame upsert consume the existing deduplicated CTE from the
shared WITH statement, using a frame_upserts CTE or equivalent and forcing its
execution from the final SELECT. Apply this restructuring in
sql/functions/054_coordinator_record_scan_request_batch_deduplicate.sql lines
92-181 and mirror the identical change in sql/postgres.source.sql lines
6147-6329; both sites must have the wireless upsert reference deduplicated
rather than independently unnesting and filtering requests.

Source: Coding guidelines

Comment thread sql/oracle.sql
ACKNOWLEDGED NUMBER(1,0) NOT NULL,
LEDGER_ACTION VARCHAR2(16) NOT NULL,
CAPTURED_AT TIMESTAMP WITH TIME ZONE DEFAULT (SYSTIMESTAMP AT TIME ZONE 'America/New_York') NOT NULL,
CAPTURED_AT TIMESTAMP DEFAULT (CAST(SYSTIMESTAMP AT TIME ZONE 'America/New_York' AS TIMESTAMP)) NOT NULL,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

CAPTURED_AT default stores America/New_York local time, not UTC — inconsistent with DETECTED_AT UTC normalization. The shared root cause is the default expression CAST(SYSTIMESTAMP AT TIME ZONE 'America/New_York' AS TIMESTAMP), which converts the system timestamp to America/New_York local time and then drops the timezone, producing a naive non-UTC value. Meanwhile DETECTED_AT is stored as UTC via CAST(SYS_EXTRACT_UTC(:NEW.DETECTED_AT) AS TIMESTAMP). Two naive-TIMESTAMP columns in the same ledger table with different timezone conventions will cause incorrect cross-column comparisons and time arithmetic, and this contradicts the PR's stated goal of normalizing ledger timestamps to UTC.

  • sql/oracle.sql#L607-L607: Change the default to CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS TIMESTAMP) for UTC consistency, or document the mixed convention if America/New_York local time is intentional for CAPTURED_AT.
  • sql/oracle/tables/022_wireless_alerts_ledger.sql#L27-L27: Apply the same default change to keep the table-file DDL aligned with sql/oracle.sql.
📍 Affects 2 files
  • sql/oracle.sql#L607-L607 (this comment)
  • sql/oracle/tables/022_wireless_alerts_ledger.sql#L27-L27
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sql/oracle.sql` at line 607, Update CAPTURED_AT in sql/oracle.sql at lines
607-607 to default to UTC using SYS_EXTRACT_UTC, matching DETECTED_AT
normalization; apply the same change to
sql/oracle/tables/022_wireless_alerts_ledger.sql at lines 27-27 so both DDL
definitions remain consistent.

Comment on lines 1006 to +1012
loop {
let (len, client_addr) = socket.recv_from(&mut buf).await?;
let permit = match dispatch_semaphore.clone().try_acquire_owned() {
Ok(permit) => permit,
Err(_) => {
if !state.rate_limiter.allow(client_addr).await {
state.stats.record_rate_limited_drop();
debug!(%client_addr, listener = %listener_name, "dropping rate-limited packet");
continue;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant file around the cited lines.
FILE="src/bin/wg-udp-frontdoor.rs"
if [ -f "$FILE" ]; then
  wc -l "$FILE"
  sed -n '960,1045p' "$FILE" | cat -n
fi

# Find all recv_from usages and related error handling.
rg -n "recv_from|rate_limiter.allow|shutdown|graceful|listener" src/bin/wg-udp-frontdoor.rs src -g '!target' -g '!node_modules' || true

Repository: zlovtnik/ssl-proxy

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="src/bin/wg-udp-frontdoor.rs"
if [ -f "$FILE" ]; then
  wc -l "$FILE"
  sed -n '960,1045p' "$FILE" | cat -n
fi

rg -n "recv_from|rate_limiter.allow|shutdown|graceful|listener" src/bin/wg-udp-frontdoor.rs src -g '!target' -g '!node_modules' || true

Repository: zlovtnik/ssl-proxy

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the shim receive loop that the comment references.
sed -n '360,395p' src/wg_shim_sections/sessions.rs | cat -n

# Inspect the frontdoor listener shutdown/error handling around the caller.
sed -n '630,650p' src/bin/wg-udp-frontdoor.rs | cat -n

Repository: zlovtnik/ssl-proxy

Length of output: 2635


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect how listener task failures are handled by the frontdoor runtime.
sed -n '630,690p' src/bin/wg-udp-frontdoor.rs | cat -n

# Inspect the listener runner and any shutdown token usage nearby.
sed -n '950,1035p' src/bin/wg-udp-frontdoor.rs | cat -n

Repository: zlovtnik/ssl-proxy

Length of output: 6452


Handle recv_from errors without taking down the frontdoor src/bin/wg-udp-frontdoor.rs:1007

socket.recv_from(&mut buf).await? bubbles out of run_listener, and the supervisor exits the whole process on any listener task failure. If this socket can hit transient errors, log and continue like the shim receive loop instead of dropping the service.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/bin/wg-udp-frontdoor.rs` around lines 1006 - 1012, Update the receive
loop in run_listener so socket.recv_from(&mut buf).await errors are handled
locally instead of propagated with ?. Log the receive error using the same
approach as the shim receive loop, then continue listening for subsequent
packets while preserving the existing rate-limiting and packet-processing flow.

…r configs

- Add ensure_server_key_material() to generate server key pair when missing.
- Update peer config rendering to accept server_public_key parameter and replace placeholder.
- Clarify secret management docs regarding repair command behavior.
@zlovtnik
zlovtnik merged commit ae700e0 into main Jul 14, 2026
2 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.

1 participant