myxce/.wolf/bugs/bug-1676.md
Rongsong Shen d26ff8870d
feat(buglog): one Markdown record per bug, checked against a record standard
The buglog was one 27K-line JSON file whose fields covered only symptom,
root cause and fix, as free text: 2% of entries named the code version a
bug was found on, 12% the build profile, 36% a way to reproduce, and 58% of
the file was OpenWolf hook auto-detections ("Missing guard clause",
"Function not marked async" on .md files).

- .claude/skills/buglog/bug-record.md: the record standard. Eight
  sections (Summary as the title, Description, Environment, Reproduction;
  Root cause, Fix, Verification, References once fixed), each with the
  content it must contain -- e.g. Environment needs the OS, the libc the
  failing binary loads (from its ELF interpreter: glibc 2.42 in the nix
  shell vs 2.40 on the host), toolchain, build profile and commit.
- .wolf/bugs/<id>.md: 500 records migrated from buglog.json; every field
  verified to round-trip. They carry legacy: true and an explicit "not
  recorded" where the old log had no such field; component derived from
  file paths, severity from keywords (else unknown), fix_commits from
  hashes in status_note/fix that git resolves (91 of 463 fixed).
- .wolf/buglog-archive.json: the 710 hook auto-detections, verbatim.
- .wolf/buglog.json is now an index generated from the records, keeping
  the fields OpenWolf's hooks and `openwolf bug search` read.
- scripts/buglog.py rewritten: new (template + Environment collected from
  the machine and --binary), check, status (refuses a status the record
  doesn't support; fixed needs Root cause, Fix, Verification and
  --commit hashes git resolves), note, recur, set, show, list, triage,
  env, index. 29 unittest cases in scripts/tests/test_buglog.py.
- scripts/git-hooks/pre-commit runs `check --staged`: incomplete staged
  records, a legacy record hand-changed to fixed without the fix-time
  sections, a new record claiming legacy: true, or a stale index refuse
  the commit.
- scripts/gitea-sync.py reads the records: issue body = the record's
  sections plus linked fix commits (origin remote, GITEA_COMMIT_REPO to
  override), and a body hash so an issue's text is refreshed when the
  record changes.
- bug-1866 rewritten to the full standard as the worked example.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 03:40:11 +00:00

5.1 KiB

id status status_updated status_note component severity timestamp last_seen occurrences files tags related legacy gitea_issue gitea_synced_status
bug-1676 fixed 2026-09-24 apiserver unknown 2026-08-24T13:40:00Z 2026-09-19T09:00:00Z 1
src/frontend/apiserver/controllers/jobs.go:1483
src/frontend/apiserver/backend/handler.go:18-20
src/schema/controller.capnp
gitea-issue-44
apiserver
go
jobs.go
handler.go
from-host
capnp-schema
data-loss
true 44 fixed

bug-1676: Gitea issue #44 ("FROM_HOST is -"): xcecli jobs list's FROM_HOST column always shows - instead…

Description

Gitea issue #44 ("FROM_HOST is -"): xcecli jobs list's FROM_HOST column always shows - instead of the host the job was submitted from. Reproduced live on branch scheduler-framework: submitted a job, checked xcecli jobs list ~1 second later (job still PEND) -- FROM_HOST blank; confirmed via the apiserver's own debug log showing "from_host":"" on every job regardless of state (PEND/RUN/DONE), across every job submitted in the session.

Environment

Not recorded (migrated from buglog.json).

Reproduction

Not recorded (migrated from buglog.json).

Root cause

Three-part chain, fully traced: (1) jobs.go:1483 correctly sets FromHost: ctx.ClientIP() at job-CREATION time. (2) controller.capnp's Job/JobSubmitData structs have no from_host field at all (confirmed via grep -- zero matches for fromHost/from_host in the schema), so this value never round-trips to or back from the C controller. (3) handler.go's OnJobUpdated (line 18-20) does a blind store.Jobs.Put(uint64(job.Unique_JobID), *job) full overwrite on every controller-sourced job push, unlike OnHostUpdated/OnHostConfigUpdated (handler.go:46-70) which explicitly merge worker-sourced and config-sourced fields onto the existing stored entry. Since a controller-sourced job push never carries from_host (per #2), the very first state-change push after creation -- which happens almost immediately, well before a user can typically observe the initial value -- wipes FromHost back to "" via the blind overwrite.

Fix

FIXED (2026-08-24), full fix. User directive: client should assert its own from-host and the backend should pass it through unchanged, rather than the apiserver deriving it from ctx.ClientIP() (which is an IP not a hostname, and trivially spoofable via X-Forwarded-For since this apiserver never calls gin.Engine.SetTrustedProxies()). Two independent, non-overlapping pieces:

(1) Origin: xcecli's BuildJobRequest() (cmd/jobs/submit.go) now sets JobSubmitRequest.FromHost via os.Hostname(); apiserver's CreateJob (controllers/jobs.go:1483) now does FromHost: req.FromHost -- a straight passthrough, ctx.ClientIP() removed entirely from this path. New field added to both xcecli's and apiserver's independent models.JobSubmitRequest structs (separate Go modules, no shared code). New test TestBuildJobRequest_SetsFromHostToLocalHostname (xcecli). Full xcecli suite and apiserver controllers/models suites pass.

(2) Round-trip: src/schema/controller.capnp's JobSubmitData gains fromHost @10: Text $C.mapname("from_host") (auto-regenerates controller.capnp.c/h via the existing meson capnpc-c custom_target -- no hand-editing of generated files). src/include/xce/types.h's job_submit_data_t gains char* from_host. src/lib/jobj.c's jobsub_init/jobsub_destroy (the hand-written, ref-counted, content-deduped job-submit interning object -- NOT auto-generated) thread from_host through the deep-copy, the dedup identity comparison, and the destroy path; 3 existing tests updated + new test_jobsub_from_host_distinguishes_identity in test_jobj.c/testsuite. Go apiserver/backend/convert.go's modelJobToSubmit/freeJobSubmit (submit direction) and cJobToModel/cJobArrayToModels (receive direction), plus convert_pure.go's rawSubmitData/rawJobToModel (the pure-Go, CGO-free mapping layer) all thread the field through. Did NOT need to touch job.c's build_job_submit_payloads() (bare pointer borrow, flows through automatically) or any WAL persistence code (capnp_encode_job/decode_Job already generically encode/decode the whole xce_job_t including the full .submit sub-struct) or backend/handler.go's OnJobUpdated (its existing blind overwrite is correct by construction once every push genuinely carries the right value).

Verified: C xcelib_test 301/301 (ASAN leak detection on, includes the 3 updated + 1 new jobsub tests, independently re-run and confirmed). Go backend suite: pure-Go tests (CGO_ENABLED=0) and full CGO suite via make test-backend against the real regenerated capnp headers, both independently re-run and confirmed (ok apiserver/backend 14.6s). Live, independently verified on a freshly-submitted job (not reusing any job the implementer had already submitted): FROM_HOST= visible from the very first query while still PEND, survives the RUN transition, and (implementer's own live check, not independently re-run) survives a full 4-daemon restart for free via existing WAL_JOB_SUBMIT persistence.

Verification

Not recorded (migrated from buglog.json).

References

  • Gitea: #44