Skip to content

Keep both coordinates when wttr.in auto-detects a location as lat,lon - #12138

Open
SirJul1337 wants to merge 1 commit into
omacom:quattrofrom
SirJul1337:fix-weather-location-coordinates
Open

SirJul1337 wants to merge 1 commit into
omacom:quattrofrom
SirJul1337:fix-weather-location-coordinates

Conversation

@SirJul1337

Copy link
Copy Markdown

Fixes #12127

When no weather location is set, omarchy-weather-location auto-detects one with wttr.in's %l and cuts the answer at the first comma to drop the country. For some IPs wttr.in can't name the place and answers with bare coordinates (48.855800,2.349400), so the cut left only the latitude. wttr.in rejects that, and omarchy-weather-status printed "Weather unavailable".

The fix keeps the answer whole when it matches the script's existing COORDS_PATTERN. Named locations are still trimmed to the city.

Testing

  • Added cases to test/shell.d/weather-test.sh with curl stubbed: a named location, positive coordinates, and negative coordinates. All weather tests pass; the coordinates case fails without the fix.
  • In an Omarchy 4.0.4 VM with the %l lookup stubbed to return coordinates:
    • before: omarchy-weather-status → Weather unavailable
    • after: omarchy-weather-status → 48.855800,2.349400 · Temp 23°C · Wind ↘13km/h (the real wttr.in response)

With this fix the status line shows the coordinates where a city name would normally go.

wttr.in's %l falls back to a bare "lat,lon" when it can't name the IP.
Trimming at the first comma left only the latitude, which wttr.in rejects,
so the bar showed "Weather unavailable".

Fixes omacom#12127
github-actions Bot pushed a commit to opencharly/plugin-pipeline that referenced this pull request Sep 16, 2026
…al openai-go SDK + a fully-authored CUE param surface (#26)

* feat(pipeline): replace the handcrafted OpenAI client with the official openai-go SDK + a fully-authored CUE param surface

The engine's agent runtime hand-rolled the entire OpenAI-compatible wire path
(chatRequest/chatMsg structs, a net/http POST, a 121-line SSE parser) and
hardcoded every request knob. That client could not do vision, dropped
reasoning deltas, sent no max_tokens/response_format/seed/stop, and silently
dropped tool_choice (ollama's compat request struct has no such field). It is
now DELETED and replaced by github.com/openai/openai-go/v3.

SDD: every parameter is authored in charly.yml through the plugin's own CUE
schema (schema/pipeline.cue -> params/cue_types_gen.go, regenerated by
cue exp gengotypes, reproducible).

- schema/pipeline.cue: #LLMSpec gains organization/project/timeout/
  idle_timeout/max_retries/headers/params; NEW #LLMParams (temperature, top_p,
  max_tokens, max_completion_tokens, frequency/presence_penalty, seed, stop,
  response_format, reasoning_effort, reasoning, stream_options,
  parallel_tool_calls, tool_choice, logprobs, top_logprobs, user, metadata,
  logit_bias, and an extra escape hatch); #ResponseFormat/#Reasoning/
  #StreamOptions/#NamedToolChoice; #StageLLMSpec + the #AgentStage llm
  override. Both param defs are closed - an unknown or wrong-typed field is a
  LOAD error naming the CUE path.
- llm.go: resolveLLM applies env > stage > entity > built-in default
  FIELD-WISE; the client is built per call with explicit options. It uses
  NewChatCompletionService (NOT NewClient) so a stray OPENAI_API_KEY /
  OPENAI_BASE_URL / OPENAI_CUSTOM_HEADERS can never hijack a lane; an empty
  resolved key sends NO Authorization header (the keyless local ollama needs
  none); the request params map 1:1 onto the SDK union.
- chat() re-implemented on NewStreaming + ChatCompletionAccumulator, KEEPING the
  RCA'd IDLE bound (a per-chunk watchdog that cancels the request ctx - not a
  whole-generation deadline) and the empty-completion guard. ollama's
  non-standard reasoning delta (which the SDK accumulator drops) is read from
  the raw JSON, so a reasoning-only 200 is reported as a NAMED empty completion
  instead of a bare one - the real shape behind the intermittent lane failures.
- tools.go: the catalog now renders openai.ChatCompletionToolUnionParam; the
  catalog + dispatchTool are unchanged.
- executor.go: rc.llm was map[string]any assigned via mm(p.Llm) - the same
  map-assertion defect already RCA'd for rc.media, which made an authored llm
  block a SILENT no-op. It is now the generated params.LLMSpec, assigned
  directly.
- vision: chatVision/imageDataURL send a screenshot as a base64 image_url
  content part DIRECTLY to the endpoint (ollama supports base64 data URLs only).
  This is the primitive the screenshot-vision check verb will drive.
- tests: the SSE fixtures now speak the SDK's chunk shape; 13 conformance tests
  prove each authored param reaches the wire (incl. vision content parts,
  reasoning-only, empty completion, idle-stall, precedence, NO OpenAI_* env
  bleed, custom headers, response_format, extra) + 3 LIVE R10 tests against real
  ollama. Two mutations prove the guards are load-bearing: neutralising the
  reasoning read reds TestConformance_ReasoningOnlyIsNamedEmpty, and swapping
  NewChatCompletionService for NewClient reds TestConformance_NoOpenAIEnvBleed.

Verification:
  cd candy/plugin-pipeline
  gofmt -l .                                     # clean
  go vet ./...                                   # clean
  go test -count=1 ./...                         # ok (93 tests)
  go test -count=1 -race ./...                   # ok
  cue exp gengotypes . + diff params/cue_types_gen.go   # PARAMS REPRODUCIBLE
  charly box validate (eval-omarchy + a full llm block, local override)
    -> OK; an unknown param -> #PipelineInput.llm.params.bogus_unknown_knob:
    field not allowed

Co-authored-by: agent <[email protected]>

* fix(pipeline): RCA + fix the defects found by measuring a real eval-pr-plan lane

Eleven defects, each root-caused. Two of them were MISCONCEPTIONS on my part,
corrected here by measurement rather than inference.

MEASURED BASELINE (the correction). Running the real eval-pr-plan lane on a
real non-draft PR (omacom/omarchy#12138, lanes=1) took 757.6s = 12m38s, NOT
the "30+ minutes" I had asserted from a tool timeout. Timestamped stage
breakdown: oracle 90s, render 20s, control 177s, eval 196s, validate 147s,
report 24s, cold-read 88s, the rest ~0s. A 2-lane run took 1095s with the
lanes finishing at 874s/1079s — a 1.38x speedup over sequential, so
concurrency helps but contends. The per-bed STEP durations sum to only 61-81s
while the enclosing stage takes 177-196s: the gap is charly-subprocess
overhead (project resolve + plugin connect + `box validate`, measured at ~13s
each). And 16 lanes is NOT 16x2 VMs: control and eval are SEQUENTIAL stages
within a lane, so the concurrent VM count is `lanes`, not `lanes*2`.

The fixes:

1. (HIGH) runBatch reported SUCCESS for a FAILED batch. It printed each lane's
   error and then returned `0, nil` unconditionally, so a lane ending in the
   LOOP-GUARD escalation still printed "pipeline eval-pr-plan: OK" and exited
   0 — the exit status carried no information (R7). Extracted a `laneReport`
   aggregate; ANY failed lane is now a non-zero exit and an honest
   "FAILED (n/m lanes failed)" summary. Live-verified: a bad PR now exits 1.

2. (HIGH) ade.go passed the PROCESS-GLOBAL `os.Getenv("PR_HEAD_SHA")` to the
   check-run instead of the per-lane value, directly contradicting the RCA
   already recorded at executor.go ("$env.PR_HEAD_SHA to this lane's head;
   never via os.Setenv"): the live run logged `--var PR_HEAD_SHA=`. `adeVerdict`
   now takes the lane's head from `rc.env`.

3. (HIGH) teardownVenue hardcoded the eval-omarchy golden entity and a
   `check-omarchy-pr-<pr>-vm`/`-vm-probe` domain scheme inside the
   DOMAIN-NEUTRAL engine, and omitted `--if-exists` (so every clean lane logged
   a spurious "no such VM … nothing destroyed"). Replaced with
   `teardownLaneBeds`, which derives the beds from the lane's OWN `ade` stages
   (ref-resolved) and always passes `--if-exists`.

4. (HIGH) No signal handling. The lanes drive child processes that hold the
   per-bed flock and keep a VM alive; the engine passed `context.Background()`
   and installed no handler, so a SIGTERM/SIGINT killed only the engine and the
   orphaned child kept the lock — every later lane then died on "check bed …
   already running in this project". Added `signal.NotifyContext`, so the lane
   contexts cancel and the children tear down.

5. (HIGH) The ledger dump path was FIXED (`workdir/stage-findings.yml`), so
   concurrent lanes overwrote each other: the surviving file held ONE lane's
   stages and a FAILING lane's forensic artifact could be destroyed by a
   sibling. This is the per-lane-state class the ledger OBJECT already fixed
   (RCA 2026.252.2210) — never applied to the dump PATH. Now per-lane
   (`stage-findings-pr-<pr>.yml`).

6. (MEDIUM) The runner has ALWAYS measured `StageResult.Duration` but the dump
   DROPPED it, so the one artifact that could answer "where did the lane's 13
   minutes go?" carried no timing. `#StageFinding` gains
   `duration_seconds` and the dump records it.

7. (MEDIUM) runCheckRun + teardownBed were DEAD code (definition-only) and
   teardownBed hardcoded `exec.Command("charly", …)`, bypassing CHARLY_BIN.
   Deleted (R5).

8. (MEDIUM) probeHeadFreshness shelled out to a hand-rolled `gh api`
   subprocess and reported a bare "gh failed" — the exact defect class
   tools.go's own header RCA'd. It now uses the canonical ghkit client and
   names the repo in its failure.

9. (MEDIUM) The `pipeline` agent-tool group declared NINE tools with EMPTY
   parameter schemas and dispatched them with an EMPTY input map, so each
   either passed vacuously (lock_audit over no trees) or failed spuriously
   (config_audit needs a bed) — the "every call arrived arg-less" class, and it
   DUPLICATED the schema-validated probe STAGE surface while being unused.
   Deleted (R3/R5); `tools: [pipeline]` now resolves to no tools.

10. (MEDIUM) probeSequencing matched a hardcoded
    `guest=charly-check-omarchy-pr-<N>-vm` (a vacuous green for any other
    project) and probeGoldenPresent silently substituted a hardcoded
    eval-omarchy path. Both are now driven by their declared inputs
    (`bed_prefix`, `golden`), and a missing input is an explicit failure.

11. (LOW) The ADE summary was truncated to the last 400 BYTES, slicing
    mid-word and dropping the diagnosis (live: "check-run exit 1:
    eline/candy/plugin-pipeline"). `lastLines` keeps whole trailing lines.

Also: `lanes_ok` was an unreachable alias of the sequencing gate whose
description claimed it "reports the concurrency budget" — deleted.

Tests (all mutation-verified to FAIL without their fix): laneReport exit gate,
per-lane ledger path, duration recording, entity-driven teardown target,
sequencing bed_prefix requirement, golden_present input requirement,
head_freshness canonical client, pipeline-tool-group removal, whole-line
summary tail.

Verification:
  gofmt -l . ; go vet ./... ; go test -count=1 ./... ; go test -race ./...
  cue exp gengotypes . + diff params/cue_types_gen.go   # REPRODUCIBLE
  LIVE: eval-pr-plan #12055 (draft) 12/12 stages green; #12138 (real, non-draft)
        ran the full lane, 757.6s, verdict BLOCK with a populated record;
        a bad PR now exits 1 (was 0).

Co-authored-by: agent <[email protected]>

* fix(pipeline): address the PR #26 validator BLOCK — one venue owner, no hardcoded bed default

The fresh pr-validator BLOCKED PR #26 with three findings. All three were
correct; each is fixed by its root cause, not patched.

BLOCK 1 (R3/R5) — the hardcoded `check-omarchy-pr-<pr>-vm` bed default survived
in three more sites (`ade.go` runAdeBed + adeVerdict, `adekit.go` bedPlanOps),
the same lane-coupling the change removes from the batch path. ROOT CAUSE:
`#AdeStage.bed` is schema-REQUIRED, so an empty bed is a CALLER DEFECT and the
fallsback were dead defensive code that (a) baked a lane's private naming scheme
into the domain-neutral engine, (b) silently mis-targeted any other project, and
(c) made the bed-naming rule live in two places with different rules. All three
now FAIL LOUD with "ade: bed required". Test: TestAdeBedIsRequiredNotDefaulted
(mutation-verified: restoring the fallback reds it).

BLOCK 2 (R1/R3/R5) — `teardownLaneBeds` re-broke the per-lane env invariant and
was skipped exactly on abort. ROOT CAUSE: venue lifecycle had TWO owners.
`runAdeBed` already destroys its `--keep-venue` domain; the batch-level copy was
a duplicate that resolved bed refs against the PROCESS env (`envMap()`) instead
of the lane's run context, and used the signal-cancelled ctx, so once
`signal.NotifyContext` fired the destroy never ran at all. Fixed by R3/R5:
DELETE the duplicate — the `ade` stage is the ONE owner — and make the one owner
abort-safe: `destroyVenue` is deferred and runs on a
`context.WithoutCancel`-detached context, so a failure, a provider error and a
SIGTERM all still tear the venue down (the previous early return on a
non-ExitError leaked the VM). Tests: TestVenueHasOneOwner (mutation-verified:
rejoining the signal ctx reds it).

BLOCK 3 (B10/A1) — the PR body claimed `chatMsg`/`chat()` were "Deleted" while
the diff re-defines both. ROOT CAUSE: the accounting conflated "the WIRE structs
+ the old implementation" with "the symbols". The body now says exactly what
changed: the wire structs and the old hand-built `chat()` implementation are
replaced; `chat()` is re-implemented on the SDK and `chatMsg` survives as the
engine's internal transcript row (no longer a wire type).

Verification (frozen tree):
  gofmt -l .            # clean
  go vet ./...          # clean
  go test -count=1 ./...        # ok
  go test -count=1 -race ./...  # ok
  cue exp gengotypes . + diff params/cue_types_gen.go   # REPRODUCIBLE
  LIVE eval-pr-plan #12138, lanes=1: full 12-stage lane green in 521.9s
    (control 209s, eval 409s), and BOTH venues destroyed by the one owner —
    `virsh list --all | grep 12138` => CLEAN (no leak). The prior batch-level
    teardown leaked in exactly the abort case this fixes.

Co-authored-by: agent <[email protected]>

---------

Co-authored-by: agent <[email protected]>
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at be0917f against quattro, and it holds up. Nothing was pushed to the branch.

Reproduced on a disposable Omarchy VM. With no weather.json, I stubbed only wttr.in's ?format=%l lookup to answer 48.855800,2.349400 and let every other request go to the real wttr.in:

  • On quattro, omarchy-weather-location printed 48.855800, wttr.in answered that with HTTP 500, and omarchy-weather-status printed Weather unavailable.
  • On this head it printed the full pair, and omarchy-weather-status showed 48.855800,2.349400 · Temp 17°C · Wind →11km/h.
  • A named answer (Copenhagen, Denmark) is still trimmed to Copenhagen.

Tests, on the same VM. ./test/cli passes, and so does test/shell.d/weather-test.sh (60 passed). With only bin/omarchy-weather-location reverted to quattro, the new coordinates test fails, so it checks the fix rather than passing either way. The curl stub is scoped to each call and does not leak into other tests.

Second opinion: Codex Medium read the diff without running it and found no defect. It agreed the one-line change is the proportionate fix. Because it could read this review's working notes, its agreement isn't fully independent. It also pointed out something outside this diff that I confirmed in the source: shell/plugins/panels/weather/Panel.qml:464 makes its own %l request and splits it at the comma too, so on such an IP the weather panel labels the location with the bare latitude. That only affects the label: the panel's forecast request uses IP auto-detect and still loads. It is a separate cosmetic follow-up and doesn't block this PR.

Related: #13676 changes the --set path of the same script and does not conflict with this change. This PR closes #12127.

Nothing is left for the author. It is waiting on the maintainer.

@jandrusk

Copy link
Copy Markdown

Nice catch — verified ready. Keeping both lat,lon when wttr.in returns bare coordinates (instead of cutting at the first comma) is the right fix for #12127. Same change appears inside the #12155 bundle; prefer this single-purpose PR.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This no longer conflicts over a detail: the line it fixes is gone from quattro. Nothing was pushed to the branch.

What changed. 46ef114 (#16240) moved location auto-detection off wttr.in. With no weather.json, bin/omarchy-weather-location now asks https://geo.omarchy.org/ and prints its JSON .name; there is no ?format=%l lookup and no ${name%%,*} cut left in it. bin/omarchy-weather-status takes that name as is, and the weather panel gets coordinates from the same geo answer, falling back to wttr.in's own ?format=j1 lookup without truncating anything. The only remaining ?format=%l strings on quattro are curl stubs in test/shell.d/runtime-smoke-test.sh and screenshot-sanity-test.sh. So the bare lat,lon answer this PR handled can no longer reach the code, and porting it would add a branch for an input that does not arrive.

Checked by Claude Opus 5.5, reading quattro at 46ef114 against this head (be0917f). Nothing was run on a worker, because nothing here needs running: the question is whether the code still exists. No second opinion ran on this pass: the reviewers (Codex Medium and muse-spark-1.3-contributor) answer a ping, but today's review budget was already spent, so this conclusion is one model's.

Waiting on the maintainer, with a recommendation to close this as fixed by #16240. #9706, the original report of this bug, is still open and looks fixed by the same commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-weather-location breaks when wttr.in returns coordinates instead of a city name

3 participants