Skip to content

[Bug]: store editable does not stop the owner's increments, so an approved record's value can still change #989

Closed

Description

@jimhoyd

Found in an adversarial review of #984 (#952).

Runtime revision and environment

main at 348920f, Node 26 with node:sqlite, macOS, store package test harness (test/direct.ts).

Summary

editable refuses PUT/PATCH outside the named states, but POST <mount>/<id>/increment/<property> still changes the record. On an owned collection the owner can run it. So a collection declaring both editable and increments lets the owner change a value of a record after it was approved.

packages/store/SECURITY.md and docs/STORE.md do list increments as not gated. But the guarantee the feature is sold on says otherwise:

  • STORE.md: "editable is what keeps the approved version as it was".
  • The authoring contract: "so an approved request keeps the values its reviewer saw".

Activation accepts the combination silently.

Minimal reproduction

requests:
  mount: /api/requests
  ownership: owner
  schema: {type: object, additionalProperties: false, required: [title, amount, status], properties: {title: {type: string, maxLength: 120}, amount: {type: integer, minimum: 1, maximum: 100000}, status: {type: string, enum: [draft, pending, approved]}}}
  defaults: {status: draft, amount: 1}
  readOnlyProperties: [status]
  increments: [amount]
  editable: {status: draft}
  deletable: {status: draft}
  transitions:
    submit: {from: {status: draft}, set: {status: pending}}
    approve: {from: {status: pending}, set: {status: approved}, by: others, mount: /api/approve, members: reviewers}

The owner creates {title: x, amount: 6}, submits it, and a reviewer approves it: amount is 6 and status is approved. Then the owner sends POST /api/requests/<id>/increment/amount.

  • Observed: 200 with amount: 7, status: approved. The same record's PATCH/PUT/DELETE correctly answer 409 record_locked, and the Allow header is GET, HEAD.
  • Expected: either the increment is refused outside editable (409 record_locked), or activation refuses an increments property on a collection that declares editable unless that property is excluded explicitly.

Also checked (sound)

  • A PUT naming status is refused.
  • An Idempotency-Key replay of a pre-lock PATCH only replays (idempotency-replayed: true) and writes nothing.
  • Another owner's list carries an empty allow.

Assumed

Not every increments use needs gating: a view counter on a published record probably should keep counting. So this may be a documentation fix (drop the unconditional "keeps the values its reviewer saw") plus an opt-in, rather than a behavior change. That is a design decision for the maintainer.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions