Skip to content

[AI-3] Provision the LLM connection from the environment - #24887

Open
tangopium wants to merge 5 commits into
feature/66020-pr08-embedding-detectionfrom
feature/66020-pr09-environment-provisioning
Open

[AI-3] Provision the LLM connection from the environment#24887
tangopium wants to merge 5 commits into
feature/66020-pr08-embedding-detectionfrom
feature/66020-pr09-environment-provisioning

Conversation

@tangopium

@tangopium tangopium commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Ticket

AI-3

What are you trying to accomplish?

PR 9 of 11 in the AI-3 stack. Adds the OPENPROJECT_LLM__CONNECTION setting and an EnvData seeder, so an on-premise deployment can ship the connection alongside its LLM sidecar without touching the UI. When the setting is present the record belongs to the deployment: the form renders read-only with a banner, the destructive actions refuse, and the contract rejects any write. Seeding must not fail because of a server that has not finished starting, so the environment path skips the reachability probe and refreshes the catalogue in a background job.

Merge checklist

  • Added/updated tests
  • Added/updated documentation (env var list regenerated)
  • Behind the llm_connection feature flag

Stacked on #24886.

@github-actions

Copy link
Copy Markdown

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

@github-actions

Copy link
Copy Markdown

Caution

The Enterprise plan field is not set on the work package

Details:

Please make sure that:

  • The work package Enterprise plan field is set

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dcefe085a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/seeders/env_data/llm_connection_seeder.rb Outdated
@tangopium
tangopium force-pushed the feature/66020-pr09-environment-provisioning branch from dcefe08 to fa61b44 Compare August 22, 2026 15:05
@tangopium tangopium changed the title [#66020] Provision the LLM connection from the environment [AI-3] Provision the LLM connection from the environment Aug 22, 2026
@tangopium
tangopium force-pushed the feature/66020-pr09-environment-provisioning branch from fa61b44 to 4ca02db Compare August 22, 2026 15:26
@tangopium
tangopium force-pushed the feature/66020-pr09-environment-provisioning branch from 4ca02db to b33ce35 Compare August 22, 2026 15:51
Adds the OPENPROJECT_LLM__CONNECTION setting and an EnvData seeder, so an on-premise deployment can ship the connection alongside its LLM sidecar without touching the UI. When the setting is present the record belongs to the deployment: the form renders read-only with a banner, the destructive actions refuse, and the base contract rejects any write.

Seeding must not block on -- or fail because of -- a server that has not finished starting, so the environment path validates with its own contract that skips the reachability probe, and refreshes the catalogue through a background job instead of inline.

Part 9 of the AI-3 stack.

https://community.openproject.org/work_packages/66020
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/work_packages/table/queries/parent_field_ranking_spec.rb[1:1]
  • rspec ./spec/features/work_packages/table/switch_types_spec.rb[1:1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24887, linked for reference only):

- `rspec ./spec/features/work_packages/table/queries/parent_field_ranking_spec.rb[1:1]`
- `rspec ./spec/features/work_packages/table/switch_types_spec.rb[1:1:1]`

Treat this as a standalone task, unrelated to PR #24887. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24887 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @tangopium to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @tangopium, and request a review from @tangopium.
On every commit, set @tangopium as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@tangopium
tangopium force-pushed the feature/66020-pr09-environment-provisioning branch from b33ce35 to 786a84f Compare August 22, 2026 16:16
@tangopium
tangopium requested a review from thykel August 22, 2026 21:39
@tangopium tangopium self-assigned this Aug 22, 2026
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]
  • rspec ./modules/meeting/spec/features/meeting_notifications_spec.rb[1:2:1]
  • rspec ./modules/meeting/spec/features/meeting_notifications_spec.rb[1:2:2]
  • rspec ./spec/features/roles/report_spec.rb[1:2]
  • rspec ./spec/features/work_packages/table/switch_types_spec.rb[1:1:2]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24887, linked for reference only):

- `rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]`
- `rspec ./modules/meeting/spec/features/meeting_notifications_spec.rb[1:2:1]`
- `rspec ./modules/meeting/spec/features/meeting_notifications_spec.rb[1:2:2]`
- `rspec ./spec/features/roles/report_spec.rb[1:2]`
- `rspec ./spec/features/work_packages/table/switch_types_spec.rb[1:1:2]`

Treat this as a standalone task, unrelated to PR #24887. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24887 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @tangopium to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @tangopium, and request a review from @tangopium.
On every commit, set @tangopium as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

The seeder runs on every container start, so enqueuing a refresh there
undid whatever an administrator had curated, and could empty the list
when the new server answers nothing. Following the UX review with Tom,
the environment path now follows the same rule as the administration
page: fetch the model list once while nothing is stored, and leave a
stored list alone. A host or key changed in the environment shows up as
the stale warning on the AI models page, which asks for the refresh.
The default chat model moved off the LLM settings page onto the AI
models page in the UX review with Tom, and it moved out of reach of the
environment banner with it. It now renders like the server settings do
when the deployment owns the connection: the picker disabled, the banner
above it, no Save button that the base contract would only reject.

The autocompleter takes its disabled flag through autocomplete_options,
which is what reaches the Angular component; the field-level flag it had
before never left the Ruby side.

The API key caption follows the same idea: asking an administrator to
leave the field blank to keep the current key makes no sense where
nothing can be typed, so it says where the key comes from instead.
The reviewer thread on the seeder was answered with the backoff retry,
but nothing pinned it. The job now loops over every stored connection,
so the example also proves that a server which is not up yet stops the
run and comes back rather than silently leaving the connection without
its model list.
The connection defaults reference a model row, so an environment naming a
model the server has not been asked about yet had nothing to point at. The
seed enters that model the way an administrator entering one by hand would,
then writes the reference, both inside one transaction, and clears a default
the environment no longer names.

Provisioning also writes the AI features switch to its setting rather than to
the column it used to live in, and the catalogue fill is now enqueued when no
catalogue was ever fetched rather than when no model row exists, since
provisioning itself creates one.
@tangopium
tangopium force-pushed the feature/66020-pr09-environment-provisioning branch from 786a84f to 0c17575 Compare September 10, 2026 06:52
@tangopium

Copy link
Copy Markdown
Collaborator Author

The branch was rebuilt, so the commits your comments point at no longer exist and those threads now render as outdated. Nothing was dropped. Here is where each point landed.

  • The catalogue is filled once when provisioning, and the retry that a provisioned catalogue depends on is covered.
  • The default models are read-only while the environment owns the connection.
  • Because the defaults are references now, a model the environment names is entered as a row during provisioning, the way an administrator entering one by hand would. A default the environment stops naming is cleared.

CI has not started on the new commits: only the CLA check ran, and the workflow runs seem to need maintainer approval on this repository. The checks are waiting on that.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant