mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-19 21:19:14 +00:00
Merge main into the api_v3 split, carrying the three fixes it would have dropped
main modified web_interface/blueprints/api_v3.py while this branch deletes it, so git reports a modify/delete conflict. Resolving that by accepting the deletion - the obvious move - would silently discard every api_v3.py change merged since this branch forked. Three were: #560 the sudo diagnosis on /system/action -> api_v3/system.py #557 the stale-reconciliation-findings filter -> api_v3/plugins.py #550 the deletion of dead _validate_time_range -> api_v3/__init__.py All three were verified absent from the split beforehand: _sudo_hint_for, _SUDO_NEEDS_PASSWORD and _drop_stale_reconciliation_findings appeared in zero files, while _validate_time_range was still sitting at __init__.py:343 after #550 removed it from main. Each is now ported to the module that owns the affected route, and the dead function is gone. Two further changes this surfaced: - api_v3/__init__.py imported fcntl at module scope. fcntl is POSIX-only, the monolithic blueprint never imported it, and on this branch it made the whole api_v3 package unimportable off POSIX: the pristine branch cannot run its test suite on Windows at all - 14 collection errors interrupt the run. The import now happens inside _starlark_manifest_lock(), the only thing that uses it. Deliberately NOT degraded to a no-op lock off POSIX; that function's docstring describes a real lost-update race, and silently not locking would be worse than failing loudly on a platform that cannot drive the display. - test/test_reconciliation_status_endpoint.py is new. #557's endpoint wiring had no test - only the pure still_unresolved() helper in src/ was covered, and that lives outside web_interface so it survived the split untouched. Losing the filter during this merge would therefore have been completely silent. Removing the filter call now fails three of its seven cases. Suite on this merge: 115 failed / 4317 passed. main today: 105 / 4252. All 11 extra failures are in test_starlark_pixlet_routes.py and need POSIX file locks, so they are Windows-only; on that same file the pristine branch shows 19 failed plus 39 errors, so this is a large net improvement rather than a regression. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -707,6 +707,35 @@ def reconcile_plugin_state():
|
||||
context=error.context,
|
||||
status_code=500
|
||||
)
|
||||
def _drop_stale_reconciliation_findings(unresolved):
|
||||
"""Re-check a stored reconciliation verdict against current state.
|
||||
|
||||
The verdict is a snapshot written once per run, and a run that could not
|
||||
apply a fix also refuses to retry -- so a resolved condition was reported
|
||||
indefinitely. Best-effort: any failure here returns the list untouched,
|
||||
because showing a stale warning beats failing the endpoint.
|
||||
|
||||
The disk set is enumerated directly rather than through
|
||||
_installed_plugin_ids(): this mirrors StateReconciliation._get_disk_state(),
|
||||
whose verdict we are re-checking, and avoids triggering a discovery scan on
|
||||
an endpoint the overview page polls.
|
||||
"""
|
||||
try:
|
||||
from src.plugin_system.state_reconciliation import still_unresolved
|
||||
|
||||
config_keys = set(api_v3.config_manager.load_config() or {})
|
||||
installed = set()
|
||||
plugins_dir = getattr(api_v3.plugin_manager, 'plugins_dir', None)
|
||||
if plugins_dir:
|
||||
for entry in Path(plugins_dir).iterdir():
|
||||
if entry.is_dir() and (entry / 'manifest.json').exists():
|
||||
installed.add(entry.name)
|
||||
return still_unresolved(unresolved, config_keys, installed)
|
||||
except Exception:
|
||||
logger.debug("[Reconciliation] Could not re-check stored findings", exc_info=True)
|
||||
return unresolved
|
||||
|
||||
|
||||
@api_v3.route('/plugins/reconciliation-status', methods=['GET'])
|
||||
def get_reconciliation_status():
|
||||
"""Return the result of the last startup reconciliation from /tmp status file."""
|
||||
@@ -721,6 +750,8 @@ def get_reconciliation_status():
|
||||
try:
|
||||
with open(_recon_path) as _f:
|
||||
data = json.load(_f)
|
||||
if data.get('unresolved'):
|
||||
data['unresolved'] = _drop_stale_reconciliation_findings(data['unresolved'])
|
||||
return jsonify({'status': 'success', 'data': data})
|
||||
except json.JSONDecodeError:
|
||||
logger.exception("[Reconciliation] Failed to parse status file: %s", _recon_path)
|
||||
|
||||
Reference in New Issue
Block a user