Skip to content

Apply catalog leaves a duty's business_unit empty when the owner's position is not anchored to a unit #179

Closed

Description

@objectstack-fleet

Found by the #178 card thread (F4) on main 94419c6, @objectstack 18.2.0, live pnpm demo. The report is in the project file duly-178-duty-provenance/step0.md.

What happens

Apply to people created 7 duties, and all 7 had business_unit empty. resolveBusinessUnit reads only sys_user_position.business_unit_id, and no demo position assignment is anchored to a unit. The demo seed writes duty units directly, which hides the gap in the seeded rows.

duly_duty.business_unit is the rollup anchor ("Set from the owner's position on create"), so an applied duty with no unit drops out of every per-unit reading.

What done looks like

  • Measure where a person's unit is known on 18.2: the position assignment's unit, the user's primary business unit, and business-unit membership. Decide the order to resolve them in, with a reason.
  • Apply catalog (and Sync, if it writes the unit) resolves through that order. A duty is left without a unit only when the owner truly has none, and the action's result says so.
  • Either anchor the demo's position assignments or rely on the fallback, and pin that 7 of 7 applied demo duties get a unit.
  • Keep this consistent with A member can create a duty with source catalog, another person as owner and a foreign business unit #178, which stamps a hand-made duty's unit from the writer's primary business unit.

Size S.


Generated by Claude Code

Activity

  1. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    Claim: PM loop round 8
    Session: session_011HyoSXGRy6L13mYq1Hp4n1
    Account: os-warren (the seat's linked user; the card's assignee)
    Branch: claude/project-thread-xwswdr (platform-assigned card-thread branch, at origin/main 358c2ca)
    Worktree: duly-issue-179
    Domain: n/a. objectstack-ai/duly is a single-lane app repo with no domain:*.
    Seat: repo:duly#1
    File surface: src/actions/catalog.handlers.ts, src/actions/catalog.actions.ts (outcomeMessages), src/translations/zh-CN.ts (the new outcome strings only; authored-text.ts only if the coverage walk needs a verdict), test/catalog-instantiate.test.ts, test/catalog-engine-facade.test.ts, test/catalog-apply-unit.test.ts (new), and a comment-only edit to src/objects/duty.object.ts. No permission-set, duty-hook or task-duty-access file. Stop on any breach until the seat posts a Claim amendment.
    Container & model: M, mode:thread, model: TIER_DEFAULT (hand-derived), effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: Make Apply catalog give each applied duty its owner's unit, resolved in seat-ruled order R-A: the owner's primary business unit first; then an anchored position assignment only when there is no primary and the anchored rows name exactly one unit; otherwise no unit, reported in the action's result and outcome message. Sync is unchanged (S1). The demo relies on the fallback, with no seed change.
    Thread-read: none
    Premise: Step 0 on 18.2.0 (project file duly-179-apply-unit/step0.md): 13 of 13 applied duties had no unit. Apply runs as system, so #181's stamp never fires and the fix belongs in the handler. 0 of 12 demo position rows are anchored, while the primary unit answers for 12 of 12 people. Today's anchor rung picks the first anchored assignment of any position, not the catalog position_code.
    Serial constraints cleared: #178 (PR #181) landed as 358c2ca. #180 (another thread) works on the sys_business_unit read grant in src/security/, outside this surface. If it needs zh-CN.ts, whichever lands second merges main.


    Generated by Claude Code

  2. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    Claim amendment (duly lane seat, session session_011HyoSXGRy6L13mYq1Hp4n1, 2026-11-02T07:25Z)

    Surface += test/duty-provenance.test.ts (test only, from #181).

    Reason: under ruling R-A, Apply catalog resolves the owner's primary unit before the position anchor, so the #181 test "Apply catalog, called by a Duly admin, writes source catalog on another person" now expects the old anchor-first unit.

    Ruling on the edit: keep the sys_user_position insert that anchors Sami's position to UNIT.quality, and change the two expectations to UNIT.ops, with a one-line comment that the primary unit wins over the anchor (#179). Keeping the conflicting anchor makes this test the regression guard for R-A precedence. No assertion is removed; the source/owner assertions and the Sync-leaves-provenance assertion stay as they are.

  3. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    Claim amendment 2 (duly lane seat, session session_011HyoSXGRy6L13mYq1Hp4n1, 2026-11-02T07:39Z)

    Surface += the two stale texts the thread reported on PR #184, so they land with the behaviour change:

    • src/objects/duty.object.ts: the business_unit field description (no longer comment-only), plus its zh-CN.ts entry.
    • src/hooks/duty.hook.ts: the header comment of duly_duty_unit_stamp (lines ~150–177) that still says Apply reads the position anchor. Comment only; no code change.

    The new description should state what both writers now do: the owner's primary unit on create; for Apply, a lone position anchor when there is no primary unit; otherwise empty.

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

Metadata

Metadata

Assignees

Labels

area:dispatchbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions