Styxis
Company
Knowledge

jq delpaths: agreeing on deletion targets before mixed-sign paths change an array

Hand over deletion targets resolved against the original snapshot, rather than positions in an array that is changing during deletion.

jq delpaths: agreeing on deletion targets before mixed-sign paths change an array

When several array paths are deleted together, an earlier deletion can alter the interpretation of a later position. Negative indexes depend on the current length, so rereading the original request against a shortened array may select another target. Fix target identities from the pre-operation snapshot to preserve the request. [1, 2, 3]

What the primary source establishes

A jq report describes mixed positive and negative indices at non-leaf path levels producing results consistent with subsequent positions being evaluated against a shortened array. Leaf-level mixtures and uniformly signed path controls produce the expected result. [1]

The handover decision

Requester and executor should resolve all paths against the original snapshot first, then reconcile the actual deleted-ID set before reporting completion. Keep original_path, resolved_item_id, requested_delete, and actually_deleted so equal deletion counts cannot conceal different targets. [1, 3]

A reference defined before the output

The illustrative original targets are values 4 and 6. If 3 disappears while 4 remains, the unrequested-deletion count is 1 even when the total count matches. A count of 0 unrequested deletions is the normal case. Target identity, rather than an unchanged count, determines whether the request was respected. [1, 3]

The scoped Truthound check

Truthound Core 3.3.2 can compare actual deleted IDs with the originally approved set using DistinctValuesEqualSetValidator. Do not reinterpret the original negative paths against only the remaining array. Rollback and execution blocking belong to the operational layer consuming the reconciliation result. [1, 2, 3]

Limits and alternative choices

Without stable IDs, preserve original positions together with the snapshot; the check itself does not roll back deletion. Normalize paths against the original or construct a new array using explicit identifiers. If the contract intentionally specifies sequential deletion, each step's updated positions are the reference instead. [1, 3]

Application conditions

Resolve paths against the preserved original snapshot and prepare requested and actual target-ID inventories independently.

Alternatives

Normalize paths against the original or construct a new array using explicit identifiers.

Limitations

  • Without stable IDs, preserve original positions together with the snapshot; the check itself does not roll back deletion.

Evidence

Event checked
Subject checked
Modified