121 lines
5.0 KiB
Python
121 lines
5.0 KiB
Python
"""Admission dispatch for wave bounded-stream (openspec task 1.2a).
|
|
|
|
classify + activate + admit (the headless scaffolding entry law,
|
|
tests/test_construction_admission.py pattern): the bounded feed/stream
|
|
adapter builds on the existing rune project, user-dispatch approved.
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
|
|
from rune import construction_activation as cact # noqa: E402
|
|
from rune import construction_admission as cadm # noqa: E402
|
|
from rune import construction_mode as cmode # noqa: E402
|
|
from rune import scaffold as sc # noqa: E402
|
|
|
|
ROOT = os.path.join(os.path.dirname(__file__), "..")
|
|
|
|
OBJECTIVE = (
|
|
"bounded feed/stream adapter (openspec add-native-rune-tui task "
|
|
"1.2a): a new tui/stream package extending the tui/capsys one-loop "
|
|
"arbiter law to the runtime side — a bounded queue where semantic "
|
|
"events are NEVER dropped (decoration yields first, dropped and "
|
|
"counted; an all-semantic queue admits past the bound with the "
|
|
"over-capacity pressure surfaced, never a silent drop, never a "
|
|
"healthy facade), queue depth/overflow/cancellation/retention state "
|
|
"surfaced in the status strip (compact normal, unmistakable "
|
|
"exception), a retention window honored for replay with honest gap "
|
|
"reporting, and clean cancellation (post-cancel enqueues refused, "
|
|
"pending discarded and counted). The rune serve surface /v1/events "
|
|
"(SSE) gains the same bounded-queue semantics natively (stdlib-only "
|
|
"mirror in src/go/rune-entry): overflow counts, honest queue-state "
|
|
"comments on the stream, and a retention cap on the ?last=N replay "
|
|
"with an honest gap comment when history beyond retention is "
|
|
"requested"
|
|
)
|
|
AFFECTED = [
|
|
"tui/stream/doc.go",
|
|
"tui/stream/stream.go",
|
|
"tui/stream/status.go",
|
|
"tui/stream/README.md",
|
|
"tui/stream/frozen_test.go",
|
|
"tui/stream/testdata/overflow-flood.v1.json",
|
|
"tui/stream/testdata/semantic-pressure.v1.json",
|
|
"tui/stream/testdata/status-lines.v1.txt",
|
|
"src/go/rune-entry/internal/entry/bounded.go",
|
|
"src/go/rune-entry/internal/entry/bounded_test.go",
|
|
"src/go/rune-entry/internal/entry/surface.go",
|
|
"src/go/rune-entry/serve.go",
|
|
"scripts/admit_wave_bounded_stream.py",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
store = os.path.join(ROOT, "store", "scaffold")
|
|
scaffold = sc.Scaffold(store, "rune")
|
|
|
|
md = cmode.classify_mode(
|
|
OBJECTIVE,
|
|
target_project="rune",
|
|
project_exists=True,
|
|
affected_surface=AFFECTED,
|
|
)
|
|
print("classified mode:", md.mode)
|
|
|
|
need = {
|
|
"need_id": "need-wave-bounded-stream",
|
|
"objective": OBJECTIVE,
|
|
"origin": "worker",
|
|
"project": "rune",
|
|
"task_ref": "wave-bounded-stream",
|
|
"affected_surface": AFFECTED,
|
|
"evidence_refs": [
|
|
"docs/openspec/changes/add-native-rune-tui/tasks.md",
|
|
"docs/openspec/changes/add-native-rune-tui/specs/work-observability/spec.md",
|
|
"tui/capsys/doc.go",
|
|
"tui/capsys/loop.go",
|
|
"src/go/rune-entry/internal/entry/surface.go",
|
|
],
|
|
}
|
|
act = cact.activate(md, need=need, scaffold=scaffold,
|
|
builder="wave-bounded-stream")
|
|
print("activated:", act.get("activated"), act.get("mode"))
|
|
|
|
env = cadm.admit(
|
|
act,
|
|
objective=OBJECTIVE,
|
|
builder="wave-bounded-stream",
|
|
affected_surface=AFFECTED,
|
|
evidence_refs=need["evidence_refs"],
|
|
origin="worker",
|
|
task_ref="wave-bounded-stream",
|
|
expected_new_entities=[
|
|
"tui/stream (package)",
|
|
"scripts/admit_wave_bounded_stream.py",
|
|
],
|
|
expected_runtime_effects=[
|
|
"overflow drops decoration only, counted and surfaced; semantic events never dropped, all-semantic pressure surfaces over-capacity state honestly",
|
|
"the status strip line is compact when healthy and unmistakable on overflow/pressure/cancellation — never a healthy facade",
|
|
"cancellation refuses further enqueues, discards pending with a count, and leaves a truthful cancelled state",
|
|
"retention window honored: replay returns at most the retained events and reports the gap when more is requested",
|
|
"/v1/events SSE carries overflow counts and honest queue-state comments; ?last=N replay is capped at retention with an honest gap comment",
|
|
],
|
|
verification_obligations=[
|
|
"go test ./stream/ -race in tui/ green (red-first record in frozen_test.go)",
|
|
"go test ./... in src/go/rune-entry green (red-first record in bounded_test.go)",
|
|
"go vet + gofmt clean on both modules",
|
|
],
|
|
approval_ref="user:wave-K10-bounded-stream dispatch",
|
|
contract_id="ADMIT-wave-bounded-stream",
|
|
project_store=store,
|
|
project_id="rune",
|
|
)
|
|
print(json.dumps(env, indent=2, default=str)[:2400])
|
|
return 0 if env.get("success") else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|