Skip to content

Commit 01828a0

Browse files
committed
refactor(services): rename tests + strip internal planning vocabulary
Renames test files / directory / functions to descriptive names and strips internal roadmap IDs (SVC-XX, CNT-XX, IDX-06, D-XX, phase_04). - Directory: phase_04_service_init_parity/ -> service_init_parity/ - Files: - test_svc01_starter_hash_cache.py -> test_starter_project_hash_gate.py - test_svc02_dependency_review.py -> test_lifespan_dependency_review.py - test_svc02_gather_structure.py -> test_lifespan_gather_structure.py - test_svc03_mcp_event_readiness.py -> test_mcp_event_readiness.py - test_svc04_restart_integration.py -> test_langflow_restart_parity.py - Functions: test_svc04_* -> descriptive names No behavioral changes.
1 parent 7cba56b commit 01828a0

File tree

25 files changed

+97
-97
lines changed

25 files changed

+97
-97
lines changed

src/backend/base/langflow/initial_setup/starter_project_hash.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
short-circuit the full starter-project re-sync on restarts where nothing
77
changed.
88
9-
Failure modes (D-04): missing, unreadable, or corrupt hash files all fall
9+
Failure modes: missing, unreadable, or corrupt hash files all fall
1010
through to a full re-sync. ``LANGFLOW_FORCE_STARTER_RESYNC=1`` bypasses the
1111
comparison. Write failures (read-only root filesystem, e.g. container
1212
deployments) log at debug level and never raise -- mirroring the
@@ -45,7 +45,7 @@ async def compute_starter_projects_hash(starter_folder: anyio.Path) -> str:
4545
(source-only checkout without ``pip install -e .``), the sentinel
4646
``"unknown"`` is substituted (Pattern F / Pitfall 5). The hash remains
4747
stable within such an environment but will invalidate whenever the
48-
fallback fires in a fresh environment -- acceptable per D-01.
48+
fallback fires in a fresh environment -- acceptable .
4949
"""
5050
try:
5151
pkg_version = version("lfx")
@@ -77,7 +77,7 @@ async def read_hash_file_safe(hash_path: Path) -> str | None:
7777
- Corrupt content (first non-comment line is not 64 hex chars)
7878
7979
The caller is expected to treat ``None`` as a cache miss and fall through
80-
to a full re-sync (D-04).
80+
to a full re-sync.
8181
"""
8282
try:
8383
async with aiofiles.open(str(hash_path), encoding="utf-8") as f:
@@ -132,10 +132,10 @@ async def run_starter_projects_hash_gate(
132132
hash_path: Path,
133133
sync_fn: Callable[[], Awaitable[Any]],
134134
) -> bool:
135-
"""Execute the SVC-01 hash-gated starter-project sync.
135+
"""Execute the hash-gated starter-project sync.
136136
137137
This helper encapsulates the hash compare / sync / write sequence so both
138-
``main.py`` (inside its ``FileLock``) and the Phase 4 parity tests invoke
138+
``main.py`` (inside its ``FileLock``) and the parity tests invoke
139139
the exact same code path. ``sync_fn`` is a zero-arg coroutine factory the
140140
caller uses to pass in ``create_or_update_starter_projects(all_types_dict)``
141141
with ``all_types_dict`` already bound.

src/backend/base/langflow/main.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,17 @@ async def lifespan(_app: FastAPI):
207207
try:
208208
start_time = asyncio.get_event_loop().time()
209209

210-
# SVC-03 (D-12): Event constructed inside lifespan so it binds to the running loop.
210+
# Event constructed inside lifespan so it binds to the running loop.
211211
# Module-level asyncio.Event() would leak across pytest event loops (Pitfall 1, same
212-
# root cause as IDX-01's asyncio.Lock issue on Python 3.13/3.14).
212+
# root cause as's asyncio.Lock issue on Python 3.13/3.14).
213213
starter_projects_ready_event = asyncio.Event()
214214

215215
await logger.adebug("Initializing services")
216216
await initialize_services(fix_migration=fix_migration)
217217
await logger.adebug(f"Services initialized in {asyncio.get_event_loop().time() - start_time:.2f}s")
218218

