Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

- name: "Venv husks | Stage the provenance module onto the node (#17339)"
ansible.builtin.copy:
src: "{{ playbook_dir }}/../../../autobot-slm-backend/venv_provenance.py"
src: "{{ role_path | default(playbook_dir ~ '/x') }}/../../../../autobot-slm-backend/venv_provenance.py"
dest: "{{ autobot.base_dir }}/venv_provenance.py"
owner: "{{ autobot.user }}"
mode: "0644"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

- name: "Shared manifests | Stage constraints/shared.txt onto the node (#17331)"
ansible.builtin.copy:
src: "{{ playbook_dir }}/../../../constraints/shared.txt"
src: "{{ role_path | default(playbook_dir ~ '/x') }}/../../../../constraints/shared.txt"
dest: "{{ autobot.base_dir }}/constraints/shared.txt"
owner: "{{ autobot.user }}"
mode: "0644"
Expand All @@ -53,7 +53,7 @@
# It declares no includes of its own, so staging it needs nothing further.
- name: "Shared manifests | Stage the root requirements.txt onto the node (#17331)"
ansible.builtin.copy:
src: "{{ playbook_dir }}/../../../requirements.txt"
src: "{{ role_path | default(playbook_dir ~ '/x') }}/../../../../requirements.txt"
dest: "{{ autobot.base_dir }}/requirements.txt"
owner: "{{ autobot.user }}"
mode: "0644"
Expand Down
4 changes: 2 additions & 2 deletions autobot-slm-backend/ansible/roles/ai-stack/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@
group: "{{ ai_group }}"
mode: "0644"
loop:
- "{{ playbook_dir }}/../../../autobot-infrastructure/shared/docker/ai-stack/ai_api_server.py"
- "{{ playbook_dir }}/../../../autobot-infrastructure/shared/docker/ai-stack/ai_container_main.py"
- "{{ role_path }}/../../../../autobot-infrastructure/shared/docker/ai-stack/ai_api_server.py"
- "{{ role_path }}/../../../../autobot-infrastructure/shared/docker/ai-stack/ai_container_main.py"
notify: restart ai-stack
tags: ['ai', 'deploy']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

- name: Copy AutoBot application files
synchronize:
src: "{{ playbook_dir }}/../"
src: "{{ role_path }}/../../"
dest: "{{ autobot.base_dir }}/app/"
rsync_opts:
- "--chmod=o-w" # #19503
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

- name: Deploy AutoBot dashboards
ansible.builtin.copy:
src: "{{ playbook_dir }}/../../../autobot-infrastructure/shared/config/grafana/dashboards/"
src: "{{ role_path }}/../../../../autobot-infrastructure/shared/config/grafana/dashboards/"
dest: /var/lib/grafana/dashboards/
owner: root
group: grafana
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
become: false
ansible.builtin.command:
cmd: git rev-parse HEAD
chdir: "{{ playbook_dir }}/../../.."
chdir: "{{ role_path }}/../../../.."
register: git_commit_result
changed_when: false
# (#2872) Intentional: git may not be available on the Ansible controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

- name: "Grafana | Deploy AutoBot dashboards"
ansible.builtin.copy:
src: "{{ playbook_dir }}/../../../autobot-infrastructure/shared/config/grafana/dashboards/"
src: "{{ role_path }}/../../../../autobot-infrastructure/shared/config/grafana/dashboards/"
dest: /var/lib/grafana/dashboards/
owner: root
group: grafana
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
# Issue #937: Sync and install autobot_shared before requirements (prometheus metrics)
- name: "SLM | Sync autobot_shared to SLM server"
ansible.posix.synchronize:
src: "{{ playbook_dir }}/../../../autobot_shared/"
src: "{{ role_path }}/../../../../autobot_shared/"
dest: "{{ slm_base_dir }}/autobot_shared/"
rsync_opts:
- "--chmod=o-w" # #19503
Expand Down
4 changes: 2 additions & 2 deletions autobot-slm-backend/ansible/roles/tts-worker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
# not this file, so `ansible_requirements_parity_test` failed #18105 on a shard. One
# declaration now -- the manifest -- read here instead of restated.
#
# Read from the CONTROLLER via playbook_dir, the same anchor
# Read from the CONTROLLER via role_path, whose depth is fixed (#20509), the same anchor
# `_shared/tasks/stage_shared_manifests.yml` uses for `constraints/shared.txt`; the
# component manifest is not synced to the node, so it cannot be read from there.
#
Expand All @@ -238,7 +238,7 @@
- name: "TTS Worker | Read the torch requirement from the component manifest (#18127)"
ansible.builtin.set_fact:
_tts_torch_requirement: >-
{{ lookup('file', playbook_dir ~ '/../../../autobot-tts-worker/requirements.txt')
{{ lookup('file', role_path ~ '/../../../../autobot-tts-worker/requirements.txt')
| regex_search('^torch(?![A-Za-z0-9_.-])[^\s#]*', multiline=True) }}
tags: ['tts', 'packages']

Expand Down
5 changes: 5 additions & 0 deletions repo_tests/_reach_policy_verdicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"Workflow files are a subset of tracked YAML (#20191); compose, ansible and filter files grow "
"at their own rate, so a share of all YAML would sink with nothing wrong.",
),
"role-source-paths-depth-proof-20509": (
ABSOLUTE,
"SUBSET_DRIFTS",
"Ansible YAML under roles, a subset of tracked files that grows at its own rate.",
),
"operational-docs-playbook-references-19611": (
ABSOLUTE,
"SUBSET_DRIFTS",
Expand Down
1 change: 1 addition & 0 deletions repo_tests/_reach_roots_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@
"scripts",
"tools",
),
"repo_tests/role_source_paths_depth_proof_20509_test.py": ("autobot-slm-backend/ansible/roles",),
"repo_tests/root_resolver_single_source_18101_test.py": (
"autobot-backend",
"autobot-slm-backend",
Expand Down
1 change: 1 addition & 0 deletions repo_tests/reach_scope_claim_17844_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def test_a_declared_scope_that_the_sweep_does_not_reach_is_refused() -> None:
#: Compared as a SET in both directions. Adding a scoped declaration means adding a line here,
#: and that is the point -- the scope is a decision, so it is written twice on purpose.
_DECLARED_SCOPES = {
"role-source-paths-depth-proof-20509": ("autobot-slm-backend/ansible/roles",),
"operational-docs-playbook-references-19611": (
".claude",
"autobot-infrastructure",
Expand Down
57 changes: 57 additions & 0 deletions repo_tests/role_source_paths_depth_proof_20509_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2025-2026 mrveiss
# SPDX-License-Identifier: Apache-2.0
"""#20509: a role never reaches repo files through playbook_dir, whose depth depends on the playbook."""

from __future__ import annotations

import re
from pathlib import Path

from repo_tests._paths import repo_root
from repo_tests._reach import declare

from tools.lint._scan_helpers import EmptyEnumeration, tracked_paths

_ROLES = "autobot-slm-backend/ansible/roles"
#: Any climb out of playbook_dir, in either spelling: its depth depends on which playbook ran.
_BAD = re.compile(r"""playbook_dir\s*(?:\}\}|~\s*['"])/\.\.""")


def _role_yaml(root: Path) -> list[Path]:
try:
return [root / rel for rel in tracked_paths(root, _ROLES) if rel.endswith((".yml", ".yaml"))]
except EmptyEnumeration:
return []


REACH = declare(
"role-source-paths-depth-proof-20509",
discover=_role_yaml,
floor=189, # mid-window: population 209, window (169, 209)
growth=40,
what="Ansible YAML files",
roots=(_ROLES,),
)


def _offenders(text: str) -> bool:
return any(_BAD.search(line) for line in text.splitlines() if not line.lstrip().startswith("#"))


def test_no_role_reaches_the_repo_through_playbook_dir() -> None:
bad = [str(p) for p in REACH.examined(repo_root()) if _offenders(p.read_text(encoding="utf-8"))]
assert not bad, f"use role_path, whose depth is fixed: {bad}"


def test_contrast_the_old_form_is_caught() -> None:
assert _offenders('src: "{{ playbook_dir }}/../../../constraints/shared.txt"')
assert _offenders("""lookup('file', playbook_dir ~ '/../../../x/requirements.txt')""")
assert _offenders('chdir: "{{ playbook_dir }}/../../.."')
assert _offenders('src: "{{ playbook_dir }}/../"')
assert not _offenders('src: "{{ role_path }}/../../../../constraints/shared.txt"')
assert not _offenders("# the comment may say {{ playbook_dir }}/../")


def test_the_ai_stack_copies_from_its_own_tree() -> None:
text = (repo_root() / _ROLES / "ai-stack/tasks/main.yml").read_text(encoding="utf-8")
assert "{{ role_path }}/../../../../autobot-infrastructure/shared/docker/ai-stack/ai_api_server.py" in text