Skip to content

refactor(logs,landscape): unified log targets, injection-safe profile writes - #56

Merged
Datata1 merged 1 commit into
mainfrom
refactor/05-logs-landscape-hardening
Jul 12, 2026
Merged

refactor(logs,landscape): unified log targets, injection-safe profile writes#56
Datata1 merged 1 commit into
mainfrom
refactor/05-logs-landscape-hardening

Conversation

@Datata1

Copy link
Copy Markdown
Owner

Implements plans/refactor/05-logs-landscape-hardening.md:

  • One stream/collect implementation instead of six: frozen target dataclasses (StageTarget, ServerTarget, ReplicaTarget) select the StreamOperation; WorkspaceLogManager.open/stream/collect take a LogTarget. The six legacy methods (stream_server, stream_replica, collect_server, collect_replica, open_*_stream) and the positional stream(stage, step) form remain as deprecated shims that warn and delegate (tested via pytest.warns)
  • save_profile no longer builds a shell heredoc from user content: YAML is transported base64-encoded (printf '%s' '' | base64 -d), so content containing PROFILE_EOF, , backticks, or quotes is inert; get/delete_profile filenames are single-quoted. Adversarial round-trip tests cover terminator/substitution/quote/CRLF/unicode payloads
  • LogStream takes the APIHttpClient and uses its new public stream() passthrough and stream_timeout property (configured connect timeout, unbounded read) instead of reaching into _get_client() with a hardcoded Timeout(5.0); SSE terminator event names are a module constant
  • LogEntry.kind is a LogKind enum (I/E) with str fallback for unknown values (left_to_right union)

No breaking changes: all legacy method names keep working with a DeprecationWarning.

… writes
Implements plans/refactor/05-logs-landscape-hardening.md:
- One stream/collect implementation instead of six: frozen target
dataclasses (StageTarget, ServerTarget, ReplicaTarget) select the
StreamOperation; WorkspaceLogManager.open/stream/collect take a
LogTarget. The six legacy methods (stream_server, stream_replica,
collect_server, collect_replica, open_*_stream) and the positional
stream(stage, step) form remain as deprecated shims that warn and
delegate (tested via pytest.warns)
- save_profile no longer builds a shell heredoc from user content:
YAML is transported base64-encoded (printf '%s' '<b64>' | base64 -d),
so content containing PROFILE_EOF, , backticks, or quotes is
inert; get/delete_profile filenames are single-quoted. Adversarial
round-trip tests cover terminator/substitution/quote/CRLF/unicode
payloads
- LogStream takes the APIHttpClient and uses its new public stream()
passthrough and stream_timeout property (configured connect timeout,
unbounded read) instead of reaching into _get_client() with a
hardcoded Timeout(5.0); SSE terminator event names are a module
constant
- LogEntry.kind is a LogKind enum (I/E) with str fallback for unknown
values (left_to_right union)
No breaking changes: all legacy method names keep working with a
DeprecationWarning.
@Datata1Datata1 self-assigned this Jul 12, 2026
@github-actions

Copy link
Copy Markdown

🛡️ Bandit Security Scan Results

✅ No security issues found by Bandit.

@github-actions

Copy link
Copy Markdown

Coverage

Pytest Coverage Report
FileStmtsMissBranchBrPartCoverMissing
__init__.py9000100%
client.py40060100%
config.py9000100%
exceptions.py9432382259%25->30, 40–42, 53->58, 54->55, 55, 73->74, 74, 85–87, 101–104, 106–107, 148–151, 158–160, 196->197, 197–199, 204->205, 205, 206->207, 207, 210->211, 211, 214, 215->216, 216, 217->218, 218–219, 222
http_client.py59106282%45, 51–52, 58, 61->exit, 71->exit, 106–107, 109–110, 115–116
utils.py1024179%9->10, 10–11
core
__init__.py4000100%
base.py55020100%
handler.py59318096%80–82
operations.py15000100%
resources
__init__.py0000100%
resources/metadata
__init__.py3000100%
operations.py6000100%
resources.py13000100%
schemas.py28000100%
resources/team
__init__.py5000100%
operations.py8000100%
resources.py11000100%
schemas.py27000100%
resources/team/domain
__init__.py3000100%
operations.py11000100%
resources.py16000100%
schemas.py5550091%67, 69, 72, 75–76
resources/team/usage
__init__.py3000100%
operations.py4000100%
resources.py4328292%99->102, 102, 162->165, 165
schemas.py7076584%66->67, 67, 72–73, 76, 84–86
resources/workspace
__init__.py5000100%
envVars.py4000100%
operations.py12000100%
resources.py1624280%13->14, 14, 19->20, 20
schemas.py99146681%100–101, 103–109, 115–116, 118, 142, 161
resources/workspace/env_vars
__init__.py3000100%
operations.py7000100%
resources.py25212484%28->30, 30–31, 33->exit
schemas.py4000100%
resources/workspace/git
__init__.py3000100%
operations.py8000100%
resources.py15040100%
schemas.py4000100%
resources/workspace/landscape
__init__.py3000100%
operations.py12000100%
resources.py96736889%28->29, 29, 129->132, 135->138, 161->162, 162–163, 165->160, 168->169, 169, 173–175
schemas.py2902910489%113–114, 117, 122–123, 126–127, 130, 135–137, 140–141, 144, 251, 258–259, 334–336, 338–340, 342–343, 458–459, 466–467
resources/workspace/logs
__init__.py3000100%
operations.py5000100%
resources.py17550603763%66->68, 68, 97–98, 104, 106–108, 110, 113–114, 117, 120–121, 123–126, 128–129, 132–133, 135–136, 138–139, 141–143, 145–146, 148–152, 154–155, 157–159, 161–166, 179–180, 252–253
schemas.py22000100%
TOTAL14711652209385%

Test Execution Summary

TestsSkippedFailuresErrorsTime
3000 💤0 ❌0 🔥3.178s ⏱️

@Datata1
Datata1 merged commit a812cf6 into mainJul 12, 2026
3 of 4 checks passed
Sign up for freeto 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

@Datata1