mikebridge commented on code in PR #44258:
URL: https://github.com/apache/superset/pull/44258#discussion_r4031683033


##########
superset/versioning/activity/creation.py:
##########
@@ -0,0 +1,183 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Synthetic "starting version" record for the activity stream (sc-120488).
+
+``operation_type=0`` transactions emit zero change records by design
+(see ``versioning/changes/listener.py``), so an entity's creation —
+Continuum's INSERT row, an importer's INSERT, or the retroactive
+pre-tracking baseline — exists in the versions API but never appears in
+the activity timeline. This module derives ONE synthetic record from the
+op=0 shadow row and its ``version_transaction`` so the panel can render
+the starting version as the oldest entry, previewable and restorable
+like any other version (the record carries the same ``version_uuid``
+the ``/versions/`` family resolves).
+
+Placement and gating live in the orchestrator: the record is appended
+only for the PATH entity (it inherits the activity endpoint's access
+gate — edit-gated once #44021 lands),
+only when the stream is not truncated, and never for
+``include="related"``. If retention pruned the op=0 row or its
+transaction, no record is synthesized — the timeline simply starts at
+the oldest surviving save.
+"""
+
+from __future__ import annotations
+
+from typing import Any
+
+import sqlalchemy as sa
+from flask_appbuilder import Model
+
+from superset.extensions import db
+from superset.versioning.activity.kinds import USER_FACING_KIND
+from superset.versioning.queries import derive_version_uuid
+
+#: ``kind`` value of the synthetic record. Like ``__meta__``, the dunder
+#: name keeps it out of the field-verb vocabulary; renderers dispatch on
+#: it explicitly.
+CREATION_RECORD_KIND = "__creation__"
+
+#: ``creation_kind`` machine values — the API ships these, never display
+#: strings; the frontend owns the user-facing copy in ONE constant.
+CREATION_KIND_PRE_TRACKING = "pre_tracking"
+CREATION_KIND_CREATED = "created"
+CREATION_KIND_IMPORTED = "imported"
+CREATION_KIND_UNKNOWN: str = "unknown"
+CREATION_KINDS: tuple[str, ...] = (
+    CREATION_KIND_PRE_TRACKING,
+    CREATION_KIND_CREATED,
+    CREATION_KIND_IMPORTED,
+    CREATION_KIND_UNKNOWN,
+)
+
+
+def _creation_kind_for(action_kind: str | None) -> str:
+    # pylint: disable=import-outside-toplevel
+    from superset.versioning.changes import (
+        ACTION_KIND_BASELINE,
+        ACTION_KIND_CLONE,
+        ACTION_KIND_IMPORT,
+    )
+
+    if action_kind == ACTION_KIND_BASELINE:
+        return CREATION_KIND_PRE_TRACKING
+    if action_kind == ACTION_KIND_IMPORT:
+        return CREATION_KIND_IMPORTED
+    if action_kind == ACTION_KIND_CLONE:
+        return CREATION_KIND_CREATED
+    # Unstamped ordinary inserts and historical retroactive baselines are
+    # indistinguishable. Do not invent creation provenance for either.
+    return CREATION_KIND_UNKNOWN

Review Comment:
   Good catch—addressed in d1b8e40921d59fc6eb2b1ccab4dc81737e9721b3. Ordinary 
tracked creates receive internal provenance from surviving INSERT shadows in 
their transaction, while old unstamped origins stay unknown and 
import/clone/restore precedence is preserved. Private stamps are filtered from 
public activity records, including mixed create/edit transactions. The create 
regressions failed with stamping disabled and passed after restoration; 223 
Python and 224 frontend tests pass locally, along with scoped pre-commit and 
live PostgreSQL/MySQL helper-level savepoint recovery checks. Full-application 
dialect coverage and current-head CI remain separate gates.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to