219-
# SVC-02 wave 1: independent filesystem / in-memory ops.
220-
# D-09 service-dependency review (enforced by D-10 test; every task passed to gather MUST have a row):
219+
# wave 1: independent filesystem / in-memory ops.
220+
# service-dependency review (enforced by test; every task passed to gather MUST have a row):
221221
#
222222
# | Task | Reads | Writes |
223223
# |-----------------------|--------------------------------------------|-----------------------------------|
@@ -242,8 +242,8 @@ async def lifespan(_app: FastAPI):
242242
f"Default super user initialized in {asyncio.get_event_loop().time() - current_time:.2f}s"
243243
)
244244

245-
# SVC-02 wave 2: independent post-superuser ops.
246-
# D-09 service-dependency review (enforced by D-10 test; every task passed to gather MUST have a row):
245+
# wave 2: independent post-superuser ops.
246+
# service-dependency review (enforced by test; every task passed to gather MUST have a row):
247247
#
248248
# | Task | Reads | Writes |
249249
# |-------------------------------|---------------------------------------|--------------------------------|
@@ -285,7 +285,7 @@ async def lifespan(_app: FastAPI):
285285
lock = FileLock(lock_file, timeout=1)
286286
try:
287287
with lock:
288-
# SVC-01: hash-gated re-sync. Hash read / compute / write all run
288+
# hash-gated re-sync. Hash read / compute / write all run
289289
# inside the FileLock to preserve multi-worker TOCTOU safety (the
290290
# other worker either wrote the up-to-date hash before releasing
291291
# the lock, or the lock contention path fires below).
@@ -309,10 +309,10 @@ async def lifespan(_app: FastAPI):
309309
f"Starter projects hash matches; skipped re-sync in "
310310
f"{asyncio.get_event_loop().time() - current_time:.2f}s"
311311
)
312-
# SVC-03 producer (D-11): fire on both match and miss paths inside the
312+
# producer: fire on both match and miss paths inside the
313313
# FileLock, but NOT in a finally clause. If create_or_update_starter_projects
314314
# or the hash read raises, DO NOT set the event -- let the 60s consumer
315-
# timeout (D-13) surface the failure as warn-and-continue degraded mode.
315+
# timeout surface the failure as warn-and-continue degraded mode.
316316
starter_projects_ready_event.set()
317317
except TimeoutError:
318318
# Another process has the lock
@@ -378,10 +378,10 @@ async def lifespan(_app: FastAPI):
378378
await logger.adebug(f"Total initialization time: {total_time:.2f}s")
379379

380380
async def delayed_init_mcp_servers():
381-
# SVC-03 consumer (D-11/D-13): replace the previously hardcoded 10-second
381+
# consumer (D-11/D-13): replace the previously hardcoded 10-second
382382
# coordination sleep with a bounded wait on the starter_projects_ready_event
383383
# set by the FileLock producer. On timeout, log a warning and proceed with
384-
# MCP init anyway (warn-and-continue degraded mode per D-13). Closure captures
384+
# MCP init anyway (warn-and-continue degraded mode ). Closure captures
385385
# the Event because this function is defined inline inside lifespan (Pitfall 6).
386386
try:
387387
await asyncio.wait_for(starter_projects_ready_event.wait(), timeout=60.0)
@@ -396,7 +396,7 @@ async def delayed_init_mcp_servers():
396396
await logger.adebug(f"MCP servers loaded in {asyncio.get_event_loop().time() - current_time:.2f}s")
397397
except Exception as e: # noqa: BLE001
398398
await logger.awarning(f"First MCP server initialization attempt failed: {e}")
399-
await asyncio.sleep(5.0) # D-14: retain transient-DB-error retry guard
399+
await asyncio.sleep(5.0) #: retain transient-DB-error retry guard
400400
current_time = asyncio.get_event_loop().time()
401401
await logger.adebug("Retrying MCP servers initialization")
402402
try:

src/backend/base/langflow/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def load_config(self) -> None:
7474
config = {key: value for key, value in self.options.items() if key in self.cfg.settings and value is not None}
7575
for key, value in config.items():
7676
self.cfg.set(key.lower(), value)
77-
# CNT-04: reset fork-unsafe resources in each worker after fork.
77+
# reset fork-unsafe resources in each worker after fork.
7878
# See _langflow_post_fork below + TelemetryService.start() guard.
7979
self.cfg.set("post_fork", _langflow_post_fork)
8080

@@ -91,15 +91,15 @@ def _langflow_post_fork(server, worker) -> None: # noqa: ARG001
9191
asyncio.get_event_loop, no await).
9292
9393
Current responsibilities (CNT-04 fork-hazard audit, RESEARCH.md section
94-
"Fork Hazard Audit (D-05)"):
94+
"Fork Hazard Audit"):
9595
9696
* TelemetryService.client (httpx.AsyncClient) — reset to None so that
9797
TelemetryService.start() reconstructs it inside the worker's event
9898
loop. httpx.AsyncClient has no synchronous .close(), so we cannot
9999
aclose() here; replacing the reference is the correct pattern
100100
(Pitfall 1).
101101
102-
All other hazards audited in Phase 5 (SQLAlchemy engine, asyncio locks,
102+
All other hazards audited in (SQLAlchemy engine, asyncio locks,
103103
ComponentCache.all_types_dict, Redis pool, asyncio.create_task, open
104104
file descriptors) are SAFE by construction — see the phase 05 SUMMARY
105105
for evidence.

src/backend/tests/phase_04_service_init_parity/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/backend/tests/phase_04_service_init_parity/fixtures/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/backend/tests/phase_04_service_init_parity/fixtures/starter_minimal/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/backend/tests/phase_04_service_init_parity/fixtures/starter_mutated/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# service-init parity / lifespan assertion tests.

src/backend/tests/phase_04_service_init_parity/ast_helpers.py renamed to src/backend/tests/service_init_parity/ast_helpers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"""AST helpers for Phase 4 structural assertions.
1+
"""AST helpers for structural assertions.
22
33
Source: docs.python.org/3/library/ast.html
44
5-
These helpers support Phase 4 D-06 (SVC-02 gather structure), D-07
6-
(SVC-03 ``asyncio.sleep(10.0)`` absence), and D-10 (gather-review-table
5+
These helpers support (SVC-02 gather structure),
6+
(SVC-03 ``asyncio.sleep(10.0)`` absence), and (gather-review-table
77
enforcement) tests. They parse ``src/backend/base/langflow/main.py`` once and
88
expose a tiny query API over the AST.
99
"""
@@ -35,7 +35,7 @@ def find_calls_to(tree: ast.AST, qualname: str) -> list[ast.Call]:
3535
- Two-segment qualified names ("asyncio.gather") matched against
3636
``Call(func=Attribute(value=Name('asyncio'), attr='gather'))``.
3737
38-
Longer dotted paths are not currently needed by Phase 4 and are not
38+
Longer dotted paths are not currently needed by and are not
3939
supported.
4040
"""
4141
parts = qualname.split(".")
@@ -62,7 +62,7 @@ def find_sleep_with_value(tree: ast.AST, value: float) -> list[ast.Call]:
6262
6363
Non-literal arguments (e.g. ``asyncio.sleep(timeout_var)``) are ignored --
6464
they are not regressions of the Phase 3 / 4 "no magic sleep(10.0)"
65-
constraint. The literal check exactly matches what D-07 absence assertions
65+
constraint. The literal check exactly matches what absence assertions
6666
care about.
6767
"""
6868
return [
@@ -80,7 +80,7 @@ def extract_gather_task_names(call: ast.Call) -> list[str]:
8080
8181
For ``asyncio.gather(foo(), bar.baz())`` returns ``["foo", "baz"]``.
8282
83-
Two levels of unwrapping are applied so the D-10 review-table enforcement
83+
Two levels of unwrapping are applied so the review-table enforcement
8484
test sees the *actual* task names regardless of the transport wrapper used:
8585
8686
1. ``_safe_step("name", real_call())`` -> look at ``arg.args[1]``. Phase 4

src/backend/tests/phase_04_service_init_parity/conftest.py renamed to src/backend/tests/service_init_parity/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Phase 4 service-init parity test fixtures.
1+
"""service-init parity test fixtures.
22
33
Provides a phase-local ``tmp_config_dir`` that redirects
44
``LANGFLOW_CONFIG_DIR`` + ``LANGFLOW_DATABASE_URL`` into a per-test tmp
@@ -32,7 +32,7 @@ def tmp_config_dir(tmp_path, monkeypatch):
3232
settings_service = get_settings_service()
3333
config_dir = tmp_path / "config"
3434
config_dir.mkdir(parents=True, exist_ok=True)
35-
db_path = tmp_path / "test_phase_04.db"
35+
db_path = tmp_path / "test_.db"
3636
test_db_url = f"sqlite:///{db_path}"
3737

3838
original_config = os.getenv("LANGFLOW_CONFIG_DIR")

0 commit comments

Comments
 (0)