Skip to content

Adopt capsize_commons.logging in spikeforge (B″, hq#3) - #52

Merged
w4ffl35 merged 1 commit into
mainfrom
chore/adopt-capsize-commons-logging
Sep 19, 2026
Merged

w4ffl35 merged 1 commit into
mainfrom
chore/adopt-capsize-commons-logging

Conversation

@w4ffl35

@w4ffl35 w4ffl35 commented Sep 19, 2026

Copy link
Copy Markdown
Member

Closes Capsize-Games/hq#3 (B″). Deletes the duplicated observability/json_formatter.py and renders through capsize_commons.logging.JsonFormatter.

Changes

  • Delete spikeforge/observability/json_formatter.py; logging_setup.py now builds JsonFormatter(message_key="event", identifier_fields=("run_id","config_id","config_hash")). LOGGER_NAME and the event key are unchanged.
  • Clear the import blocker. Both spikeforge/__init__.py and spikeforge/observability/__init__.py resolve their eager imports lazily (PEP 562). The issue's blocker note named the chain (spikeforge/__init__.py → torch) and the observability eager imports; fixing only the latter would not have made the logging surface torch-free, so both were made lazy. Public names are preserved (verified below).
  • Manifest: capsize-commons>=0.1.1 on the core distribution, plus the exact-pin update in test_packaging_profiles.py and documentation/project-layout.md.

Acceptance criteria

# Criterion Result
1 logging surface imports without the ML stack ✅ import spikeforge.observability.logging_setup — torch/snntorch not in sys.modules; all 7 __all__ names present
2 json_formatter.py deleted, callers use the library ✅ only caller (logging_setup.py) switched; message_key="event" + 3 identifier fields
3 pytest tests/test_observability_logging.py passes ✅ 5 passed
4 before/after dump with identical keys+values ✅ see below
5 capsize-commons declared; ruff+mypy clean ✅ ruff clean repo-wide; mypy 412 files, no issues
6 LOGGER_NAME still importable from ...logging_setup ✅

Behaviour-parity artefact

Same log record (train.started, run_id=run-1, config_hash=abc, fields={"epoch":2}), timestamp frozen:

before  {"timestamp": "2023-11-14T22:13:20+00:00", "level": "INFO", "event": "train.started", "logger": "spikeforge", "run_id": "run-1", "config_hash": "abc", "fields": {"epoch": 2}}
after   {"timestamp": "2023-11-14T22:13:20+00:00", "level": "INFO", "logger": "spikeforge", "event": "train.started", "run_id": "run-1", "config_hash": "abc", "fields": {"epoch": 2}}

json.loads(before) == json.loads(after) → True. The only difference is JSON key order (logger now precedes event); JSON objects are unordered, so this is not a semantic change.

Edge deltas found by direct comparison (reported, not hidden):

Case before after
fields={} key omitted "fields": {} emitted
exc_info set no exception key "exception": "<traceback>" added
non-ASCII message \u00e9-escaped (ensure_ascii=True) raw UTF-8 (ensure_ascii=False)

All are additive or parse-equivalent; none renames event or drops a correlation field.

Test results

  • tests/test_observability_logging.py → 5 passed (torch-free venv, capsize-commons==0.1.1).
  • Full suite in that env → 118 passed, 6 skipped, 5 failed, 154 errors. Every failure/error is environmental:
    • the 154 errors are ModuleNotFoundError: torch on collection (the suite requires the ML stack);
    • the 5 failures are tests/test_version_reporting.py (torch absent + spikeforge not pip-installed in this venv).
    • Attribution: git stash + re-run on the pre-change tree makes test_version_reporting.py fail harder (collection ERROR, not 5 assertion failures) — the change is not the cause.

Not verified

  • The full suite was not run to green — it cannot run without torch in this tree (no .venv/uv.lock). CI owns that.
  • snn_interpreter was not touched (provenance, hq#2, found no unique work to port).
  • No publish/release performed.

Delete the private §14 JSON formatter and render through
capsize_commons.logging.JsonFormatter(message_key="event",
identifier_fields=("run_id", "config_id", "config_hash")), which
reproduces spikeforge's payload keys and values exactly.

Clear the import blocker so the logging surface is importable without
the ML stack: spikeforge/__init__.py and spikeforge/observability/__init__.py
now resolve their eager torch/metrics imports lazily (PEP 562). Importing
spikeforge.observability.logging_setup no longer pulls torch or snntorch;
LOGGER_NAME and the "event" key are unchanged.

Declare capsize-commons>=0.1.1 on the core distribution (logging is part
of its base install), update the packaging dependency pin in
test_packaging_profiles.py, and refresh documentation/project-layout.md.

Refs Capsize-Games/hq#3
@w4ffl35

w4ffl35 commented Sep 19, 2026

Copy link
Copy Markdown
Member Author

Compensating local run — recorded owner-approved bypass (hq#14)

Owner decision on Capsize-Games/hq#14: option 1 (path-filtering) + a recorded one-off bypass for this PR and airunnerweb#280. No red check is merged past — this PR is 0 failed; it is blocked only by the queued spikeforge-ci self-hosted pool (run 35459161595 queued since 17:47:21Z with no progress; the last successful run took 2h17m).

Compensating run, this worktree, capsize-commons==0.1.1:

Check Result
pytest tests/test_observability_logging.py tests/test_packaging_profiles.py 31 passed, 2 skipped
ruff check . All checks passed
mypy --ignore-missing-imports spikeforge/ … server/ Success: no issues found in 412 source files
import spikeforge.observability.logging_setup torch-free; LOGGER_NAME=spikeforge

The full suite still requires the ML stack and is not run here (documented in the PR body).

@w4ffl35
w4ffl35 merged commit 3594387 into main Sep 19, 2026
3 of 19 checks passed
@w4ffl35
w4ffl35 deleted the chore/adopt-capsize-commons-logging branch September 19, 2026 18:22
w4ffl35 added a commit that referenced this pull request Sep 19, 2026
`#52` added `capsize-commons>=0.1.1` to the core dependencies for §14 logging,
but `capsize-commons` requires Python >=3.11. The declared floor and the
classifiers still said 3.10, and `test (3.10)` now fails at install:

  ERROR: Could not find a version that satisfies the requirement
  capsize-commons>=0.1.1 ... Ignored the following versions that require a
  different python version: 0.1.1 Requires-Python >=3.11

The failure was masked because #52 was merged on a clause-8 bypass without its
checks completing; running the job exposed it.

Raise `requires-python` to >=3.11, drop the 3.10 classifier, and drop the 3.10
CI matrix cell. Refs Capsize-Games/hq#3 Capsize-Games/hq#14
w4ffl35 added a commit that referenced this pull request Sep 19, 2026
* ci: run the required checks on GitHub-hosted runners (hq#14)

The five *required* jobs (`lint`, `test (3.12)`, `core-boundary`,
`published-surfaces`, `packaging-guards`) move from the three self-hosted
runners to `ubuntu-latest`. spikeforge is public, so hosted minutes are free,
and this takes the merge gate off the queue that has cost three waves
(observed: spikeforge#52 queued 32+ min with zero progress; the last full run
took 2h17m).

The seven non-required heavy jobs stay on the self-hosted pool; they no longer
sit in front of a merge.

Refs Capsize-Games/hq#14

* fix(packaging): drop Python 3.10, which the core can no longer support

`#52` added `capsize-commons>=0.1.1` to the core dependencies for §14 logging,
but `capsize-commons` requires Python >=3.11. The declared floor and the
classifiers still said 3.10, and `test (3.10)` now fails at install:

  ERROR: Could not find a version that satisfies the requirement
  capsize-commons>=0.1.1 ... Ignored the following versions that require a
  different python version: 0.1.1 Requires-Python >=3.11

The failure was masked because #52 was merged on a clause-8 bypass without its
checks completing; running the job exposed it.

Raise `requires-python` to >=3.11, drop the 3.10 classifier, and drop the 3.10
CI matrix cell. Refs Capsize-Games/hq#3 Capsize-Games/hq#14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant