MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / run_successful_activation

Function run_successful_activation

tests/test_daemon_smoke.py:534–642  ·  view source on GitHub ↗

Run one native activation and bind its durable audit trail to its PID.

(
    binary,
    env,
    tmpdir,
    activation_log,
    label,
    action,
    arguments,
    expected_source_build,
    minimum_daemon_clients=1,
)

Source from the content-addressed store, hash-verified

532
533
534def run_successful_activation(
535 binary,
536 env,
537 tmpdir,
538 activation_log,
539 label,
540 action,
541 arguments,
542 expected_source_build,
543 minimum_daemon_clients=1,
544):
545 """Run one native activation and bind its durable audit trail to its PID."""
546 records_before = len(json_records(activation_log))
547 process = subprocess.Popen(
548 [str(binary)] + arguments,
549 stdin=subprocess.DEVNULL,
550 stdout=subprocess.PIPE,
551 stderr=subprocess.PIPE,
552 text=True,
553 env=env,
554 )
555 try:
556 stdout, stderr = process.communicate(timeout=SHUTDOWN_TIMEOUT)
557 except subprocess.TimeoutExpired:
558 process.terminate()
559 try:
560 process.communicate(timeout=3)
561 except subprocess.TimeoutExpired:
562 process.kill()
563 process.communicate(timeout=3)
564 raise
565 (tmpdir / (label + ".out")).write_text(stdout, encoding="utf-8")
566 (tmpdir / (label + ".err")).write_text(stderr, encoding="utf-8")
567 check(
568 process.returncode == 0,
569 label + " failed: stdout={!r}, stderr={!r}".format(stdout, stderr),
570 )
571 check(
572 "Stopping active CBM sessions and operations for {}...".format(action)
573 in stdout,
574 label + " did not show coordination progress: " + repr(stdout),
575 )
576 check(
577 RESTART_GUIDANCE in stdout,
578 label + " did not print the exact restart guidance: " + repr(stdout),
579 )
580
581 records = json_records(activation_log)[records_before:]
582 records = [
583 record
584 for record in records
585 if record.get("event") == "cbm.activation"
586 and record.get("requester_pid") == process.pid
587 ]
588 phases = [record.get("phase") for record in records]
589 check(
590 phases == ["requested", "daemon_stopped", "completed"],
591 label + " activation audit sequence mismatch: " + repr(records),

Callers 1

mainFunction · 0.85

Calls 2

json_recordsFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected