Skip to content

Update v2 sync with main#4903

Closed
midigofrank wants to merge 35 commits into
mainfrom
update-v2-sync-with-main
Closed

Update v2 sync with main#4903
midigofrank wants to merge 35 commits into
mainfrom
update-v2-sync-with-main

Conversation

@midigofrank

Copy link
Copy Markdown
Collaborator

Description

This PR [adds/changes/fixes]... (A description of your work goes here.)

Closes #__

Validation steps

  1. (How can a reviewer validate your work?)

Additional notes for the reviewer

  1. (Is there anything else the reviewer should know or look out for?)

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

taylordowns2000 and others added 30 commits May 8, 2026 09:41
Broaden the GitHub-sync repo+branch guard from "no ancestor may share"
to "no project in the same tree may share" (root, sandboxes, siblings,
cousins all share one (repo, branch) namespace), and move the
enforcement from a check-then-insert pattern in Elixir to a Postgres
unique index. Two concurrent transactions in the same project family
can no longer both succeed at READ COMMITTED.

- Add Lightning.Projects.root_id/1 walking parent_id to the top.
- Migration adds project_repo_connections.root_project_id (NOT NULL
  after backfill) and a unique index on
  (root_project_id, repo, branch).
- ProjectRepoConnection sets root_project_id on insert, declares
  unique_constraint(:branch, name: ...), and exposes
  tree_unique_violation?/1 so the boundary can translate the
  constraint violation back to :branch_used_in_project_tree.
- VersionControl.create_github_connection drops its in-memory
  pre-flight check and relies on the unique index for race-safety.
- Tests cover sibling/cousin collisions, the renamed error, and a
  direct INSERT race that's only resolvable by the index.

Co-authored-by: Claude <noreply@anthropic.com>
* Emit schema_version: '4.0' in v2 workflow and project YAML

Adds a top-level `schema_version` key after `id` and `name` in both the
TypeScript workflow serializer and the Elixir workflow/project serializer.
The v2 JSON schema is extended to permit the key so round-trip parsing
still passes its own validation. Parsers remain lenient — files without
the key continue to parse unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* formatting on yaml output

* add schema_version to v1

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* restore v1 spec emitter

* update test

* force lowercase ids in v2

* lowercase in frontend
…ization

Resolved conflicts:
- CHANGELOG.md: merged unreleased entries from both branches
- projects.ex: kept both root_id/1 and list_descendants/1
- projects_test.exs: kept describe blocks from both sides
- export_utils.ex + webhook_reply fixture: kept deleted (V2 refactor)
- yaml/util.ts: kept V2 pass-through refactor

Note: channels and webhook_response_config export are not yet ported to
the V2 serializer; the corresponding ported tests fail until a follow-up.
Brings two main-branch project-export features into the V2 portability
format that the v2-sync refactor had left unported:

- channels: emitted as a YAML array of objects (name, destination_url,
  enabled, destination_credential). The destination_credential reference
  uses V2's email|name credential-key form, consistent with a job's
  configuration: field.
- webhook_response_config: nested under the webhook trigger step with
  the success_code / error_code the user has set; omitted when unset.

Mirrored on the frontend (assets/js/yaml/v2.ts + schema) for
webhook_response_config serialize/parse parity (channels are
project-level, backend-only).

The inherited tests asserted the v1/main shapes (a triggers: map and
hyphenated credential refs); rewritten to the V2 steps-array shape. Also
updated two pre-existing project-export tests that hadn't been adjusted
when schema_version emission was added.
- Preserve webhook_response_config on import: the webhook branch of
  convertWorkflowSpecToState dropped the configured success/error status
  codes on every v2 import, unlike the cron and kafka branches.
- Default a trigger's enabled to false on parse, matching the serializer,
  the Elixir emitter, and the Trigger schema default; parse previously
  defaulted to true, so the two directions of the module disagreed.
- Round-trip JS conditions that collide with named condition literals: a
  js_expression body such as !state.errors is now preserved instead of
  being rewritten to on_job_success and dropping the expression.
- Add `|` to the quote whitelist so credential keys (email|name) and
  `||` conditions stay unquoted, matching the Elixir emitter and avoiding
  byte-different YAML for the same workflow.

Correct the stale module-doc comments and add round-trip tests covering
each case.
The v2 project export preloaded the full credential chain
(project_credential -> credential -> user) on every job and every
channel, duplicating the project-level project_credentials that are
already loaded.

Build a project_credential_id -> "owner|name" lookup once from the
project's credentials and resolve each job's configuration: and each
channel's destination_credential: by id. workflow_struct_to_canonical
now takes a :credential_keys option; serialize_workflow/1 has no project
context, so it omits the option and falls back to the job's preloaded
project_credential. Drop the redundant nested credential preloads from
preload_project_for_export.

Add a test covering a job whose configuration resolves from the project
credentials by id.
@midigofrank midigofrank self-assigned this Jun 29, 2026
@github-project-automation github-project-automation Bot moved this to New Issues in Core Jun 29, 2026
@midigofrank midigofrank changed the base branch from main to v2-sync-finalization June 29, 2026 07:27
@midigofrank midigofrank changed the base branch from v2-sync-finalization to main June 29, 2026 07:31
@midigofrank

Copy link
Copy Markdown
Collaborator Author

Dupilicate of #4722

@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants