Skip to content

MILAB-6225: Add federative envelope handling to Ls API#1647

Open
vgpopov wants to merge 1 commit into
mainfrom
MILAB-6225/identity-propogation
Open

MILAB-6225: Add federative envelope handling to Ls API#1647
vgpopov wants to merge 1 commit into
mainfrom
MILAB-6225/identity-propogation

Conversation

@vgpopov
Copy link
Copy Markdown
Contributor

@vgpopov vgpopov commented May 19, 2026

  • Extend Ls API to carry additionalInfo envelope for federative storages
  • Switch list results to a file-stats variant and propagate envelopes
  • Pass envelope through to index handles when present
  • Update REST/GRPC schemas to include additionalInfo
  • Add tests to verify envelope threading and absence when empty

Greptile Summary

This PR extends the Ls API to carry a federative identity envelope (additionalInfo, a map<string, string>) through the full stack — proto definition, gRPC and REST codegen, TypeScript client, and index handle serialisation — so that downstream consumers can verify signed identity envelopes from federative storages.

  • Proto / schema layer: additional_info = 8 added to LsAPI_ListItem in .proto, OpenAPI YAML, and both generated TypeScript stubs (gRPC and REST).
  • Handle serialisation: createIndexImportHandle now accepts an optional additionalInfo map and only embeds it when non-empty, keeping existing URLs byte-identical.
  • Driver rename + threading: listRemoteFilesWithAdditionalInfo is renamed to listRemoteFilesWithFileStats; both listFiles and listRemoteFilesWithFileStats now forward e.additionalInfo to the handle builder.

Confidence Score: 3/5

The data flow and serialisation are correct; the hand-written protobuf map decoder in protocol.ts will throw a hard error on any unrecognised field number, which is unsafe for forward compatibility.

The hand-written binaryReadMap8 in the generated gRPC file unconditionally throws on unknown field numbers rather than skipping them. Every other field in the same generated file respects options.readUnknownField. Under normal proto version alignment this path never triggers, but it is a latent runtime breakage that needs fixing before this decoder is relied on in production for federative storages.

lib/node/pl-drivers/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts — the binaryReadMap8 default case needs attention.

Important Files Changed

Filename Overview
lib/node/pl-drivers/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts Adds additionalInfo map field (field 8) to LsAPI_ListItem with a hand-written binaryReadMap8 decoder. The decoder throws on any unrecognised field number instead of skipping it per proto3 spec, which could break parsing under version skew.
lib/node/pl-drivers/src/drivers/helpers/ls_remote_import_handle.ts Adds optional additionalInfo parameter to createIndexImportHandle; only embeds it when non-empty, preserving byte-identical URLs for non-federative storages.
lib/node/pl-drivers/src/drivers/ls.ts Renames listRemoteFilesWithAdditionalInfo to listRemoteFilesWithFileStats and threads e.additionalInfo into both list methods; two TODO-4 comments remain in production call sites.
lib/node/pl-drivers/src/drivers/types.ts Adds optional additionalInfo: z.record(z.string(), z.string()) to ImportFileHandleIndexData Zod schema; backwards compatible.
lib/node/pl-drivers/src/drivers/ls.test.ts Extends existing test file with LsDriver additionalInfo threading suite covering envelope propagation in both list methods.

Sequence Diagram

sequenceDiagram
    participant Backend as gRPC/REST Backend
    participant Client as ClientLs (ls_api.ts)
    participant Driver as LsDriver (ls.ts)
    participant Handle as createIndexImportHandle
    participant Consumer as Downstream Consumer

    Backend->>Client: "LsAPI_ListItem { additionalInfo, fullName, ... }"
    Client->>Driver: items with additionalInfo map
    Driver->>Handle: createIndexImportHandle(storageId, fullName, additionalInfo)
    Note over Handle: non-empty? embed in JSON, else omit
    Handle-->>Driver: index://index/encoded-JSON
    Driver-->>Consumer: "LsEntry { handle, type, name, fullPath }"
    Consumer->>Consumer: "parseIndexHandle -> { storageId, path, additionalInfo? }"
Loading

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
lib/node/pl-drivers/src/proto-grpc/github.com/milaboratory/pl/controllers/shared/grpc/lsapi/protocol.ts:242-257
**Unconditional throw on unknown fields breaks proto3 forward compatibility**

The `default` case throws unconditionally regardless of the `options.readUnknownField` configuration, while the outer `internalBinaryRead` properly gates on `options.readUnknownField`. Any wire format that carries an unexpected field number in the `additional_info` map entry — due to proto version skew, future extensions, or a misbehaving upstream — will throw a hard error instead of skipping the field as proto3 requires. The `options` argument is accepted but ignored in this path. The standard fix is to call `reader.skip(wireType)` (with optional `UnknownFieldHandler.onRead`) rather than throwing.

### Issue 2 of 2
lib/node/pl-drivers/src/drivers/ls.ts:220-221
These `TODO-4` references are left in production code paths and will appear in every `listFiles` and `listRemoteFilesWithFileStats` call. If this work item has a separate tracking ticket, the comment should reference that ticket explicitly; if it was already resolved in this PR, the TODO can be removed.

```suggestion
          handle: createIndexImportHandle(storageData.storageId, e.fullName, e.additionalInfo),
```

Reviews (1): Last reviewed commit: "[MILAB-6225]: Add federative envelope ha..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: e4c4c21

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@milaboratories/pl-middle-layer Minor
@milaboratories/pl-drivers Minor
@milaboratories/pl-mcp-server Major
@platforma-sdk/pl-cli Patch
@platforma-sdk/test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@notion-workspace
Copy link
Copy Markdown

@vgpopov vgpopov changed the title Add federative envelope handling to Ls API MILAB-6225: Add federative envelope handling to Ls API May 19, 2026
@vgpopov vgpopov force-pushed the MILAB-6225/identity-propogation branch from 5157b0a to 504a380 Compare May 19, 2026 16:17
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for federative identity envelopes by adding an additionalInfo field to storage listing responses and import handles across the OpenAPI, Protobuf, and TypeScript layers. It also renames several internal types and methods related to remote file listing for clarity. Review feedback suggests using bigint for file sizes to prevent precision loss and cleaning up TODO placeholders in the comments.

Comment thread lib/node/pl-drivers/src/drivers/ls.ts
Comment thread lib/node/pl-drivers/src/drivers/ls.ts Outdated
Comment thread lib/node/pl-drivers/src/drivers/ls.ts Outdated
Comment thread lib/node/pl-drivers/src/drivers/ls.ts
Comment thread lib/node/pl-drivers/src/drivers/ls.test.ts
Comment thread lib/node/pl-drivers/src/drivers/ls.ts Outdated
@vgpopov vgpopov force-pushed the MILAB-6225/identity-propogation branch from 504a380 to d0fd3c3 Compare May 19, 2026 16:38
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
1240 4 1236 14
View the top 3 failed test(s) by shortest run time
src/drivers/ls.test.ts > LsDriver additionalInfo threading > listRemoteFilesWithFileStats: handle carries additionalInfo envelope
Stack Traces | 0.000754s run time
Error: Not a signed resource id (no '|' separator): res-id
 ❯ asSignedResourceId ...../src/core/types.ts:305:26
 ❯ parseRemoteStorageHandle .../drivers/helpers/ls_storage_entry.ts:87:22
 ❯ parseStorageHandle .../drivers/helpers/ls_storage_entry.ts:17:12
 ❯ LsDriver.listRemoteFilesWithFileStats src/drivers/ls.ts:256:25
 ❯ src/drivers/ls.test.ts:248:33
src/drivers/ls.test.ts > LsDriver additionalInfo threading > listRemoteFilesWithFileStats: no additionalInfo when absent in item
Stack Traces | 0.000961s run time
Error: Not a signed resource id (no '|' separator): res-id
 ❯ asSignedResourceId ...../src/core/types.ts:305:26
 ❯ parseRemoteStorageHandle .../drivers/helpers/ls_storage_entry.ts:87:22
 ❯ parseStorageHandle .../drivers/helpers/ls_storage_entry.ts:17:12
 ❯ LsDriver.listRemoteFilesWithFileStats src/drivers/ls.ts:256:25
 ❯ src/drivers/ls.test.ts:272:33
src/drivers/ls.test.ts > LsDriver additionalInfo threading > listFiles: handle has no additionalInfo when item has empty envelope
Stack Traces | 0.00114s run time
Error: Not a signed resource id (no '|' separator): res-id
 ❯ asSignedResourceId ...../src/core/types.ts:305:26
 ❯ parseRemoteStorageHandle .../drivers/helpers/ls_storage_entry.ts:87:22
 ❯ parseStorageHandle .../drivers/helpers/ls_storage_entry.ts:17:12
 ❯ LsDriver.listFiles src/drivers/ls.ts:210:25
 ❯ src/drivers/ls.test.ts:225:33
src/drivers/ls.test.ts > LsDriver additionalInfo threading > listFiles: handle carries additionalInfo envelope from gRPC item
Stack Traces | 0.00905s run time
Error: Not a signed resource id (no '|' separator): res-id
 ❯ asSignedResourceId ...../src/core/types.ts:305:26
 ❯ parseRemoteStorageHandle .../drivers/helpers/ls_storage_entry.ts:87:22
 ❯ parseStorageHandle .../drivers/helpers/ls_storage_entry.ts:17:12
 ❯ LsDriver.listFiles src/drivers/ls.ts:210:25
 ❯ src/drivers/ls.test.ts:202:33

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

- Extend Ls API to carry additionalInfo envelope for federative storages
- Switch list results to a file-stats variant and propagate envelopes
- Pass envelope through to index handles when present
- Update REST/GRPC schemas to include additionalInfo
- Add tests to verify envelope threading and absence when empty
@vgpopov vgpopov force-pushed the MILAB-6225/identity-propogation branch from d0fd3c3 to e4c4c21 Compare May 19, 2026 17:08
Sign up for free to 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.

3 participants