Build CompText Universe inside Hugging Face Space - #21
Conversation
There was a problem hiding this comment.
Code Review
This pull request transforms the existing Hugging Face Space into 'CompText Universe,' a public showcase for the CompText local orchestration architecture. It introduces a modular UI with new tabs for architecture, capabilities, and contract previews, while implementing static data loading, secret scanning, and comprehensive testing. The reviewer suggested improving consistency in the UI return types for secret detection and refactoring string literals into constants in the preview module for better maintainability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| payload = { | ||
| "decision": "blocked", | ||
| "reason": "Potential secret material detected. Input was not processed.", | ||
| "secret_matches": secret_matches, | ||
| } | ||
| return text, payload, pd.DataFrame(), json.dumps(payload, ensure_ascii=False, indent=2), None |
There was a problem hiding this comment.
The object returned for the compression_metrics UI component is inconsistent. In this 'secret detected' case, you return a payload dictionary with lowercase keys. In the successful compression case, you return a metrics dictionary with capitalized keys and a different structure. This can be confusing for the UI and any programmatic consumers.
I suggest creating a metrics dictionary here that is consistent with the one in the success path, and use that for the UI component, while keeping the payload for the raw JSON output.
| payload = { | |
| "decision": "blocked", | |
| "reason": "Potential secret material detected. Input was not processed.", | |
| "secret_matches": secret_matches, | |
| } | |
| return text, payload, pd.DataFrame(), json.dumps(payload, ensure_ascii=False, indent=2), None | |
| metrics = { | |
| "Decision": "blocked", | |
| "Reason": "Potential secret material detected. Input was not processed.", | |
| "Secret matches": secret_matches, | |
| } | |
| payload = { | |
| "decision": "blocked", | |
| "reason": "Potential secret material detected. Input was not processed.", | |
| "secret_matches": secret_matches, | |
| } | |
| return text, metrics, pd.DataFrame(), json.dumps(payload, ensure_ascii=False, indent=2), None |
| def _constraints(text: str) -> list[str]: | ||
| lower = text.lower() | ||
| constraints: list[str] = [] | ||
| if any(term in lower for term in ("no provider", "keine provider", "keine live-provider", "without provider")): | ||
| constraints.append("no_provider_calls") | ||
| if "--dry-run" in text: | ||
| constraints.append("dry_run_only") | ||
| if any(term in lower for term in ("do not write", "nicht ändern", "nicht veraendern", "read only", "nur lesen")): | ||
| constraints.append("no_writes") | ||
| if any(term in lower for term in ("do not commit", "nicht commit", "no commit")): | ||
| constraints.append("no_commits") | ||
| return sorted(set(constraints)) |
There was a problem hiding this comment.
For improved readability and maintainability, the tuples of string literals used for matching constraints should be extracted into module-level constants. This avoids 'magic values' within the function and makes them easier to manage and reuse.
For example:
_NO_PROVIDER_TERMS = ("no provider", "keine provider", "keine live-provider", "without provider")
_NO_WRITES_TERMS = ("do not write", "nicht ändern", "nicht veraendern", "read only", "nur lesen")
_NO_COMMITS_TERMS = ("do not commit", "nicht commit", "no commit")
def _constraints(text: str) -> list[str]:
lower = text.lower()
constraints: list[str] = []
if any(term in lower for term in _NO_PROVIDER_TERMS):
constraints.append("no_provider_calls")
if "--dry-run" in text:
constraints.append("dry_run_only")
if any(term in lower for term in _NO_WRITES_TERMS):
constraints.append("no_writes")
if any(term in lower for term in _NO_COMMITS_TERMS):
constraints.append("no_commits")
return sorted(set(constraints))
Implements the approved CompText Universe + Compression Lab design while modifying only
hf_space/**.Includes:
Boundary verification: every changed path begins with
hf_space/.The Space remains an experimental public demonstration; the CompText runtime, CLI, schemas, workflows, providers, and TUI are untouched.