Skip to content

bug(api): replace_artifact omits HTTP 409 from OpenAPI #2551

In review

Description

@frf12

Describe the bug

PUT /v1/scopes/{scope_id}/artifacts/{family}/{artifact_id} (replace_artifact) can return HTTP 409 for an Atomic Memory lifecycle conflict, but its response list in the canonical OpenAPI contract does not declare 409.

The gap is present on master at c4c95e465. The Atomic Memory workflow already documents invalid_memory_state as a 409 response.

Steps to reproduce

  1. Read an active Atomic Memory A and retain its content ETag, for example "revision:1".
  2. Allow memory processing to merge A into a successor C. A's content revision remains 1, while its lifecycle becomes merged.
  3. Submit a complete replacement to A's original replace_artifact URL with the retained If-Match value.
  4. Compare the returned status with the operation's declared OpenAPI responses.

This sequence occurred during a real Codex integration run: a search returned A as active, and the subsequent replacement encountered the merged state. Reading the successor and updating it succeeded.

Expected behavior

The OpenAPI operation declares the existing HTTP 409 response and its error schema. The server continues rejecting edits to merged or retired inputs.

Actual behavior

The server correctly returns:

{
  "error": {
    "code": "invalid_memory_state",
    "message": "merged and retired Artifacts cannot be edited",
    "details": null
  }
}

The operation declares 412, 422 and other errors, but omits 409. Consumers of the canonical contract therefore cannot discover this supported conflict response from that operation.

Environment

  • Runtime observation: PowerContext 1.5.0, Python 3.12, Linux x86_64.
  • Contract checked against upstream master c4c95e465775b5b87ccac796194e01086bd7cc8f.

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Activity

  1. added
    bug
    documentation
    on Nov 9, 2026
  2. moved this from Todo to In progress in PowerContexton Nov 9, 2026
  3. Lumea-art commented on Nov 30, 2026

    @Lumea-art
    Contributor

    I'll take this. The fix is in the canonical contract: declare the existing 409 Conflict response on replace_artifact, matching the invalid_memory_state behavior already documented for Atomic Memory, then regenerate the Python/JS/Desktop artifacts and add the contract assertion so the response list cannot regress. A stale replacement after a merge is exactly the case to cover: the content revision still matches, but the lifecycle state makes the write conflict.

  4. added
    module:core
    on Dec 2, 2026
  5. hireview001 commented on Dec 2, 2026

    @hireview001
    Collaborator

    This issue belongs to the Core module. @hidb4ai, please lead follow-up, with support from @frf12, @Fengzdadi, @beatenevo. Please provide a substantive response within 72 hours of issue creation, outlining the proposed disposition, any additional information needed, or the next investigation steps. After sufficient discussion and agreement on the scope and acceptance criteria, a contributor who volunteers to take it on can undertake implementation.

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

Metadata

Metadata

Assignees

Labels

bugdocumentationmodule:core

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions