Repository navigation
Conversation
…execution Add a server-derived scheduleExecutionId (sjx-<trace>) to the scheduled dispatch path so each dispatched Task and Run, its child SOPs, and ingested telemetry/log carry the specific ScheduleJobExecution that produced them. - dispatchScheduledRun derives the ID from the claimed execution trace; an empty trace never fabricates an sjx- ID. - dispatchIssue writes it onto the Task before ReserveIssueDispatch and into the Run TelemetryContext; public manual dispatch never sets it. - worker-log ingestion unconditionally overwrites the value from the persisted Run context (including clearing it for manual runs). - child SOPs inherit it via the existing ExecutionContext value copy; TraceID == Run.ID is unchanged. No new tables, no migration, no backfill. - document the read-only Task.scheduleExecutionId in the OpenAPI schema. This is a backend slice of Tencent#460 only; it does not close the issue. Related to Tencent#460. Does not duplicate Tencent#1128 or Tencent#1145.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(schedule): attribute dispatched tasks and runs to their schedule execution
This is a further backend slice of #460 (schedule execution ledger / outcome attribution). It persists the specific schedule execution ID on each dispatched Task and Run, retains it through child SOPs and telemetry/log ingestion, and keeps the existing per-Run
TraceID == Run.IDcontract unchanged. It does not close #460.Problem
The scheduled dispatch path currently propagates only the schedule job ID (
scheduleJobId) into the Task and Run context. A job that runs repeatedly produces one execution per occurrence, but the job ID cannot distinguish them — so a Task, Run, child SOP, or worker log cannot be tied back to the specificScheduleJobExecutionthat produced it.Change
Add an optional, server-derived
scheduleExecutionId(sjx-<trace>, viadomain.ScheduleJobExecutionID(job.LastTraceID)) that flows from the scheduler-side dispatch into the Task and Run execution context:internal/domain/task.go—Task.ScheduleExecutionID(scheduleExecutionId,omitempty).internal/domain/observability.go—TelemetryContext.ScheduleExecutionID(scheduleExecutionId,omitempty).internal/httpapi/schedule.go—dispatchScheduledRunderives the ID from the claimed execution'sjob.LastTraceID. An empty trace (a direct dispatch without a claimed execution) never fabricates ansjx-ID.internal/httpapi/dispatch.go—dispatchRequestcarries the server-derived ID;dispatchIssuewrites it onto the Task beforeReserveIssueDispatch, and into the Run'sTelemetryContext. Public manual dispatch (POSTissue/room dispatch) never sets it, so callers cannot inject attribution.internal/engine/run_events.go— worker-log ingestion unconditionally overwritesScheduleExecutionIDfrom the persisted Run context, including clearing it to empty for manual runs. Worker-reported values are never trusted.docs/api/openapi.yaml— documents the read-onlyTask.scheduleExecutionId.Child SOPs inherit the field through the existing
ExecutionContextvalue copy (engine/sop_node.go), and observation context is rebuilt from the persisted Run context, so both retain the attribution. No new tables, no SQL migration, no data backfill; old records keep an empty value.Verification (Linux/amd64, Docker
python:3.12, real schedule/engine paths)internal/httpapi/schedule_execution_attribution_test.go—TestScheduleExecutionAttributionSeparatesOccurrences: two realRunNowoccurrences on different issues produce distinct execution IDs on Task and Run JSON, the first occurrence is not overwritten by the second, and manual/legacy dispatch stay empty. PASS.internal/engine/schedule_execution_context_test.go—TestScheduledExecutionContextSurvivesChildSOP(parent→child inheritance,TraceID == Run.ID) andTestScheduledExecutionContextOverridesWorkerClaims(forged worker telemetry/log overwritten by the persisted Run value, including the empty/manual case). PASS.go vet(linux target) on the changed packages: clean.docs/api/openapi.yamlparses; the new field is present andreadOnly.domainandschedule: PASS.engine/httpapifull suites show only pre-existing, environment-specific failures, all reproduced on the unmodified baseline (timing-sensitive lease/cancel/recovery tests under parallel load; a pre-existing nil panic in an assistant-diagnostics test; a runner source-build test needing a Go toolchain). Not introduced by this slice.Scope / not covered (by design)
Related
Closes part of #460 (backend attribution slice only); does not close the whole issue.