The halfling's Lucky trait deals with the die roll (PHB, p. 28):
When you roll a 1 on an attack roll, ability check, or saving throw, you can reroll the die and must use the new roll.
And so does Advantage/Disadvantage, since it refers to the same trait (PHB, p. 173):
For example, if a halfling has advantage on an ability check and rolls a 1 and a 13, the halfling could use the Lucky trait to reroll the 1.
The Divination wizard's Portent feature, on the other hand, deals with the check as a whole:
You can replace any attack roll, saving throw, or ability check ... with one of these foretelling rolls.
And here comes the interesting part - the three emphasized terms are only mentioned in rules as actions, not numbers:
The description of attack rolls (PHB, p. 194):
To make an attack roll, roll a d20 and add the appropriate modifiers.
If the total of the roll plus modifiers equals or exceeds the
target’s Armor Class (AC), the attack hits.
Saving throws (PHB, p. 179):
To make a saving throw, roll a d20 and add the appropriate ability
modifier. [...]
A saving throw can be modified by a situational bonus or penalty [...]
[...] proficiency in a saving throw lets a character add his or her
proficiency bonus to saving throws made using a particular ability
score. [...]
And ability checks (PHB, p. 171):
To make an ability check, roll a d20 and add the relevant ability
modifier. As with other d20 rolls, apply bonuses and penalties, and
compare the total to the DC.
All three go the standard way:
- Roll a d20, get a number
- In case of (dis-)advantage: roll another d20, get a new number (or
keep the old)
- Add bonuses/penalties, get the final number
- Compare the final number with the AC/DC and get the final
success/failure answer
From the strict RAW reading of Portent, we have to replace steps 1–4 (the whole check) with a number (foretelling roll), which makes no sense, as the result has to be boolean – success/failure.
If we loosen the restrictions, the logical thing to say would be "In the context of Portent, attack roll/saving throw/ability check is the number to be compared with the AC/DC" (i.e. the result of Step 3 above). In this interpretation "You must choose to do so before the roll" means that the decision is made before Step 1 and therefore no actual die roll happens. The modifiers are applied to the foretold roll as normal. This interpretation is reinforced by an unofficial tweet from March 2015 by rules designer Jeremy Crawford:
The portent die is intended to replace a d20 roll only, not any modifiers applied to it.
This result is Rules As Intended as well; the whole point is that the character knows in advance what is going to happen.
Rules as written, it is left to DM or the table for interpretation
Rules as written what you're supposed to do is look at Nondetection and Portent and decide for your table how it works. You're supposed to look at what the intent of Nondetection and the intent of Portent is supposed to be, which means you'll have to read and decide for yourself based on how you understand the rules and what works best for the fun and enjoyment of your table. That is 5e's rules philosophy.
I don't buy the "It doesn't say it is or it isn't, therefore it isn't." You can just as easily say, "It doesn't say it is or it isn't, therefore it is." Lack of evidence doesn't prove anything. The game rules do not claim to be comprehensive, and this is the natural consequence of that. This is the entire point the "rulings not rules" idiom is making. There is no burden of proof on Portent or Nondetection or the PHB as a whole to provide an answer. While that line of reasoning was implicit to 3e and 4e -- both editions that sought comprehensive and complete rules sets -- 5e actively does not do that. 5e D&D is often intentionally vague so as to leave rules open for interpretation and the system intentionally doesn't use keywords or raw mechanics. It does this so that players and DMs have the explicit freedom to interpret the rules for themselves and do what makes sense for that interaction. The designers know they can't possibly foresee every interaction in the rules, so they no longer try.
There is no clear answer by design. Yes, this means that asking, "What is RAW?" on RPG SE for 5e D&D is often a pointless exercise because the answer you should often get is, "RAW it depends on your table." This is why there are so many conflicting answers on RPG SE for 5e questions and why Sage Advice contradicts itself so often.
The rules are less important than the game. What Mearls and Crawford want is for players and DMs to stop asking WotC how to play and just make a decisions and play for themselves. If you make a mistake, admit it and make a correction. It's no less destructive than doing nothing until WotC makes a decision and then maybe changes their mind later.
You're expected to look at whole picture that the rules are giving you and to make a judgement call on what feels the most consistent and correct for your table. Is it reasonable for Nondetection to block Portent? Sure, it almost certainly is divination magic given that it's an ability of the Diviner subclass. How about a Ranger's Primeval Awareness? Well, that works like a spell, even consuming a spell slot, and it would have to be divination magic given the distance, so sure. How about a Paladin's Divine Sense? Hm... possibly, it's pretty close to Detect Good and Evil, but it's really described as the Paladin's senses. A Warlock's Devil's Sight? Hrm, hard to say. It's got elements that only True Seeing can accomplish, and Nondetection probably blocks True Seeing, but it's basically an improved Darkvision spell and that's not even Divination. So maybe partially? A Barbarian's Feral Instinct? Eh, that doesn't seem right, it's not magical. A Rogue's Blindsense? Yeah, probably not unless Blindsense is supposed to be magical, but I don't get that impression.
Best Answer
No, there is no way to know that Portent was "used"
Portent is an unusual feature in that it leverages the distinction between the player and their character. Obviously, it is the player's choice when to replace a roll with a foretelling roll, but within the fiction, this does not correspond to any action or even any thought or intent on the character's part. All the character does is witness the fact that the glimpse of the future they received earlier that day has indeed come to pass.
To put it another way, when a foretelling roll is used, nothing changes in the present. Instead, the player retroactively decides what vision of the future their character has already received in the past. Hence, there is no detectable effect to be noticed in the present to determine that the feature was used.
This interpretation is supported by the first sentence of the feature, which is the only part that describes how it works rather than the mechanics of using it:
Also note that no action or reaction of any kind is required to use the feature. If Portent represented an active manipulation of probability or fate by the diviner, it would make more sense for it to require a reaction to do so. Contrast this with the Wild Magic sorceror's Bend Luck ability, which explicitly does actively manipulate fate, and requires the sorceror's reaction to do so (emphasis added):
In the case of the Bend Luck ability, the sorceror is using their force of will to change something rather than passively witnessing something they had seen in a vision. In this case, it might not be unreasonable for the DM to rule that the victim sensed some kind of probabilistic funny business going on, e.g. "I'm sure that rock I tripped over wasn't there a second ago!"
Immunity to frightening (or another condition) is not a dead giveaway for your secret magic item
To address your specific problem, immunity to fear is not a terribly rare effect, so that alone isn't necessarily going to tip off your players that a special magic item is in play. Furthermore, if your players do infer that a magic item is protecting NPC from fear, they will most likely assume that the item does that and nothing more. From your question, it seems like the item in question probably does a good deal more than simply protect from fear. But if you're really worried about your players figuring it out, I think the best advice is to make sure you can still tell an interesting story if they do so, even if it's different from the story you had planned.
It seems that the fear effect was just an example, but the same can be said of most other condition immunities. At worst, your players will probably suspect a magic item or spell that specifically protects from that one condition.