@databricks-solutions/lakebase-scm-utils 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/scripts/index.cjs +40 -21
  2. package/dist/scripts/index.d.cts +1 -1
  3. package/dist/scripts/index.d.ts +1 -1
  4. package/dist/scripts/index.js +39 -21
  5. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +2 -2
  6. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +2 -2
  7. package/dist/scripts/lakebase/collapse-heads.cli.cjs +2 -2
  8. package/dist/scripts/lakebase/collapse-heads.cli.js +2 -2
  9. package/dist/scripts/lakebase/detect-language.cli.cjs +2 -2
  10. package/dist/scripts/lakebase/detect-language.cli.js +2 -2
  11. package/dist/scripts/lakebase/doctor.cli.cjs +2 -2
  12. package/dist/scripts/lakebase/doctor.cli.js +2 -2
  13. package/dist/scripts/lakebase/get-connection.cli.cjs +2 -2
  14. package/dist/scripts/lakebase/get-connection.cli.js +2 -2
  15. package/dist/scripts/lakebase/index.cjs +40 -21
  16. package/dist/scripts/lakebase/index.d.cts +13 -4
  17. package/dist/scripts/lakebase/index.d.ts +13 -4
  18. package/dist/scripts/lakebase/index.js +39 -21
  19. package/dist/scripts/lakebase/infra-runner.cli.cjs +2 -2
  20. package/dist/scripts/lakebase/infra-runner.cli.js +2 -2
  21. package/dist/scripts/lakebase/new-migration.cli.cjs +2 -2
  22. package/dist/scripts/lakebase/new-migration.cli.js +2 -2
  23. package/dist/scripts/lakebase/schema-diff.cli.cjs +2 -2
  24. package/dist/scripts/lakebase/schema-diff.cli.js +2 -2
  25. package/dist/scripts/lakebase/schema-migrate.cli.cjs +2 -2
  26. package/dist/scripts/lakebase/schema-migrate.cli.js +2 -2
  27. package/dist/scripts/lakebase/scm-abandon-feature.cli.cjs +37 -22
  28. package/dist/scripts/lakebase/scm-abandon-feature.cli.js +34 -22
  29. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +2 -2
  30. package/dist/scripts/lakebase/scm-claim-feature.cli.js +2 -2
  31. package/dist/scripts/lakebase/scm-doctor.cli.cjs +36 -21
  32. package/dist/scripts/lakebase/scm-doctor.cli.js +36 -21
  33. package/dist/scripts/lakebase/scm-merge.cli.cjs +2 -2
  34. package/dist/scripts/lakebase/scm-merge.cli.js +2 -2
  35. package/dist/scripts/lakebase/scm-park-feature.cli.cjs +586 -0
  36. package/dist/scripts/lakebase/scm-park-feature.cli.d.cts +4 -0
  37. package/dist/scripts/lakebase/scm-park-feature.cli.d.ts +4 -0
  38. package/dist/scripts/lakebase/scm-park-feature.cli.js +546 -0
  39. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +2 -2
  40. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +2 -2
  41. package/dist/scripts/util/index.cjs +2 -2
  42. package/dist/scripts/util/index.js +2 -2
  43. package/package.json +2 -1
  44. package/scripts/lakebase/scm-abandon-feature.cli.ts +3 -3
  45. package/scripts/lakebase/scm-abandon-feature.ts +19 -83
  46. package/scripts/lakebase/scm-park-feature.cli.ts +150 -0
  47. package/scripts/lakebase/scm-park-feature.ts +71 -0
  48. package/scripts/lakebase/scm-release-claim.ts +146 -0
  49. package/templates/project/common/consort-capture.ts +121 -3
  50. package/templates/project/python/tests/__pycache__/conftest.cpython-314.pyc +0 -0
  51. package/templates/project/python/tests/conftest.py +90 -1
@@ -95,11 +95,100 @@ def _consort_emit_test_run(test_id, status, item):
95
95
  rel = str(Path(str(item.fspath))).replace(f"{root}/", "")
96
96
  out = root / ".consort"
97
97
  out.mkdir(parents=True, exist_ok=True)
98
+ ts = datetime.now(timezone.utc).isoformat()
98
99
  line = json.dumps(
99
- {"ts": datetime.now(timezone.utc).isoformat(), "test_id": test_id, "status": status, "file": rel, "kind": "behavior"}
100
+ {"ts": ts, "test_id": test_id, "status": status, "file": rel, "kind": "behavior"}
100
101
  )
101
102
  with open(out / "test-run.jsonl", "a", encoding="utf-8") as fh:
102
103
  fh.write(line + "\n")
104
+ # RECORD a durable per-test test.result into the agent-log AT RUN TIME (mirrors the TS reporter
105
+ # in consort-capture.ts) so the dashboard lights each behavior test the moment it runs, scrubbing
106
+ # lights it at its real run position, and a replay of the recording does the same.
107
+ _consort_record_test_result(out, test_id, status, rel, ts)
108
+ except (OSError, ValueError, TypeError):
109
+ pass
110
+
111
+
112
+ def _consort_test_owner(consort_dir, test_id, file_rel):
113
+ """Resolve (feature_id, story_id, ac_id) for a test id from the per-story test-lists — the
114
+ attribution the reporter lacks (it sees only id + file). Ids are unique only WITHIN a story, so a
115
+ reused id has several owners: (1) the owner whose scenario_file basename matches ``file_rel`` (a
116
+ client/e2e spec pins ITSELF); then (2) the owner in the feature currently on the build lane
117
+ (``next.json``) — a fitness/behavior test carries no scenario_file, so during THIS feature's build
118
+ its reused id belongs to the active feature (a sibling feature's same-id test already resolved via
119
+ (1)). Else None (skip, never mis-key). Mirrors consort-capture.ts resolveOwner. Scoped, best-effort."""
120
+ try:
121
+ import glob
122
+ import json
123
+ import os
124
+ import re
125
+
126
+ m = re.match(r"^(T\d+)", test_id or "")
127
+ base = m.group(1) if m else test_id
128
+ owners = [] # (feature, story, ac, scenario_file)
129
+ for p in glob.glob(os.path.join(str(consort_dir), "features", "*", "stories", "*", "test-list-per-story.json")):
130
+ try:
131
+ with open(p, encoding="utf-8") as fh:
132
+ o = json.load(fh)
133
+ except (OSError, ValueError):
134
+ continue
135
+ feat, story = o.get("feature_id"), o.get("story_id")
136
+ for it in o.get("items", []):
137
+ if it.get("id") in (test_id, base):
138
+ owners.append((feat, story, it.get("ac_id") or "unknown", it.get("scenario_file")))
139
+ if not owners:
140
+ return None
141
+ if len(owners) == 1:
142
+ return owners[0][:3]
143
+ # (1) the owner whose scenario_file matches the running file (unique match)
144
+ fb = os.path.basename(file_rel or "")
145
+ by_file = [o for o in owners if o[3] and os.path.basename(o[3]) == fb]
146
+ if len(by_file) == 1:
147
+ return by_file[0][:3]
148
+ # (2) fall back to the owner in the currently-building feature (one match only)
149
+ try:
150
+ with open(os.path.join(str(consort_dir), "next.json"), encoding="utf-8") as fh:
151
+ active = json.load(fh).get("feature")
152
+ except (OSError, ValueError):
153
+ active = None
154
+ if active:
155
+ by_feat = [o for o in owners if o[0] == active]
156
+ if len(by_feat) == 1:
157
+ return by_feat[0][:3]
158
+ return None
159
+ except (OSError, ValueError, TypeError):
160
+ return None
161
+
162
+
163
+ def _consort_record_test_result(out, test_id, status, file_rel, ts):
164
+ """Append a schema-shaped ``test.result`` to ``.consort/agent-log.jsonl`` (+ the corpus mirror when
165
+ a recording is in flight), identical in shape to the kit's emitAgentLogEvent output so the dashboard
166
+ fold reads it the same. Only for an attributable test; scoped except, never breaks the suite."""
167
+ try:
168
+ import json
169
+ import os
170
+
171
+ owner = _consort_test_owner(out, test_id, file_rel)
172
+ if not owner:
173
+ return
174
+ feat, story, ac = owner
175
+ line = json.dumps(
176
+ {
177
+ "timestamp": ts,
178
+ "level": "info",
179
+ "role": "driver",
180
+ "event": "test.result",
181
+ "message": f"TEST {test_id} {status}",
182
+ "metadata": {"feature_id": feat, "test_id": test_id, "status": status, "story_id": story, "ac_id": ac},
183
+ }
184
+ )
185
+ with open(os.path.join(str(out), "agent-log.jsonl"), "a", encoding="utf-8") as fh:
186
+ fh.write(line + "\n")
187
+ rec = (os.environ.get("LAKEBASE_CONSORT_RECORD_DIR") or "").strip()
188
+ if rec:
189
+ os.makedirs(rec, exist_ok=True)
190
+ with open(os.path.join(rec, "agent-log.jsonl"), "a", encoding="utf-8") as fh:
191
+ fh.write(line + "\n")
103
192
  except (OSError, ValueError, TypeError):
104
193
  pass
105
194