Skip to content

fix(semantic): preserve parser drift, action paths, and source paths #623

Closed

Description

@Sinity

Scope

Composite issue for preserving source/action semantics across provider parsers, materialization, semantic facts, referenced paths, attachments, and parser drift diagnostics.

Problem

Several parser and semantic-fact paths normalize or lose information before downstream products can consume it:

  • NotebookEdit is classified as a file edit, but production action metadata extraction misses notebook_path. MAY BE STALE: polylogue/pipeline/semantic_capture.py:159-163 already checks file_path, path, or notebook_path, and :184-189 handles NotebookEdit with new_source. Verify before implementing; mark resolved if the regression already passes.
  • Dotted basenames can be treated as path candidates solely because they have a suffix (polylogue/lib/viewport/tools.py:104-116: looks_like_path_candidate() treats any candidate with PurePosixPath(candidate).suffix as path-like).
  • Unknown provider message types normalize to normal message without preserving a drift fact.
  • Attachment paths are sanitized at parser-model construction time, before source-root materialization can decide whether an absolute path is trusted.
  • ChatGPT parser typed models and extraction logic still have duplication that makes provider drift fixes harder to apply once.

Design principle

Separate three layers for each finding:

  1. Raw provider/source evidence: the original path/token/message/action shape, quarantined or redacted only according to source trust rules.
  2. Normalized semantic fact: the portable field products query against.
  3. Display/export projection: privacy-safe and user-readable output.

Implementation order (from comment thread)

  1. Add drift-fact collection first (infrastructure, benefits all parsers) — unknown provider enum/message/path facts preserved in provider metadata or diagnostics with original value and provider/source.
  2. Fix attachment path ordering (clean semantics fix) — sanitization split into display-token sanitization and trusted source-root materialization. Absolute attachment paths under configured trusted roots tested separately from UI/display paths.
  3. Verify NotebookEdit regression — if it already passes against current code, mark resolved.
  4. Dotted basename heuristic tuning — regression for .github, foo.bar directory/repo names, package-lock/extensionless filenames, and real path contexts.
  5. ChatGPT typed model extraction — single typed content/message model path used by parser, schema roundtrip, and drift diagnostics.

Acceptance criteria

  • NotebookEdit inputs with notebook_path produce materialized action/file-change facts with the affected path (verify current behavior first).
  • Path-candidate heuristics distinguish dotted repo/directory names from file paths unless there is real path context.
  • Unknown provider enum/message/path facts are preserved in provider metadata or validation diagnostics instead of silently collapsing into common values.
  • Attachment display-path sanitization is separated from source-root materialization path resolution.
  • ChatGPT parser model and extraction paths have one typed source of truth for shared message/content semantics.
  • Regression tests cover NotebookEdit paths, dotted names, unknown message types, and source-root attachment materialization.

Consolidated findings

This issue absorbs and supersedes:

Related:

Ref #578
Ref #635

Activity

  1. changed the title [-]fix(semantic): preserve action paths and provider drift facts[/-] [+]fix(semantic): preserve parser drift, action paths, and source paths[/+] on May 1, 2026
  2. added
    area:core
    on May 1, 2026
  3. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Semantic-preservation guard: the parser should preserve raw/source facts before normalizing them for products.

    For each finding here, separate three layers:

    • raw provider/source evidence: the original path/token/message/action shape, quarantined or redacted only according to source trust rules;
    • normalized semantic fact: the portable field products query against;
    • display/export projection: privacy-safe and user-readable output.

    Attachment/source paths are the clearest risk: sanitizing at parser-model construction can destroy information that source-root materialization needs to decide whether the path is trusted. Conversely, leaving raw absolute paths in semantic facts or displays can leak local filesystem detail. The fix should keep both sides explicit, with tests proving raw trusted-source recovery and privacy-safe projection.

    Unknown provider message types should similarly become parser-drift facts or quarantined typed events, not silently normal message rows.

  4. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Implementation anchors and stale-claim guard from the 2026-05-01 follow-up audit.

    Refresh before implementation: the NotebookEdit sub-finding may be stale in current WD. polylogue/pipeline/semantic_capture.py:159-163 already checks file_path, path, or notebook_path, and :184-189 handles NotebookEdit with new_source. Keep the acceptance criterion as a regression over materialized action/file-change facts, not as an instruction to add a duplicate NotebookEdit branch. If the regression already passes, mark that sub-item resolved.

    Other concrete anchor:

    • polylogue/lib/viewport/tools.py:104-116: looks_like_path_candidate() treats any candidate with PurePosixPath(candidate).suffix as path-like. This can classify dotted repo/directory names as paths without real path context.

    Acceptance additions:

    • Regression for .github, foo.bar directory/repo names, package-lock/extensionless filenames, and real path contexts.
    • Unknown provider enum/message types are preserved in provider metadata or diagnostics with original value and provider/source, not coerced into normal message.
    • Attachment sanitization is split into display-token sanitization and trusted source-root materialization. Absolute attachment paths under configured trusted roots are tested separately from UI/display paths.
    • ChatGPT parser unification should include a single typed content/message model path used by parser, schema roundtrip, and drift diagnostics.
  5. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Semantic/parser drift decision from 2026-05-01 bundle

    Unknown provider/parser facts should preserve the original value plus diagnostics.

    Acceptance refinements:

    • Unknown message/provider/path values should not silently collapse into common canonical values.
    • Preserve unknown originals in provider metadata or drift diagnostics.
    • Only known values are canonicalized.
    • Path-token policies remain trust-boundary-specific.

    Ref #635

  6. Sinity commented on May 2, 2026

    @Sinity
    OwnerAuthor

    Concrete file inventory for the parser/semantic items

    The issue body mentions several distinct concerns. Here are the exact locations to check:

    NotebookEdit → notebook_path:

    • polylogue/sources/parsers/claude.py — search for NotebookEdit handling in the Codex/Claude action extraction
    • Check if notebook_path is present in the raw payload but dropped during action_event construction

    Dotted basenames treated as paths:

    • polylogue/archive/semantic/ — path candidate classification logic
    • Grep pattern: r"\.\w+" or suffix-based heuristics that might over-match dotted basenames

    Unknown provider message types → drift fact:

    • Each parser's message type dispatch (e.g., claude.py, chatgpt.py, codex.py) — unknown types currently normalize to generic message silently
    • Add a _drift_fact or diagnostics collector that records the raw type string before normalization

    Attachment path sanitization vs. materialization:

    • polylogue/archive/attachment.py — path sanitization at model construction
    • polylogue/sources/source.py — source-root materialization
    • The ordering issue: sanitization runs before source_root can decide whether an absolute path is trusted

    ChatGPT typed model extraction:

    • polylogue/sources/parsers/chatgpt.py — typed chatgpt model extraction
    • polylogue/sources/providers/chatgpt/ — provider-specific models

    Suggested implementation order

    1. Add drift-fact collection first (infrastructure, benefits all parsers)
    2. Fix attachment path ordering (clean semantics fix)
    3. NotebookEdit path (single-field extraction fix)
    4. Dotted basename heuristic (heuristic tuning, needs test corpus)
    5. ChatGPT typed model extraction (may be largest, do last)
  7. Sinity commented on May 2, 2026

    @Sinity
    OwnerAuthor

    Correction to my previous comment: @Sinity's earlier comment (2026-05-01) noted that the NotebookEdit sub-finding may be stale — polylogue/pipeline/semantic_capture.py:159-163 already checks file_path, path, or notebook_path, and :184-189 handles NotebookEdit with new_source.

    Before implementing anything, verify whether the NotebookEdit regression already passes against the current code. If it does, mark that sub-item resolved and focus on the remaining items:

    1. Add drift-fact collection for unknown provider message types
    2. Fix attachment path sanitization ordering (sanitization runs before source_root can decide whether absolute paths are trusted)
    3. Dotted basename heuristic tuning
    4. ChatGPT typed model extraction
  8. Sinity commented on May 3, 2026

    @Sinity
    OwnerAuthor

    Parser drift is already tracked via _PARSER_FINGERPRINT = "live-jsonl-full-file-v1" at polylogue/sources/live/watcher.py:29. The watcher compares this against cursor.parser_fingerprint on every acquisition (line 135). When the parser changes, the fingerprint version changes and files are re-parsed. Closing — the AC items around content-aware freshness are satisfied by the cursor content_fingerprint + parser_fingerprint mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:parsertype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions