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
34 changes: 34 additions & 0 deletions docs/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,37 @@ time (the earlier stage start), so a new cloud runner cannot rejuvenate an
old pass. Installation checks retain their own timestamps and source/index.
Readiness still checks release fidelity, current library SHAs and evidence age.
This bounded search is daily-only and does not add work to the fast local tick.

## Monitoring completeness

The dashboard's headline is `monitoring.score`; `verdict`, `score`, and
`penalties` retain their release-readiness meanings for existing consumers.
Release gating is unchanged. Badges label both assessments. The cockpit
`state.status` remains the release verdict (the development entry guard reads
it); its headline and items also report monitoring findings.

`heart.monitoring` owns the complete inventory: expected active check families,
all configured repositories (including organs and developer workspaces), raw
nested observations, and missing evidence. `monitoring.checks` includes passing
and explicitly inapplicable observations; `findings` includes every unresolved
one with a stable ID, source, timestamp, and remedy. Repair consumers must read
this full inventory, not the capped visual summaries or clipboard prompt.
`pyauto-brain health --scope dashboard` adopts this assessment. Release GREEN
alone cannot complete that loop.

Monitoring starts at 100. Each family deducts its worst unresolved status:
red 10, yellow 5, missing/expired evidence 2, with a total floor of zero.
Multiple projections of a family cannot multiply its penalty. A score of 100
requires fresh green evidence across all applicable checks. Permanent exclusions
are explicit N/A records. Missing comparisons, unfinished baselines and zero
measured tests are gaps; the retired workspace-testmode collector is not an
expected check (its replacement is smoke timings).

Observation age comes from the collector, never a new aggregation timestamp.
The monitoring freshness windows are two days for local/coverage checks, seven
days for timing evidence, and fourteen for installation/rehearsal evidence;
release-specific source and freshness rules still apply through readiness.
Old adverse results remain adverse. Undated results require a collector refresh.
Published local observations carry their full inventory and per-repository
checkout evidence. Private records retain their status and an opaque ID with a
local investigation action; private paths never travel to the public board.
3 changes: 3 additions & 0 deletions heart/checks/import_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def run(
"samples": len(prior),
})

import datetime as observation_time

summary = {
"ts": observation_time.datetime.now(observation_time.timezone.utc).isoformat(),
"python": python,
"packages_measured": measured,
"packages_unavailable": unavailable,
Expand Down
3 changes: 3 additions & 0 deletions heart/checks/manifest_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def run() -> dict[str, Any]:
sys.path.insert(0, str(HEART_HOME))
from heart import state

import datetime as observation_time
result["ts"] = observation_time.datetime.now(observation_time.timezone.utc).isoformat()

state.atomic_write_json(HEART_STATE_DIR / "manifest_drift.json", result)
return result

Expand Down
3 changes: 3 additions & 0 deletions heart/checks/profiling_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def run(results_root: Path | None = None) -> dict[str, Any]:
sys.path.insert(0, str(HEART_HOME))
from heart import state

import datetime as observation_time
summary["ts"] = observation_time.datetime.now(observation_time.timezone.utc).isoformat()

state.atomic_write_json(HEART_STATE_DIR / "profiling_drift.json", summary)
return summary

Expand Down
3 changes: 3 additions & 0 deletions heart/checks/required_workflow_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def run(config_path: Path | str = CONFIG_PATH) -> dict[str, Any]:
sys.path.insert(0, str(HEART_HOME))
from heart import state

import datetime as observation_time
result["ts"] = observation_time.datetime.now(observation_time.timezone.utc).isoformat()

state.atomic_write_json(
HEART_STATE_DIR / "required_workflow_drift.json", result
)
Expand Down
7 changes: 6 additions & 1 deletion heart/checks/script_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def scan_latest_results(results_dir: Path) -> list[dict[str, Any]]:
"directory": directory,
"file": file_path,
"duration": float(duration),
"observed_at": datetime.datetime.fromtimestamp(json_path.stat().st_mtime, datetime.timezone.utc).isoformat(),
})
return entries

Expand All @@ -350,6 +351,9 @@ def run(results_dir: Path | None = None) -> dict[str, Any]:
migrations: list[dict[str, str]] = []

scanned = scan_latest_results(results_dir)
# Reading yesterday's run again is not a new timing observation.
observed_times = [e["observed_at"] for e in scanned if e.get("observed_at")]
evidence_ts = min(observed_times) if observed_times else None
slugs = [slug_for(e["project"], e["directory"], e["file"]) for e in scanned]
touched = set(slugs)
# Anything this scan does not write to is a candidate stranded baseline.
Expand Down Expand Up @@ -396,6 +400,7 @@ def run(results_dir: Path | None = None) -> dict[str, Any]:
findings[category].append(record)

summary = {
"ts": evidence_ts,
"results_dir": str(results_dir),
"run_id": run_id,
"total_scripts": total,
Expand All @@ -404,7 +409,7 @@ def run(results_dir: Path | None = None) -> dict[str, Any]:
"migrated_count": len(migrations),
"orphaned_count": len(orphans),
"migrated": migrations[:MAX_LISTED],
"orphaned": orphans[:MAX_LISTED],
"orphaned": orphans,
"red_count": len(findings["red"]),
"yellow_count": len(findings["yellow"]),
"green_count": len(findings["green"]),
Expand Down
1 change: 1 addition & 0 deletions heart/checks/smoke_timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ def _name_of(side: Any) -> str:
prev_run_id = (prev_row or {}).get("run_id")
prev_run_url = str((prev_row or {}).get("run_url") or "")
leg_rows.append({
"at": at,
"repo": repo,
"python": python,
"entry": name,
Expand Down
3 changes: 3 additions & 0 deletions heart/checks/unit_test_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ def run(runner: Runner | None = None, repos: list[str] | None = None) -> dict[st
"samples": len(history) - 1,
})

import datetime as observation_time

summary = {
"ts": observation_time.datetime.now(observation_time.timezone.utc).isoformat(),
"python": python,
"repos_measured": repos_measured,
"repos_unavailable": unavailable,
Expand Down
6 changes: 6 additions & 0 deletions heart/checks/unit_timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ def _name_of(side: Any) -> str:
prev_run_id = (prev_row or {}).get("run_id")
prev_run_url = str((prev_row or {}).get("run_url") or "")
tests.append({
"at": at,
"repo": repo,
"python": python,
"nodeid": nodeid,
Expand All @@ -652,6 +653,7 @@ def _name_of(side: Any) -> str:
import_s, history.get((repo, package, python)), thr
)
imports.append({
"at": at,
"repo": repo,
"package": package,
"python": python,
Expand Down Expand Up @@ -757,7 +759,10 @@ def legacy_summaries(
else:
unit["green"].append(entry)

evidence_times = [str(r.get("at")) for r in repos if r.get("at")]
evidence_ts = min(evidence_times) if evidence_times else None
unit_summary = {
"ts": evidence_ts,
"python": LEGACY_PYTHON,
"repos_measured": len(measured),
"repos_unavailable": unavailable,
Expand Down Expand Up @@ -800,6 +805,7 @@ def legacy_summaries(
imports.get(state, imports["green"]).append(entry)

import_summary = {
"ts": evidence_ts,
"python": LEGACY_PYTHON,
"packages_measured": packages_measured,
"packages_unavailable": packages_unavailable,
Expand Down
2 changes: 2 additions & 0 deletions heart/checks/version_skew.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def main(argv: list[str]) -> int:
# clobber live state. The --pypi leg gets its own sidecar so the tick's
# version_skew.json rewrite never clobbers on-demand PyPI evidence.
name = "version_skew_pypi.json" if pypi else "version_skew.json"
import datetime
result["ts"] = datetime.datetime.now(datetime.timezone.utc).isoformat()
state.atomic_write_json(HEART_STATE_DIR / name, result)

from heart.heart_color import c_ok, c_warn, c_fail, c_info, c_meta, glyph_ok, glyph_warn, glyph_fail
Expand Down
3 changes: 3 additions & 0 deletions heart/checks/workspace_testmode_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ def run(runner: Runner | None = None, scripts: list[tuple[str, str]] | None = No
"samples": len(history) - 1,
})

import datetime as observation_time

summary = {
"ts": observation_time.datetime.now(observation_time.timezone.utc).isoformat(),
"python": python,
"mode": "PYAUTO_TEST_MODE=2 PYAUTO_WORKSPACE_SMALL_DATASETS=1",
"scripts_measured": measured,
Expand Down
3 changes: 3 additions & 0 deletions heart/checks/worktree_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def main(argv: list[str] | None = None) -> int:
sys.path.insert(0, str(HEART_HOME))
from heart import state

import datetime as observation_time
result["ts"] = observation_time.datetime.now(observation_time.timezone.utc).isoformat()

state.atomic_write_json(HEART_STATE_DIR / "worktree_drift.json", result)

from heart.heart_color import c_fail, c_info, c_ok, c_warn, glyph_fail, glyph_ok, glyph_warn
Expand Down
Loading
Loading