forked from mtusi2026/mtusi2026lab7
76 lines
17 KiB
Markdown
76 lines
17 KiB
Markdown
# Helper entrypoints and actual consumers
|
||
|
||
All maintained orchestration is TypeScript executed with Bun. No authored Python/Node.js/mjs wrapper was introduced; original public Python scripts are preserved and invoked unchanged by Makefile. Shell entrypoints only hand control to Bun, the official PostgreSQL entrypoint, or the installed RustFS server command.
|
||
|
||
## Runtime orchestration
|
||
|
||
- `scripts/lab.ts`: operator CLI prepare/start/wait/unseal/stop/accept; calls bootstrap, native Compose with pinned manifest/project, native OpenBao API, migration, S3 SDK bridge, readiness and acceptance-session.
|
||
- `scripts/bootstrap.ts`: called by lab prepare or disposable test-session; local encrypted operator envelope, OpenSSL PKI and exact runtime config files. Hidden operator prompt; no secret arguments/logging.
|
||
- `scripts/openbao-operator.ts`: lab init/unseal/configuration. Native HTTPS API through curl with CA/hostname; root token in private header file, init/unseal material encrypted before readback; no root token in app.
|
||
- `scripts/bao-client.ts`: shared native OpenBao HTTP wrapper. Returns full HTTP JSON; consumers use the tested KVv2 parser, not a flattened secret shape.
|
||
- `scripts/pki.ts`, `operator-crypto.ts`, `security-guards.ts`, `kv-secrets.ts`: explicit libraries used by orchestration and unit/native tests. Native OpenSSL issues/revokes, Node-compatible crypto APIs in Bun encrypt operator data and inspect X509; no custom signing/TLS protocol.
|
||
- `scripts/topology.ts`, `generate-agent-configs.ts`, `telemetry-dashboard.ts`: reproducible config generators. Checked-in compose, gateway config, both actual HCL and dashboard JSON are delivered; startup consumes those exact paths.
|
||
- `scripts/db-provision.ts`: local PostgreSQL operator Unix-socket role/GRANT provisioning; app cert roles are not migration/admin roles.
|
||
- `scripts/s3-provision.ts`: Bun operator orchestration of the native SDK bridge; only the ephemeral operator container gets root S3 config and private response-receipt directory.
|
||
- `scripts/reload-gateway.ts`: verified owned HAProxy master-worker USR2 reload, preserving the namespace used by its application sidecar; hard-stop-after2s drains old connections.
|
||
- `scripts/hooks.ts`, `restart.sh`, `stop-one.sh`: public resilience hooks. Read actual backend alias file; target exact owned replica; restart stores without deleting data, unseal and wait.
|
||
- `scripts/runtime.ts`, `runtime-inspect.ts`, `public-endpoint.ts`: common pinned Compose invocation, private diagnostics, native inspection and safe published-LB binding selection. Multi-network LB uses the actual loopback HostPort, not an arbitrary address.
|
||
- `scripts/rotation.ts`: operator-only research1 scenario through real API/jobs, native CRL/token/S3 rotation, new leaf and fresh-connection checks; no publishing or external messages.
|
||
|
||
## Checks and operator diagnostics
|
||
|
||
- `scripts/grafana-cache.ts`: явный remote CLI; проверяет root CACHE-READY, immutable imageID и plugin hashes, создаёт только собственный alias/copy без network download и без изменения cache6. `scripts/grafana.ts prepareGrafana` используется bootstrap, canonical start и preflight: encrypted secret_key capture перед узким mount, exact admin envelope/consumer guard. Его чистые endpoint/frame/rule/history selectors проверяются unit tests.
|
||
- `scripts/grafana-datasources.ts readGrafanaDatasources`: required request-port reader, production caller — grafana-preflight; list используется только для membership, auth metadata читается из actual UID detail, затем matching health. Tests используют только обязательный fake request.
|
||
- `scripts/grafana-preflight.ts`: native cached/operator-provider case runner с pinned112/cache guards, private evidence, HTTPS/data-source readback и finally stop. `--incidents` вызывает grafana-incidents; `--browser` вызывает grafana-browser. `--links-only` и `--history-only` выбирают узкий browser case без нового producer; повтор полного incident/smoke не нужен для исправления reader.
|
||
- `scripts/grafana-incidents.ts`: текущий112 API/worker, bounded encrypted fixture, original worker backlog и DB-error rules, реальные firing/resolved с threshold values, обработка той же queued job; исходные2rules не меняются. Использует scoped operator files/heartbeat, не Bao.
|
||
- `scripts/grafana-browser.ts`: существующий native Chromium155 через offline cached playwright-core1.65.1; собственный HDD profile/TMPDIR, CA/SAN/time и отдельные native TLS negatives, ограниченный SPKI pin. Проверяет реальные frames/DOM, native plugin trace42, split links со specific response wait, оба actual Grafana response consumers, native histogram и ordinary page-history write/reload. Cookies/login/password/сырые response остаются private; выбранные PNG/DOM копируются только после визуальной проверки и SHA binding.
|
||
- `scripts/browser-lifecycle.ts`: small required-port ownership factory, вызывается grafana-browser сразу при acquireContext; run охватывает newPage/listener setup, close вызывается один раз, cleanup error отдельно передаётся reporter и не заменяет primary failure. `bun test student-tests/browser-lifecycle.test.ts` выполняет только обязательные fake ports; production entrypoint не импортируется. Этот regression command пока отдельный от замороженного95-test test:unit.
|
||
- `student-tests/grafana-browser-launch.ts`: explicit remote blank-page positive перед stand. `grafana-gauge-proof.ts`: storage-only fixed-point raw series/labels/start_time/age, original vs timestamp-filtered capacity/observer и absent NoData, без producer. `grafana-response-boundary.ts`: временный synthetic upstream и native HAProxy/mTLS framing controls, exact8МиБ/+1/encoding/chunked/unknown/normalization; останавливает только собственный claim container. Это не SQL work/row cap.
|
||
|
||
- `scripts/verify-offline.ts`: guard/OpenSSL unit evidence and config generation; does not certify live services.
|
||
- `scripts/format-check.ts`: native Bun formatter restricted to authored implementation/config types; non-writing check after write mode.
|
||
- `scripts/validate-source.ts`: independent non-writing native typecheck/unit/formatter checks and safe result receipts. `validate-gateways.ts` executes the cached native HAProxy parser for current9 exact mounted configs (the pre-OpenObserve11 result remains historical) without contacting an upstream.
|
||
- `scripts/final-source-checks.ts`: sequential native gofmt/dashboard generation/Bun formatting, then non-writing validation and exact offline binary rebuild. It does not start services or repeat runtime acceptance.
|
||
- `scripts/export-public-baseline.ts`: runs in the original checkout and verifies original public bytes against HEAD, exporting safe hashes. `package-checkpoint.ts` consumes that baseline and the checked backend lease, checks every delivered config bind, ZIP CRC and every extracted byte; its archive is explicitly a source checkpoint with native gates pending.
|
||
- `scripts/finalize-preflight.ts`: preserves the accepted source generation as checked<count>-source/build using exclusive create or exact existing-byte equality, verifies the binding to the accepted runtime summary, rebuilds the bounded SDK bridge and checks a new COMPLETE receipt, then validates project labels and tears down only the pinned stand. Legacy unbound summaries are refused; private bind data/test key remain for addressed cleanup.
|
||
- `scripts/command-runner.ts`: runtime.run uses its required execute/unique/last ports; diagnostic failure cannot replace the primary error and UUID receipts use wx. `scripts/checkpoint-guards.ts`: required fake-port regressions and actual build/finalizer/package callers pin initial receipt/source bytes, preserve historical evidence and bind ZIP verification to the FIRST source map plus exact manifest bytes.
|
||
- `scripts/image-manifests.ts`: manifest/digest/layer-size inspection only; no pulls. `check-tooling.ts` checks native installed help safely. `diagnose.ts` persists raw logs privately and emits fixed categories; callers must supply services. `diagnose-command.ts` and `diagnose-preflight.ts` read private command outcomes and emit only fixed diagnostic terms/codes and owned container state.
|
||
- `scripts/preflight-build.ts`: checked source hashes before/after compile, immutable cached runtime alias, exact resulting binary hashes. Compiler is the existing native `/home/rey/.local/share/mise/installs/go/1.27.2/bin/go`, with GOPROXY=off/GOSUMDB=off/-mod=readonly and existing modules. The cached runtime is an explicitly separate preflight, not OpenBao acceptance or the canonical Dockerfile.
|
||
- `scripts/preflight-run.ts`: calls preflight-build, actual scoped store provisioning, explicit operator file provider, public source/HTTP checks, native PG, cached mTLS, worker privileges, leaf lifetime and `student-tests/freshness-runtime.ts`. The latter observes actual fixed `secret_freshness_failed` events plus exit/restart after the explicit heartbeat stops; it does not seal Bao. Disposable fixture passphrase is in private unmounted `.local-preflight-key` for bounded --resume, excluded from Git/build/ZIP and removed after final teardown; production operator mode uses a hidden prompt.
|
||
- `scripts/check-source.ts`: copies source bytes excluding private/runtime/build/dependency paths into an owned temporary snapshot and runs the original public `make check` there. This avoids RustFS object directories named policy.json in the public recursive JSON walk; HTTP tests still use the live stand.
|
||
- `student-tests/probe-pki.ts`: full/cached acceptance creates an independent foreign-CA negative fixture outside service mounts. `student-tests/grpc-probe.ts`: native HTTP/2/TLS client submits the empty OTLP Export request and requires HTTP200/grpc-status0; the historical Tempo matrix used it for ingest controls; current OpenObserve matrix uses native HTTP OTLP, with no protobuf/signing implementation or extra SDK.
|
||
- `scripts/diagnose-tls.ts`: fixed allowlisted native TLS code/cause summaries from private negative-probe receipts; raw messages stay private. `student-tests/transport-negative.test.ts` proves the installed Bun certificate-required alert is accepted and timeout is rejected.
|
||
- `scripts/test-session.ts`, `acceptance-session.ts`: disposable test orchestration. Generated operator passphrase stays in process memory; no downloads, full acceptance waits for existing images plus checked backend. This mode is not durable operator recovery.
|
||
- `scripts/install-dev-types.ts`: task-only standard Bun install of @types/bun with ignore-scripts; normal reproduction uses the checked lockfile. Production scripts have no package dependency.
|
||
- `scripts/reset-failed-test.ts`: operator-only cleanup preparation for this pinned disposable stand, verifies ownership and privately archives failed state. It is not a general Docker cleanup tool.
|
||
- `student-tests/*.test.ts`: fake-port/pure regressions, native OpenSSL and native isolated Valkey ACL fixture. `student-tests/wait.ts` checks every intended replica and public HTTPS. Remaining student-tests modules are invoked by acceptance-session against actual deployed boundaries.
|
||
|
||
## Explicit native SDK exception
|
||
|
||
` scripts/s3-control.go` is a compiled Linux utility using the application's locked `github.com/minio/minio-go/v7` (7.4.1) and native SigV4 signer for RustFS administrative requests and scoped object probes. It is built with the app source, invoked by Bun in a unique task container, and does not replace Bun orchestration. Root explicitly approved this narrow existing-SDK bridge; duplicating SigV4 or downloading a new JavaScript SDK is unnecessary.
|
||
|
||
Exact callers: Dockerfile builds `/s3-control`; `s3-provision.ts` runs `-action bootstrap` in the S3 gateway namespace with operator-only config/receipt mounts; `student-tests/privileges.ts` runs `-action prove-worker` in the worker namespace using only the rendered worker config; `rotation.ts` runs `-action prove-stale` with the retired worker credential. No API/worker runtime container mounts the root S3 file or operator receipts.
|
||
|
||
The only new backend-owned leaf authored here is `backend/internal/adapter/freshness/**`, explicitly assigned by root. Its explicit read/clock/ticker ports return errors to composition; it never exits, signals or accesses live defaults in unit tests. Backend main/auth/broker changes are owned by the VP backend agent and guarded by BACKEND-READY.json.
|
||
|
||
## Перенос storage на OpenObserve, текущая работа
|
||
|
||
- `scripts/openobserve-cache.ts --check|--apply` — CLI для read-only проверки публичных cache receipts/платформы/source112 и создания только собственных aliases. `openobserve-session.ts` читает его безопасный image-freeze receipt. Canonical registry pins остаются в topology; cache helper — разрешённый способ использовать проверенные существующие blobs без pulls.
|
||
- `scripts/openobserve-accounts.ts` — фабрика с обязательными create/save ports; вызывается `scripts/openobserve.ts` и изолированными fake-port tests. Принимает только нативный service_accounts route, сохраняет token до успеха.
|
||
- `scripts/openobserve.ts prepare|provision` — CLI и native HTTP consumer для session/pipeline. Owner/token envelopes зашифрованы, ответы0600 остаются в operator directory вне mounts/build. Collector получает отдельный header file без CR/LF, Grafana — только query ServiceAccount через private env_file. Root/admin в Grafana не используется.
|
||
- `scripts/openobserve-session.ts` — отдельный bootstrap/config-validation CLI. Его успешный результат не включает приложение/Grafana/Bao. `scripts/openobserve-pipeline.ts` — scoped CLI для неизменённого checked112 и native всех трёх сигналов; uses existing operator provider, не Bao.
|
||
- `student-tests/openobserve-signals.ts` — actual native query assertions, вызывается pipeline. Проверяет реальную цепочку API/worker, parent links, native units, correlated logs и конечные PromQL samples; SQL содержит явный LIMIT100.
|
||
- `scripts/openobserve-config-check.ts` — генерация dashboard и запуск чистых config/topology regressions. Проверка конфигурации не подтверждает Grafana runtime/alerts.
|
||
|
||
Прежние helper checkpoints и ZIP8e15 остаются историческими. Новые native receipts находятся в evidence/openobserve; один request.size не объявляется жёстким лимитом результата SQL.
|
||
|
||
- `scripts/openobserve-request-path.ts`, `openobserve-response.ts`, `openobserve-search-window.ts` — pure native HTTP parameter/response boundaries called by openobserve.ts or openobserve-signals.ts and explicit regressions. No credential/process defaults.
|
||
- `scripts/openobserve-query-policy.ts` — native HAProxy ACL text consumed only by topology generator, adapted from checked lab6 policy without auth/userlist.
|
||
- `scripts/openobserve-readback.ts` — bounded recovery CLI for the exact retained failed parent dataset; uses openobserve-signals assertions, reuses persisted data and stops storage. It is not a fresh dataset bootstrap.
|
||
- `student-tests/openobserve-transport.ts`, `openobserve-gateway.ts` — native storage-only CLI checks. First invokes matrix scope openobserve and native account/rawport negatives; second generates and parses exact current gateway configs, then runs23 HTTP cases and binds pre/post configSHA. Both preserve source112 lease, fixed stage and primary failure, with own teardown.
|
||
|
||
- `scripts/validate-source.ts --openobserve` and `scripts/check-source.ts --openobserve` retain current migration results under evidence/openobserve instead of overwriting historical pre-migration source/public receipts. Their default consumers retain the existing security scope.
|
||
|
||
- Reader createSignalAssertions requires explicit request/clock ports; production assertOpenObserveSignals binds real ports, while reader.test.ts supplies only fakes and checks actual SQL end/PromQL time. createAccountWorkflow requires positive/deny/publish ports; provisionOpenObserve uses it before all derived publication, with exact validated credential snapshots. openobserve-account-workflow.test.ts never invokes the production process/client entrypoint.
|
||
- student-tests/openobserve-error-ratio.ts reads the mounted dashboard/rule expression and evaluates all3 mathematical classes on native OpenObserve. It reuses existing encrypted service accounts, verifies their unchanged hashes and production native200/403 guard, starts no producer and stops its storage-only stand.
|