Skip to content

WP-O2: origin dimension — tolerant resolver + derivation#2825

Open
byteclimber wants to merge 2 commits into
mainfrom
feat/origin-dimension
Open

WP-O2: origin dimension — tolerant resolver + derivation#2825
byteclimber wants to merge 2 commits into
mainfrom
feat/origin-dimension

Conversation

@byteclimber

@byteclimber byteclimber commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of the origin-dimension rename: adobe/serenity-docs#46. Combines WP-O2a (tolerant resolver + root rename) and WP-O2b (derivation).

WP-O2a

  • Renamed DIMENSION.SOURCEDIMENSION.ORIGIN, SOURCE_VALUEORIGIN_VALUE, etc. in prompt-tags.js
  • Added resolveAuthorshipRoot in tag-tree.js: reuses an existing origin root, else adopts a legacy source root only if its children ⊆ {ai, human}, else mints a new origin root. Wired into ensureDimensionRoots.
  • handlers/tags.js, markets-subworkspace.js, brand-provisioning.js, serenity.js needed no changes — they already resolve via the shared constants.
  • Deliberately left src/support/elements/** untouched (separate, already-flagged production-triage concern).

WP-O2b

  • makeTypeInjector now strips+injects origin: CREATE derives ai/human, UPDATE re-injects the already-stored value, never re-derives.
  • New resolveOriginForWrite(candidate, isServicePrincipal): service principal may assert a value (invalid falls back to human), user principal always overridden to human.
  • Removed the origin PATCH path from updatePromptById and the || 'human' fallback from mapRowToPrompt.
  • OpenAPI docs updated to describe origin as service-principal-only on write.

Test plan

  • Targeted unit slice (serenity + prompts-storage + brands + serenity-controller): 1696/1696 passing
  • Full suite: 14873/14877 (4 failures are pre-existing test/controllers/audits.test.js order-dependent flakes, unrelated, pass in isolation)
  • Lint + tsc type-check clean
  • it-postgres serenity IT suite not updated — it drives the real mock Docker image still pinned at @adobe/spacecat-shared-project-engine-client@1.10.0 (pre-WP-O1). Needs a follow-up once WP-O1: rename authorship tag root from source to origin (PE-client mock) spacecat-shared#1815 (WP-O1) releases and this repo's dependency bumps.

Depends on: adobe/spacecat-shared#1815 (WP-O1) for full IT verification.

Closes #2816, #2817
Jira: SITES-48001, SITES-48002 · Tracking: cross-repo plan in adobe/serenity-docs#46

🤖 Generated with Claude Code

…rigin

WP-O2a: renames DIMENSION.SOURCE -> DIMENSION.ORIGIN (and SOURCE_VALUE ->
ORIGIN_VALUE) in prompt-tags.js, and gives the authorship root its own
tolerant resolver in tag-tree.js (resolveAuthorshipRoot): it reuses an
existing `origin` root, else adopts a legacy `source` root whose children
are a subset of {ai, human}, else mints a new `origin` root — never a
second, empty one. ensureDimensionRoots/provisionDimensionTree/
ensureClosedValue route through this resolver instead of blind-creating
the authorship root. parseCreateTagBody and the provisioning seams in
markets-subworkspace.js already validate/seed against ALL_DIMENSIONS/
DIMENSION_ROOT_NAMES, so they pick up the rename automatically.

WP-O2b: generalizes makeTypeInjector (handlers/prompts.js, and its
subworkspace twin) to also strip+inject `origin` on every prompt write:
CREATE always derives to `ai`; UPDATE re-injects whichever `origin` tag
the request already carries (never re-derived), falling back to `ai`
only if none is found. prompts-storage.js's upsertPrompts now derives
`origin` from the caller's authenticated principal (service principal:
honor an asserted ai/human value; user principal: always override to
human) via the new resolveOriginForWrite; updatePromptById no longer
accepts `origin` in a PATCH body; mapRowToPrompt drops the `|| 'human'`
read fallback. brands.js wires isServicePrincipal from context.s2sConsumer
into upsertPrompts. OpenAPI docs updated to describe the new origin
semantics without changing the query filter/sort surface.

Tracks WP-O2a (spacecat-api-service#2816, SITES-48001) and WP-O2b
(spacecat-api-service#2817, SITES-48002) from serenity-docs PR #46.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@byteclimber byteclimber requested a review from MysticatBot July 15, 2026 14:45
@byteclimber byteclimber marked this pull request as ready for review July 15, 2026 15:29
@github-actions

Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@byteclimber

Copy link
Copy Markdown
Contributor Author

Related: #2785 (intent-classification) touches the same files (prompt-tags.js, tag-tree.js) — worth reviewing/merging in a coordinated order to avoid conflicts.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WP-O2a: tolerant resolver (origin/source) + root rename

1 participant