Skip to content

chore(deps): replace humantime in the IC's own crates - #12383

Open
basvandijk wants to merge 9 commits into
bas/paste-to-pasteyfrom
bas/humantime-to-jiff
Open

basvandijk wants to merge 9 commits into
bas/paste-to-pasteyfrom
bas/humantime-to-jiff

Conversation

@basvandijk

@basvandijk basvandijk commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Removes humantime 2.4.0 from the IC's own crates. Stacked on #12381. It is unmaintained (RUSTSEC-2026-0542), and its repository was archived on 2026-10-07. The advisory stays in Cargo.lock and Cargo.Bazel.*.lock until ic-bn-lib (0.11.0), ic-gateway (v0.7.6) and tarpc (0.38.0) release versions without humantime.

Changes

  • The new crate humantime-vendored (rs/utils/humantime-vendored, owned by @dfinity/node) is a vendored copy of humantime 2.4.0's duration parser and formatter, with humantime's copyright and MIT/Apache-2.0 notice.
  • rate-limits-api (compiled into the rate-limit canister), ic-nervous-system-humanize and ic-boundary use it. So rule strings, NNS/SNS durations and ic-boundary's own 15 duration flags keep humantime's grammar and semantics (month = 2,630,016 s, year = 31,557,600 s), like the flags ic-boundary takes from ic-bn-lib. ic-bn-lib's own replacement, ic_bn_lib::parse_duration (Update all dependencies and Rust to 1.100.1 ic-bn-lib#164), ports the same parser.
  • ic-boundary formats the timestamp of websocket log messages with time, the way humantime's format_rfc3339 did.
  • The humantime workspace dependency and crate.spec are removed. ic-boundary asks for time's macros feature, which the time crate.spec gets too.
  • Golden tests recorded from humantime 2.4.0 pin the duration strings used in the repository (rate-limit rules, SNS init files, ic-admin tests) and edge cases, for humantime-vendored and for the wrappers in ic-nervous-system-humanize. ic-boundary's tests check its 15 defaults and that its flags take humantime's grammar.

Behaviour changes

  • Parse results, formatted strings and error messages are unchanged, with one exception. A duration whose nanoseconds carry one second past u64::MAX seconds (e.g. 18446744073709551615s 1000000000ns) now returns the overflow error instead of panicking. This applies to ic-boundary's duration flags, rate-limit rules and NNS/SNS durations.

🤖 Generated with Claude Code

basvandijk and others added 3 commits December 2, 2026 02:26
humantime is unmaintained (RUSTSEC-2026-0542). Remove it from the IC's
own crates:

- ic-boundary parses its duration flags with jiff's friendly duration
  format and formats the timestamp of websocket log messages with jiff.
- rate-limits-api and ic-nervous-system-humanize use a vendored copy of
  humantime 2.4.0's duration parser and formatter, so stored rule
  strings and NNS/SNS durations keep their exact semantics.
- Golden tests, captured from humantime 2.4.0, pin the parsed and
  formatted values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- parse_duration rejects a duration with months or years with "months
  and years are not supported, use days or weeks", instead of jiff's
  error that names `jiff::SpanRelativeTo::days_are_24_hours()`.
- Tests pin the inputs that the friendly format and humantime, which
  still parses the flags of ic-bn-lib, treat differently, and the
  largest value per unit that a jiff span accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@basvandijk
basvandijk added this pull request to stack #12378 December 2, 2026 02:38
@basvandijk basvandijk changed the title bas/humantime to jiff chore(deps): replace humantime in the IC's own crates Dec 2, 2026
@github-actions github-actions Bot added the chore label Dec 2, 2026
@basvandijk
basvandijk requested a balanced review from Copilot December 2, 2026 02:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The zero special case is checked before trimming, incorrectly rejecting whitespace-padded zero values and contradicting the intended trimmed-input behavior.

1 open issue
What changed in this PR

Removes direct use of unmaintained humantime from IC-owned crates while preserving governance and rate-limit duration semantics. Transitive dependencies remain.

Changes:

  • Uses jiff for ic-boundary duration flags and websocket timestamps.
  • Vendors duration parsing and formatting for governance and rate-limit APIs, including an overflow fix.
  • Updates Cargo/Bazel dependencies and adds compatibility tests.
File Description
rs/​nervous_system/​humanize/​src/​tests.rs Adds duration compatibility tests.
rs/​nervous_system/​humanize/​src/​lib.rs Registers the vendored module.
rs/​nervous_system/​humanize/​src/​humantime.rs Vendors duration parsing and formatting.
rs/​nervous_system/​humanize/​Cargo.toml Removes direct humantime dependency.
rs/​nervous_system/​humanize/​BUILD.bazel Removes humantime build dependencies.
rs/​boundary_node/​rate_limits/​api/​src/​schema_versions/​v1.rs Uses vendored helpers and tests rule compatibility.
rs/​boundary_node/​rate_limits/​api/​src/​lib.rs Registers the vendored module.
rs/​boundary_node/​rate_limits/​api/​src/​humantime/​tests.rs Tests duration compatibility and overflow handling.
rs/​boundary_node/​rate_limits/​api/​src/​humantime.rs Vendors duration parsing and formatting.
rs/​boundary_node/​rate_limits/​api/​Cargo.toml Removes direct humantime dependency.
rs/​boundary_node/​rate_limits/​api/​BUILD.bazel Removes humantime build dependencies.
rs/​boundary_node/​ic_boundary/​src/​metrics.rs Uses jiff timestamps with formatting tests.
rs/​boundary_node/​ic_boundary/​src/​cli.rs Adds jiff duration parsing and behavior tests.
rs/​boundary_node/​ic_boundary/​Cargo.toml Replaces humantime with jiff.
rs/​boundary_node/​ic_boundary/​BUILD.bazel Switches build targets to jiff.
Cargo.toml Replaces the workspace dependency.
Cargo.lock Updates affected crate dependencies.
Cargo.Bazel.toml.lock Updates direct Bazel dependencies.
Cargo.Bazel.json.lock Updates dependency metadata and checksum.
bazel/​rust.MODULE.bazel Replaces humantime’s specification with jiff’s.

Review effort: Balanced

Comment thread rs/boundary_node/ic_boundary/src/cli.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Operator confirmation is needed because the boundary-node CLI rejects previously accepted duration syntax, and repository defaults and golden tests do not cover deployed CLI or environment values.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the dependency migration.

No open issues 🎉

Review effort: Balanced

basvandijk and others added 3 commits December 2, 2026 17:19
The push of 141181f during GitHub's 2026-12-02 Actions incident started no workflow runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e parser

ic-boundary's own 15 duration flags parsed jiff's "friendly" format, whose grammar differs
from humantime's, so one command line accepted two grammars: the flags ic-boundary takes
from ic-bn-lib still use humantime's. They now use the copy of humantime 2.4.0's parser that
rate-limits-api already vendors, so every duration flag parses as before this PR, except
that a value that overflows is an error instead of a panic. ic-bn-lib's own replacement,
`ic_bn_lib::parse_duration` (dfinity/ic-bn-lib#164), ports the same parser.

The timestamps of websocket log messages are formatted with `time`, as humantime's
`format_rfc3339` formatted them, so no IC crate depends on jiff anymore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the duration-helper and timestamp migration.

No open issues 🎉

Review effort: Balanced

basvandijk and others added 2 commits December 3, 2026 16:08
…red crate

rate-limits-api and ic-nervous-system-humanize each had a copy of humantime 2.4.0's duration parser and
formatter, identical apart from where the tests live, and ic-boundary used rate-limits-api's through
`pub mod humantime`. All three now depend on the new crate rs/utils/humantime-vendored, owned by the
dfinity/node team, which holds that copy and its golden tests unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the duration-utility migration.

No open issues 🎉

Review effort: Balanced

@basvandijk
basvandijk marked this pull request as ready for review December 3, 2026 21:17
@basvandijk
basvandijk requested review from a team as code owners December 3, 2026 21:17

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

@zeropath-ai

zeropath-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed 3 of 5 changed files (2 skipped) up to 7b13645.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► .github/CODEOWNERS
    Add /rs/utils/humantime-vendored/ as a CODEOWNER
Enhancement ► Cargo.lock
    Update humantime-related checks/entries (switch from humantime to humantime-vendored)
Enhancement ► Cargo.Bazel.json.lock
    Update humantime checksum and references to humantime-vendored
Enhancement ► Cargo.Bazel.toml.lock
    Update humantime references to humantime-vendored
Enhancement ► Cargo.toml
    Add rs/utils/humantime-vendored to workspace members; replace humantime with vendored version where appropriate
Enhancement ► bazel/rust.MODULE.bazel
    Remove explicit humantime crate reference; add time crate dependency in relevant sections
Enhancement ► rs/boundary_node/ic_boundary/BUILD.bazel
    Add humantime-vendored as a dependency; remove direct humantime reference in several targets; introduce time crate where needed
Enhancement ► rs/boundary_node/ic_boundary/Cargo.toml
    Replace humantime with humantime-vendored; add time crate as workspace dependency
Enhancement ► rs/boundary_node/ic_boundary/src/cli.rs
    Switch import from humantime to humantime_vendored; preserve CLI functionality and tests additions
Enhancement ► rs/boundary_node/ic_boundary/src/metrics.rs
    Replace humantime::format_rfc3339 with new format_timestamp using time crate; update related test
Enhancement ► rs/boundary_node/rate_limits/api/BUILD.bazel
    Add humantime-vendored as dependency; remove direct humantime reference in deps
Enhancement ► rs/boundary_node/rate_limits/api/Cargo.toml
    Switch dependency from humantime to humantime-vendored
Enhancement ► rs/boundary_node/rate_limits/api/src/schema_versions/v1.rs
    Use humantime_vendored for format_duration/parse_duration
Enhancement ► rs/nervous_system/humanize/Cargo.toml
    Switch dependency from humantime to humantime-vendored
Enhancement ► rs/nervous_system/humanize/src/lib.rs
    Update references from humantime to humantime_vendored in doc/comments and usage
Enhancement ► rs/nervous_system/humanize/src/tests.rs
    Extensive tests added for vendored humantime usage and duration parsing/formatting
Enhancement ► rs/nervous_system/humanize/BUILD.bazel
    Replace humantime with humantime-vendored in deps for library and tests
Enhancement ► rs/nervous_system/humanize/README? and related vendored crate additions
    New vendored humantime-vendored crate files under rs/utils/humantime-vendored (BUILD.toml, Cargo.toml, src/lib.rs, README)
Enhancement ► rs/utils/humantime-vendored/BUILD.bazel
    Introduce vendored humantime crate shim (humantime_vendored) Version 2.4.0 -->

@zeropath-ai

zeropath-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed 3 of 4 changed files (1 skipped) up to 7b13645.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/utils/humantime-vendored/BUILD.bazel
    Add vendored humantime crate (humantime-vendored) integration
► rs/utils/humantime-vendored/Cargo.toml
    Introduce humantime-vendored crate (v2.4.0) dependency
► rs/utils/humantime-vendored/README.md
    Document vendored humantime usage
► rs/utils/humantime-vendored/src/lib.rs
    Provide vendored humantime implementation and APIs
► .github/CODEOWNERS
    Update ownership for humantime-vendored utilities
Refactor ► rs/boundary_node/ic_boundary/Cargo.toml
    Replace humantime with humantime-vendored dependency
► rs/boundary_node/ic_boundary/src/cli.rs
    Switch import from humantime to humantime_vendored
► rs/boundary_node/ic_boundary/src/metrics.rs
    Use format_timestamp helper and remove direct humantime usage
► rs/nervous_system/humanize/Cargo.toml
    Switch dependency from humantime to humantime-vendored
► rs/nervous_system/humanize/src/lib.rs
    Update references from humantime to humantime_vendored
► rs/nervous_system/humanize/BUILD.bazel
    Reflect vendored humantime usage in dependencies
► rs/nervous_system/humanize/BUILD.bazel
    Replace humantime with humantime-vendored in BUILD targets
► rs/nervous_system/humanize/Cargo.toml
    Vendored humantime dependency path update
► rs/boundary_node/ic_boundary/BUILD.bazel
    Include humantime-vendored in crate dependencies
► rs/boundary_node/ic_boundary/BUILD.bazel
    Remove direct humantime dependency references in BUILD
Bug Fix / Maintenance ► Cargo.toml
    Update workspace to include rs/utils/humantime-vendored in members
► bazel/rust.MODULE.bazel
    Remove humantime crate spec block to rely on vendored version
► rs/boundary_node/rate_limits/api/Cargo.toml
    Switch dependency humantime to humantime-vendored

@zeropath-ai

zeropath-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed 5 of 7 changed files (2 skipped) up to 7b13645.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/utils/humantime-vendored/BUILD.bazel
    Add vendored humantime crate (humantime-vendored) integration
► rs/utils/humantime-vendored/Cargo.toml
    Introduce humantime-vendored crate (v2.4.0) dependency
► rs/utils/humantime-vendored/README.md
    Document vendored humantime usage
► rs/utils/humantime-vendored/src/lib.rs
    Provide vendored humantime implementation and APIs
► .github/CODEOWNERS
    Update ownership for humantime-vendored utilities
Refactor ► rs/boundary_node/ic_boundary/Cargo.toml
    Replace humantime with humantime-vendored dependency
► rs/boundary_node/ic_boundary/src/cli.rs
    Switch import from humantime to humantime_vendored
► rs/boundary_node/ic_boundary/src/metrics.rs
    Use format_timestamp helper and remove direct humantime usage
► rs/nervous_system/humanize/Cargo.toml
    Switch dependency from humantime to humantime-vendored
► rs/nervous_system/humanize/src/lib.rs
    Update references from humantime to humantime_vendored
► rs/nervous_system/humanize/BUILD.bazel
    Reflect vendored humantime usage in dependencies
► rs/nervous_system/humanize/BUILD.bazel
    Replace humantime with humantime-vendored in BUILD targets
► rs/nervous_system/humanize/Cargo.toml
    Vendored humantime dependency path update
► rs/boundary_node/ic_boundary/BUILD.bazel
    Include humantime-vendored in crate dependencies
► rs/boundary_node/ic_boundary/BUILD.bazel
    Remove direct humantime dependency references in BUILD
Bug Fix / Maintenance ► Cargo.toml
    Update workspace to include rs/utils/humantime-vendored in members
► bazel/rust.MODULE.bazel
    Remove humantime crate spec block to rely on vendored version
► rs/boundary_node/rate_limits/api/Cargo.toml
    Switch dependency humantime to humantime-vendored

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

title suggestion: Use own copy of humantime library.

This answers "replace it WITH WHAT?". Then, the description should begin with something like

Because the original is no longer maintained (as of Oct 2026).

This quickly answers the next obvious question: WHY?

So, does this mean we are taking over the job of maintaining humantime? I mean, presumably not -> I'm not really sure what problem is solved by us copying their code into our repo. I guess if there is a bug, we can patch it quickly?

re the original title of this PR: not sure what you mean by "in the IC's own crates"? I mean, it is completely understood that the ic repo is the whole context here, since this PR is in the ic repo itself. Therefore, I'm not sure what (if anything) "in the IC's own crates" is supposed to add.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am certainly not against these new tests. Please, keep them.

but why are these suddenly being added? Did something special trigger this? I mean, if we literally just copied their code, there's "no chance" of changing the behavior, right? I guess this is just belt and suspenders?

("100wk", Ok(60_480_000)),
("1month", Ok(2_630_016)),
("3months", Ok(7_890_048)),
("12M", Ok(31_560_192)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In Governance, 1 month is exactly 1 / 12 of a year, and 1 year is defined as 365.25 days (precisely). (And 1 day is defined "normally".) These units are pretty cursed. I'm just the messenger.

So, 1 month = 2_629_800 s.

Therefore, I would leave these cases out too (similar to the subsecond cases).

"unknown time unit \"mo\", supported units: ns, us/µs, ms, sec, min, hours, days, weeks, months, years (and few variations)",
),
),
("1μs", Err("invalid character at 1")),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm. it is sad to me that this is not acceptable to humantime. I mean "μs" is completely standard. Oh well...

("1h30m", Ok(5400)),
(" 1h 30m ", Ok(5400)),
("1\ts", Ok(1)),
("1\ns", Ok(1)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wow. unit being on another line should probably be considered not acceptable. OTOH, I guess it's not technically harmful?? Maybe, we can (again) simply not test this case?

Comment on lines +170 to +178
("17nsec", Ok(0)),
("17nanos", Ok(0)),
("33ns", Ok(0)),
("3usec", Ok(0)),
("78us", Ok(0)),
("163µs", Ok(0)),
("31msec", Ok(0)),
("31millis", Ok(0)),
("6ms", Ok(0)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should maybe delete these cases, since we do not support subsecond resolution. I think we could add that later, but there is no plan to do that. Alternatively, these could be commented out.

Comment on lines +296 to +297
("1m 1m", Ok(120)),
("1h 1h", Ok(7200)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Repetition is pretty confusing. I would suggest not testing these either.

(I mean, it's fine if the production code returns Ok, or whatever. My goal is just to avoid PROMISING anything in these cases. I would, for example, also be ok if these inputs caused Err to be returned.)

Comment on lines +360 to +364
(2_630_015, "30days 10h 33m 35s"),
(2_630_016, "1month"),
(5_260_032, "2months"),
(31_449_600, "11months 29days 3h 50m 24s"),
(31_557_599, "11months 30days 9h 50m 23s"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because of NNS's wacky definition of 1 month, I would get rid of these cases.

(5_260_032, "2months"),
(31_449_600, "11months 29days 3h 50m 24s"),
(31_557_599, "11months 30days 9h 50m 23s"),
(31_557_600, "1year"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This matches Governance's definition of "1 year".

(126_230_400, "4years"),
(252_460_800, "8years"),
(378_691_200, "12years"),
(68_400_000, "2years 2months 6h 52m 48s"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto.

@schneiderstefan schneiderstefan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In this PR, the core protocol team was tagged for the utils files, even though the CODEOWNERS change clearly assigns them to the node team. I assume this is just a because the code owners change hasn't taken effect yet.

Approving so that we are not a blocker here, but I did not review the code that we not actually owning.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants