Skip to content

Commit 1efd78b

Browse files
Pigbibicodex
andcommitted
Clarify TQQQ present CLI and output root contract
Co-Authored-By: Codex <noreply@openai.com>
1 parent 478059a commit 1efd78b

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/quant_strategy_plugins/tqqq_market_regime_control_present.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""T2B2 PRESENT capture CLI is ``python -m quant_strategy_plugins.tqqq_market_regime_control_present``; direct src-file execution is outside the public contract."""
2+
13
from __future__ import annotations
24

35
import base64
@@ -28,6 +30,7 @@
2830
STRATEGY = "tqqq_growth_income"
2931
PLUGIN = "market_regime_control"
3032
MODE = "shadow"
33+
PUBLIC_CLI_INVOCATION = "python -m quant_strategy_plugins.tqqq_market_regime_control_present"
3134

3235
REQUIRED_INPUTS = frozenset(
3336
{
@@ -263,7 +266,7 @@ def _csv_path(value: object) -> str:
263266
def _admit_output_root(value: str, root: Path) -> Path:
264267
lexical = Path(value)
265268
if not lexical.is_absolute():
266-
lexical = Path.cwd() / lexical
269+
lexical = root / lexical
267270
try:
268271
if lexical.is_symlink():
269272
_fail(IDENTITY_INVALID, 2)

tests/test_tqqq_market_regime_control_present.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,29 @@ def test_ignored_in_checkout_output_root_is_admitted(tmp_path: Path, monkeypatch
302302

303303
assert error.value.code == "T2B2_PRODUCER_ARTIFACT_INVALID"
304304
assert (tmp_path / "output").is_dir()
305+
306+
307+
def _checkout_root(tmp_path: Path) -> Path:
308+
subprocess.run(("git", "init", "-q", str(tmp_path)), check=True)
309+
(tmp_path / ".gitignore").write_text("output/\n", encoding="utf-8")
310+
return tmp_path
311+
312+
313+
def test_public_cli_contract_uses_package_module_not_direct_source_file() -> None:
314+
assert present.PUBLIC_CLI_INVOCATION == "python -m quant_strategy_plugins.tqqq_market_regime_control_present"
315+
316+
317+
def test_relative_output_dir_is_resolved_from_verified_checkout_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
318+
root = _checkout_root(tmp_path)
319+
invocation_dir = tmp_path / "other-working-directory"
320+
invocation_dir.mkdir()
321+
monkeypatch.chdir(invocation_dir)
322+
323+
assert present._admit_output_root("output/present", root) == root / "output" / "present"
324+
325+
326+
def test_trusted_local_output_outside_checkout_remains_admitted(tmp_path: Path) -> None:
327+
root = _checkout_root(tmp_path)
328+
outside = tmp_path.parent / f"{tmp_path.name}-outside-output"
329+
330+
assert present._admit_output_root(str(outside), root) == outside.resolve(strict=False)

0 commit comments

Comments
 (0)