Skip to content

Hardening gemma4 - #31

Merged
armand0e merged 6 commits into
mainfrom
codex/repository-hardening-gemma4
Aug 25, 2026
Merged

Hardening gemma4#31
armand0e merged 6 commits into
mainfrom
codex/repository-hardening-gemma4

Conversation

@armand0e

Copy link
Copy Markdown
Collaborator

No description provided.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 270fb6d1d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/teich/anonymize.py
Comment on lines +315 to +317
_name_pattern = re.compile(
r"(?i)(?P<prefix>\b(?:my\s+name\s+is|full\s+name\s*[:=]|name\s*[:=])\s*)"
r"(?P<value>[A-Z][A-Za-z'-]+(?:\s+[A-Z][A-Za-z'-]+){1,3})"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve case sensitivity in the name PII matcher

Remove the global case-insensitive flag from the name value or otherwise enforce title casing. Because (?i) also makes [A-Z] case-insensitive, ordinary code and YAML such as name: npm install or name: Run tests is classified as a person's name. Extraction anonymizes all user and assistant text by default, so these common snippets are replaced with redacted_pii_* and the resulting training examples are corrupted.

Useful? React with 👍 / 👎.

Comment thread src/teich/formatter.py
Comment on lines +475 to +477
parts.append(text[cursor:match.end()])
if not text.startswith(_GEMMA_THOUGHT_PREFIX, match.end()):
parts.append(suffix)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit empty-thought insertion to actual model boundaries

Identify model-turn boundaries from the message structure rather than scanning the rendered string for every _GEMMA_TURN_START_PATTERN match. For affected non-thinking Gemma 4 templates, user or system content containing the literal <|turn>model\n—for example, a discussion of the chat template—also reaches this insertion path, so Teich injects an empty thought block into the original content; downstream Gemma span inference can then additionally treat the remainder as an assistant target.

Useful? React with 👍 / 👎.

Comment thread src/teich/anonymize.py Outdated
Comment on lines +813 to +815
marker = f"[redacted media {self._dummy_sequence(value, 16)}]".encode("utf-8")
self.counts["media"] += 1
return base64.b64encode(marker).decode("ascii")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep redacted media valid for its declared MIME type

Replace media with a valid placeholder of the declared type, or remove the media block entirely. This encodes a plain-text marker as base64 while leaving fields such as media_type: image/png unchanged, so any multimodal loader that decodes the anonymized payload as the declared image, audio, or video format receives invalid bytes and can fail before the dataset is prepared.

Useful? React with 👍 / 👎.

Comment thread src/teich/studio/server.py Outdated
Comment on lines +648 to +650
if queue.full():
try:
queue.get_nowait()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve terminal output when the websocket queue fills

Avoid silently removing the oldest chunk when a terminal produces output faster than the websocket can send it. Once this 256-item queue fills, get_nowait() permanently discards bytes from the live stream; large command output is therefore incomplete, and dropping a chunk in the middle of an ANSI escape sequence can also desynchronize the xterm display. Coalescing queued chunks or replaying from the terminal scrollback would bound memory without losing output.

Useful? React with 👍 / 👎.

@armand0e
armand0e merged commit 8ee4cfb into main Aug 25, 2026
6 checks passed
@armand0e
armand0e deleted the codex/repository-hardening-gemma4 branch August 25, 2026 05:20
@CompactAIOfficial CompactAIOfficial added question Further information is requested triaged labels Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants