Skip to content

Add a kb-edit operation to append addressed-by references to records #785

Description

@williamthorsen

Problem

#763 added the addressed-by/addresses relation (a problem record points to whatever responded to it) but shipped no tool to write it. Populating addressed-by on an existing record means hand-editing frontmatter, which is error-prone and bypasses the schema validation and atomic-write guarantees the kb-edit helper already provides.

Context

addressed-by is the canonical, recall-facing side of the relation: recall reads it, lifts it onto the retrieved candidate, and surfaces it flat, so a recurring problem carries its known response when it is recalled. Entries are heterogeneous and free-form (a KB wikilink or relative path, a commit SHA, a PR/issue ref, or a URL) because the responder is often external; #763 validates only that the field is a list (the frontmatter.list rule), not the form of each entry. #763 is merged, so the contract this writes against is fixed.

kb-edit already offers targeted, mechanical, atomic mutations (--bump-updated, --verify, --append, --retag, --supersede-with), each resolving the writable KB that owns the note, validating the result against the destination schema, and writing atomically. Appending a response reference fits that model.

A common workflow motivates writing several records at once: one response (a fix assertion, a PR) often resolves multiple recurring incidents. The operation therefore accepts more than one target record in a single invocation.

Proposed solution

Add a kb-edit operation that appends one or more references to the addressed-by list of one or more target records:

  • It accepts one or more target record paths and applies the same reference(s) to each, relaxing kb-edit's single-positional rule for this operation only. (--supersede-with stays 1:1.)
  • Per target, it creates addressed-by when absent, preserves existing entries, appends the new ones, and de-duplicates in first-occurrence order, then bumps updated:. The written value is always a sequence, satisfying Add an addressed-by/addresses relation linking problems to their responses #763's list-shape validation; entries are stored free-form, with no validation of reference form.
  • References are supplied as a delimited value, each entry trimmed and empties dropped; an entirely empty value is rejected.
  • Each target is written independently through the existing atomic single-file path. Because the append de-duplicates, the operation is idempotent: a partial batch failure is reported per record and is safe to re-run, so no cross-file rollback is introduced. Each write is still validated against the destination schema, and a record whose resulting frontmatter fails validation is reported as that record's failure without aborting the others.

Deferred

The optional inverse addresses write (stamping the back-reference on a responder that is itself a vault note) is out of scope. Recall reads only addressed-by, so the inverse improves no retrieved result today; it earns its keep only alongside a future reverse-query feature ("given a response, surface the problems it addressed") and should be specified with it.

Acceptance criteria

Must have

  • A kb-edit operation appends one or more references to a record's addressed-by list, creating the field when absent and preserving and de-duplicating existing entries.
  • The operation accepts one or more target records in a single invocation and applies the same reference(s) to each.
  • Accepted reference forms match Add an addressed-by/addresses relation linking problems to their responses #763 (KB wikilink or relative path, commit SHA, PR/issue ref, URL): entries are stored free-form, and the written value satisfies Add an addressed-by/addresses relation linking problems to their responses #763's list-shape validation.
  • The operation follows the existing kb-edit single-operation, atomic-write conventions; a partial failure across multiple targets is reported per record and leaves each written record valid.
  • New behavior is covered by tests.
  • kb-edit documentation (SKILL.md) describes the operation, its multi-target invocation, and its result shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureAdded or improved external functionalityscope:kb

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions