Skip to content

BackgroundJob.promote metadata copy detaches review-loop metadata #343

Closed

Description

@agenteinstinct1-max

BackgroundJob.promote copies metadata, which detaches review-loop metadata. Needs a core design decision (share vs copy). Split from #320 and related to the context work in #319; not a quick fix.

Activity

  1. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Characterization on integration commit 57df662c53f200bf8c4830adca72a7f40c8d2a94:

    A temporary focused test using the actual BackgroundJob.Service confirms the boundary:

    1. Start a running job with a caller-owned metadata object and background: false.
    2. Add a field to that original object before promotion. jobs.get(id).metadata sees it.
    3. Promote the job.
    4. Add a review-style { writesFiles: true, handoff: "pending", sessionId: "child" } field to the same original object. jobs.get(id).metadata does not see the new field; it retains the pre-promotion fields plus background: true.

    Diagnostic: 1 passed, 4 assertions. This characterizes reference detachment, not an end-to-end review-gate failure or a fix. No product code was changed.

    Relevant current paths:

    • packages/core/src/background-job.ts: start stores input.metadata; promote replaces it with { ...job.info.metadata, background: true }; returned snapshots are separately shallow-copied.
    • packages/opencode/src/tool/task.ts: projectChildWrites assigns late REVIEW_LOOP_METADATA to its original metadata object, while independently projecting evidence into the persisted parent task part. Thus loss in the job record does not establish loss in all persisted evidence paths.
    • TaskTool.resumeChild reads job.metadata[REVIEW_LOOP_METADATA] to mark a descendant report UNREVIEWED, a concrete downstream consumer to cover in an end-to-end regression.

    Still open: establish intended metadata ownership and cover a descendant that is promoted before its first file-write evidence, then completes and resumes its parent. Sharing producer-owned metadata and adding an explicit metadata-update operation are different designs; this diagnostic does not choose between them or justify closing the issue.

  2. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Real producer-to-consumer reproduction on dcf9cf96804e04d43ab69bd5b3f2194af761ef37 confirms the narrow defect:

    • Configure the nested agent foreground; assert registry background: false before promotion and true after it. Merely passing background: false is insufficient because the agent default can still choose background.
    • Keep its actual TaskTool prompt pending, promote, then persist an actual completed write ToolPart through Session, finish it, and let the parent park/resume.
    • The resumed parent gets the descendant's result without UNREVIEWED. Direct notification still uses producer-local evidence; this is specifically the parked consumer reading registry metadata.

    Local fix preserves the producer-owned metadata reference through promotion, consistent with current start behavior; observation results remain shallow top-level copies. TaskTool is the only production start caller found. Core ownership tests and a new end-to-end nested test cover this choice. Restoring the old promotion copy makes the nested regression fail again.

    Scope caveat: the resumed child's incoming report now carries both UNREVIEWED and reviewLoop metadata, but this does not prove every later ancestor notification repeats the marker. An additional exploratory outer-notification assertion exposed that separate propagation gap, so this fix will not claim a general review-gate guarantee.

  3. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Correction to the exploratory outer-notification caveat above: the fake prompt skipped persisting its resumed incoming text metadata. The real SessionPrompt preserves and persists it. With faithful incoming message/part persistence, the outer UNREVIEWED assertion passes too. PR #573 now covers both immediate resumed evidence and that next ancestor notification; no separate product propagation defect was established. Full TaskTool + legacy registry suite: 84 passed, 407 assertions.

  4. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Scope correction after review: #573 uses real TaskTool/BackgroundJob/Session services with fake promptOps. Its incoming resumed-report persistence is manually simulated, not execution of production SessionPrompt. The test does establish the promoted registry evidence and immediate resume report regression. The later ancestor assertion covers the simulated adapter path only; source inspection shows metadata-preserving spread in SessionPrompt, not end-to-end acceptance. No actual SessionPrompt propagation defect or full acceptance is claimed. #343 remains open and #573 merge is held while this concrete review point is reconciled.

  5. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Merged #573 into dev-vibecoded as 511d574db8a3ce36b722f0d82d3df31291ad73ed (API merged=true verified). Promotion now retains the producer-owned metadata object; observation results remain shallow top-level copies. Regression covers actual TaskTool foreground promotion followed by persisted write, plus production SessionPrompt noReply incoming persistence and immediate/outer review evidence. Model replies remain synthetic, not full LLM/TUI acceptance. The old-copy mutation fails at the earlier persisted reviewLoop assertion (0/1/6); later UNREVIEWED assertions are not reached in that mutant. Exact-head CI and actual Kilo are clean; independent review resolved the production-persistence finding. Leaving this issue open for final scope reconciliation rather than claiming broad autonomous review-gate acceptance.

  6. agenteinstinct1-max commented on Oct 24, 2026

    @agenteinstinct1-max
    CollaboratorAuthor

    Final scope reconciliation: closing as fully covered by #573, merged into dev-vibecoded as 511d574db8a3ce36b722f0d82d3df31291ad73ed (merged=true verified). Both original asks are covered: promotion no longer detaches late review metadata, and the explicit ownership decision is to share the producer-owned object while returned observations shallow-copy the top level. The regression covers promoted late writes, the parked consumer, and production SessionPrompt noReply incoming persistence; restoring the old copy fails the regression. Independent final review approved with no remaining findings. Synthetic model replies and lack of a full autonomous LLM/TUI acceptance run remain broader caveats, not an uncovered part of this metadata-ownership issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions